Need debugging gltf instancing

got this example from Michael, great got so far ,

got this working , but the rotation has gone funky , and some instances missing materials and showing wireframes ?

  const gltfProjectLoader = new GLTFLoader(manager);

  var dummy = new THREE.Object3D();

  gltfProjectLoader.load('models/projectsModel.glb', function (gltf) {

    rootProjects = gltf.scene;
    projectsObj = rootProjects;
    projectsObj.getObjectByName("gltf_object_name");
    

    gltf.scene.traverse( function ( child ) {

      if ( child.isMesh ) {
             
        for ( let i = 0; i < 50; i ++ ) {

          instancedGeo = new THREE.InstancedMesh(child.geometry, child.material, 1);
          instancedGeo.setMatrixAt( 0, dummy.matrix );
          instancedGeo.position.x = getRandomFloatInclusive(100, -200) ;
          instancedGeo.position.y = getRandomFloatInclusive(100, -200) ;
          instancedGeo.position.z = getRandomFloatInclusive(-10, -100);
          instancedGeo.scale.x = instancedGeo.scale.y = instancedGeo.scale.z = Math.random() * 3 + 1;
          pointsGltf.push(instancedGeo);
          instancedGeo.needsUpdate = true;
          scene.add(instancedGeo);
            
        }

      }

    });
      
  });

Hi, do you have a question about this code or did you perhaps intend to private message someone who knows Michael?

Hi dubois,

what i meant to say was, i got the instancing gltf example from Michael’s post ,
i modified it to make it work in my code ,

and everything else works , except the instances are not at original rotation of the gltf object,
materials missing and showing wireframe on some instances,
if Michael , yourself or anyone shed some light on this would be much apritiated

Thanks

1 Like

Solved this ,

1 no materials missing , the glb object had 2 meshes , so that is sorted
2 the rotation bit fixed it as well

it works now

1 Like

Good to know that it was an issue with two meshes and I’m glad you got it working.