THREE.js: Errormessage "THREE.OBJLoader is not a constructor" THREE.js: Errormessage "THREE.OBJLoader is not a constructor" javascript javascript

THREE.js: Errormessage "THREE.OBJLoader is not a constructor"


When you are copying from Codepen examples, always go to pen and check under the 'Settings' to see any other files which are used in the project.

In your case, the author is using OBJLoader.js and that's where OBJLoader constructor is coming from and you don't have a reference to that. Hence, you're getting the error. Include the reference and it should be working.


you can use ObjectLoader.js

var objLoader = new THREE.ObjectLoader();

note: OBJLoader not working


import OBJLoader- import { OBJLoader } from './jsm/loaders/OBJLoader.js';

enter image description here