Can I emulate a BatchedMesh with InstancedMeshes that share a Material?

Is there anything special that a BatchedMesh does performance-wise that I couldn’t just do with several InstancedMeshes that share a Material?

For example, let’s say I create a BatchedMesh and add 3 different geometries to it: a cube, a sphere, and a pyramid. I then create 10 instances of each geometry, so the total number of instances in the BatchedMesh is 30.

Now let’s say I create 3 different InstancedMeshes: one for the cube, one for the sphere, and one for the pyramid. I then add 10 instances to each InstancedMesh for a total of 30 instances across 3 InstancedMeshes.

What are the differences between the two scenarios? Is one more performant than the other?

not sure they are difference
but with BatchedMesh you can control different object in same way.
like a forest you have different tree but all should start from ground.

BatchedMesh uses special WebGL extension called multi_draw. If it is not available, BatchedMesh would fall back to loops. So, I’d expect that there should be difference in performance if your hardware supports multidrawing.

However, there is another difference – convenience. BatchedMesh provides unified id and access to meshes. If you simulate with a set of instanced meshes for different geometries, if you need to work with specific mesh, you have to manually track in which instanced mesh it is and what is its id there.

I think there are other differences, e.g. frustum culling, which for instanced mesh is a kind of all-or-nothing, while in batched mesh is individual.

But if your main question is only about performance, would you make a test and post here the results of the test?

Sharing one material does not merge those three meshes into one draw, because each instanced mesh still has its own geometry, so you still pay one draw per geometry. A batched mesh can submit all of those geometries in a single multi-draw when the device supports it, and it falls back to a loop when it does not. The other practical gap is culling: an instanced mesh is kept or dropped as a whole, while a batched mesh can drop individual instances that sit outside the frustum. With only three shapes and many copies of each, separate instanced meshes are usually enough; batching pays off when you have lots of different shapes and only a few copies of each.