Overview
Both InstancedMesh and BatchedMesh reduce thousands of objects to a single draw call, but they make different trade-offs. This benchmark renders the same animated scene twice, InstancedMesh on the left and BatchedMesh on the right, with live readouts of frame rate, CPU update time and draw calls, so you can compare them at high instance counts on your own hardware.
How it works
The canvas is split with the renderer's scissor and viewport: each frame draws the left scene into the left half and the right scene into the right half. Both sides animate identical motion, so any difference in cost comes from the technique.
- InstancedMesh stores one matrix per instance in an
InstancedBufferAttribute. Updating motion means writing every matrix withsetMatrixAtand flagginginstanceMatrix.needsUpdate, which re-uploads the whole buffer. Every instance must use the same geometry. - BatchedMesh stores matrices in a data texture and supports a different geometry per instance via multi-draw.
setMatrixAtmarks the texture dirty automatically. It adds a little bookkeeping per instance but gives far more flexibility.
Each overlay reports frames per second, the milliseconds spent updating matrices on the CPU, and the draw calls reported by renderer.info.
Exploring the demo
Raise the instance count towards its maximum and watch the update timings on each side. Both stay at one or two draw calls regardless of count, which is the whole point of these APIs. The update cost grows with the number of instances you modify per frame, so animating everything is the worst case; if most instances were static, both would be much cheaper.
How to choose
If all copies share one geometry, InstancedMesh is the simplest and usually fastest option. If you have many different meshes with a shared material, BatchedMesh avoids splitting them into one instanced mesh per geometry. If the animation can be expressed in a shader, moving it to the GPU removes the CPU update entirely, as shown in instancing performance. See also BatchedMesh opacity and wireframe and frustum culling.