2

i got error three.min.js:2 THREE.Object3D.add: object not an instance of THREE.Object3D when try to run the 3D object.

  const loader = new THREE.OBJLoader();

  loader.load("./model/Room.obj", function (object) {
    scene.add(object.scene);
    console.log(object);
    renderer.render(scene, camera);
  });
2
  • 2
    Try just scene.add(object);. Commented Nov 26, 2020 at 9:18
  • now it come like this app.js:53 Uncaught ReferenceError: loader is not defined at init (app.js:53) at app.js:59 Commented Nov 26, 2020 at 9:21

1 Answer 1

3

Instead of doing:

scene.add(object.scene);

just do this when using OBJLoader:

scene.add(object);

OBJLoader always returns an instance of THREE.Group which has no scene property.

Also notice that the various loaders in three.js return their results in slightly different ways. Meaning the code in the onLoad() callback is specific for the respective loader.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.