Instanced mesh in blender -> glb -> three.js - is it instanced in three.js?

If you instance a mesh in Blender, and then bundle the instances into a glb file, will they each act as an instanced mesh in Three.js? i.e. a single draw call?

No the gltf loader will not create an instancedMesh. However the instances geometry is reused within the gltf file, so it’s still a good idea to export instances when you can to reduce the file size. Then when you import a gltf file with three.js, you can loop through the imported scene and re-create the instances with THREE.InstancedMesh.

more in this thread

1 Like

thank you - that makes sense. How can you identify a mesh as instanced when looping through that scene?

1 Like

As far as I know you have to do it with their names… You name your instances in blender like “my-instance-01”, then in three.js you check the names of the imported scene children.

glb.scene.traverse( (child) => {
	
	if ( child.name && child.name.includes( 'my-instance' ) ) {

		// add to instancedMesh

	}

} );

I’m sure there must be a better way, but that’s how I do it.