How to use Instances

Instances are an excellent way to use hardware accelerated rendering to draw a huge number of identical meshes (let's imagine a forest or an army).

Instances are built from a mesh with the following code:

var mesh = newMeshes[0];
for (var index = 0; index < 100; index++) {
    var newInstance = mesh.createInstance("i" + index);

A mesh can have as many instances as you want.

Each instance has the same material as the root mesh. They can only vary on the following properties:

  • position
  • rotation
  • rotationQuaternion
  • setPivotMatrix
  • scaling


Instances are supported for collisions, picking, rendering and shadows. Even if the current hardware does not support hardware accelerated instances, babylon.js will be able to optimize rendering to take instances into account.

Using Blender to create instances

Using Blender, you can create instances of a mesh by just creating a linked object:

Using 3DS Max to create instances

Using 3DS Max, you can create instances of a mesh by just creating a clone instance object with clic right on the object:


You can use instances with LOD but one limitation will apply in this case: You will have to hide the root objects. Here is an example where LODs reuse instances: https://www.babylonjs-playground.com/#0720FC#10 -