I
I
IliaNeverov2020-07-05 14:35:57
JavaScript
IliaNeverov, 2020-07-05 14:35:57

Why is the 3d model not showing on stage?

Why, when I try to insert a 3d model in obj format into the scene using three js, the model is not shown? Who needs to be corrected?
Here is an example Javascript code that I am trying to insert this 3d model:

var oLoader = new THREE.OBJLoader();
oLoader.load('model/untitled.obj', function(object, materials) {
  var material2 = new THREE.MeshLambertMaterial({ color: 0xa65e00 });
  object.traverse( function(child) {
    if (child instanceof THREE.Mesh) {
      // apply custom material
      child.material = material2;
      // enable casting shadows
      child.castShadow = true;
      child.receiveShadow = true;
    }
  });
  object.position.x = 0;

  object.position.y = 0;

  object.position.z = 0;

  object.scale.set(1, 1, 1);

  lesson6.scene.add(object);

});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2020-07-05
@IliaNeverov

material.needsUpdate = true
https://threejs.org/docs/#manual/en/introduction/H...

K
Kalombyr, 2020-07-05
@Kalombyr

Good day.
It is possible that some error occurs during the download - you do not have tracking of them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question