Skip to main content

Instancing

When you want to render the same model multiple times, you can use the instanceCount prop to create multiple instances. This is more efficient than separate <Model> components, as it will load the model only once to memory.

To access the different instances, you can use the <ModelInstance> component that works just like the <Model> component.

{/* We transform the root model to a unit cube, meaning all instances will be scaled to unit cubes */}
<Model source={DroneGlb} instanceCount={2} transformToUnitCube>
<ModelInstance index={1} translate={[x, y, z]} />
<ModelInstance index={2} translate={[x, y, z]} />
</Model>

The index prop is used to select the instance you want to modify.