Making 324 identical boxes with 324 separate new THREE.Mesh() calls means 324 draw calls, and draw calls are expensive on the CPU side more than the GPU. THREE.InstancedMesh(geometry, material, count) uploads the geometry and material to the GPU once, then draws every instance in one call using only an array of per-instance transform matrices (position, rotation, scale).
Set each instance’s transform with mesh.setMatrixAt(index, matrix), and flip mesh.instanceMatrix.needsUpdate = true whenever it changes so it gets re-uploaded to the GPU. To vary color per instance, use setColorAt(index, color) — it’s picked up automatically, no material flag needed.
The demo bobs an 18×18 grid of small cubes up and down, each on its own sine-wave phase. All 324 are drawn in a single draw call. If you have very many instances updating every frame (particles, say), even this CPU loop gets expensive — at that point, consider computing positions directly in the vertex shader instead (see gpu-particles).
When to use
Scenes with mass repetition of one shape — grass, trees, crowds, building windows.