Convert glTF to BufferGeomerty for InstancedMesh?


I am trying to make preformance better by using InstancedMesh, and I am following the example:

But my files are glb, glTF files, not buffergeomery JSONs like in the example. My question is how do I “convert” or use the glb files in InstancedMesh?

InstancedMesh only takes buffergeomery:

This does not work anymore:

I guess because the Object3D were remade or?

I found child.toJSON:
gltf.scene.traverse( function ( child ) {
stuff = child.toJSON();
} );

but I can’t get a “normal” Three.buffergeomerty like the buffergeomertyloader gives me. I guess I have missed something but what have I missed?

Best Regards

The instancing / scatter example (source code) might help. GLTFLoader returns a scene graph that might contain multiple meshes. Each of those meshes will already have a BufferGeometry attached to it. If there’s just on mesh then things are pretty simple, if there’s more than one you’ll need multiple InstancedMesh objects with appropriate offsets.