How do I get the THREE.JS InstancedMesh working?

1.3k views Asked by At

I'm trying to use the THREE.JS InstancedMesh to make copies of an imported gltf file, but nothing shows up in the scene. This is the code I've used so far:

const equatorMaterial = new THREE.MeshStandardMaterial({color: 0x242526, metalness:1, 
    opacity:0.8, roughness:0.8} )


let ball;

const loader = new GLTFLoader()

loader.load( './ball.gltf', function ( gltf ) { //load sphere
    gltf.scene.traverse(function(model) {
        if (model.isMesh) {
            //model.castShadow = true;
            ball = model.geometry
        }
    });
    let mesh = new THREE.InstancedMesh(ball, equatorMaterial, 20)
    scene.add( mesh )   
}, undefined, function ( error ) {
    console.error( error );
} );
0

There are 0 answers