I'm trying to load a .obj file in three.js but I'm having trouble importing the libraries for the object loader. In the console it says THREE.OBJLoader2 is not a constructor. I'm trying to load the file locally.
I also tried loading the .gltf file using the gltfloader library, but I can't seem to import the libraries correctly.
this is the html code to import the OBJLoader script:
<script src="resources/threejs/r105/js/loaders/LoaderSupport.js"></script>
<script src="resources/threejs/r105/js/loaders/OBJLoader2.js"></script>
this is the js code for obj loader:
const objLoader = new THREE.OBJLoader2();
objLoader.load('house.obj', (event) => {
const root = event.detail.loaderRootNode;
scene.add(root);
});
I also tried to import the libraries locally by creating a GLTFLoader.js file and using
<script src="GLTFLoader.js"></script>
but that did not work either.