Hello guys, Is it possible to export instancedMesh directly to three.js scene with blender?
I see that the GLTFLoader
build InstancedMesh where there is a “node” type data, but I do not know how to do it.
//GLTFLoader.js
//....
case 'node':
dependency = this._invokeOne(function (ext) {
return ext.loadNode && ext.loadNode(index)
})
break
// class GLTFMeshGpuInstancing
//.....
const instancedMesh = new InstancedMesh(mesh.geometry, mesh.material, count)
//....
I’ve tried alt+D
to duplicate or make instance collection
with blender ,but non of them make true instancedMesh in three.js.
And the blender extension GitHub - takahirox/glTF-Blender-IO-EXT-mesh-gpu-instancing seems not compatible with Blender4.0.
Yes. The most recent built in blender->gltf exporter handles instances, and thrreejs knows how to create them on loading.
You have to set it up carefully in blender. To make an instance of another mesh, you use Alt-D instead of Shift-D to duplicate it. that creates an instance.
Also If the instances don’t have the same parent I think it breaks instancing.
It might even require that they don’t have a parent, and are just in the scene.
Hi, I’ve tried Alt-D to duplicate a simple cube, but failed with or without same parent.I must have missed some thing
A quick check to see if your glTF model is set up for GPU instancing would be:
gltf-transform inspect scene.glb
If you see EXT_mesh_gpu_instancing
listed near the top of the output, under extensionsUsed
, then your glTF export should generate at least one InstancedMesh in three.js.
There are two relevant options in the Blender exporter settings, probably “GPU instances” is the simpler one to use. Both should result in similar exports, but require differing setup in Blender.
Alternatively, if you can’t get instances working directly, post-processing with gltf-transform can add them for any identical meshes in the scene:
gltf-transform optimize in.glb out.glb --instance --instance-min 5
Hi, I’ve managed to export instancedMesh by using GeometryNode Editor
and fix install extension glTF-Blender-IO-EXT-mesh-gpu-instancing
via Patch 1 by jrjdavidson · Pull Request #16 · takahirox/glTF-Blender-IO-EXT-mesh-gpu-instancing · GitHub
And i just saw my blender version is 3.6.1 so there is no “Scene Graph” option in exporter. I will upgrade and figure it out.
Thank you so much
2 Likes
I think with newer Blender (I tested v4.2, but maybe older versions too…) there’s no need for an additional extension, the built-in one can handle instances. Good luck!
1 Like