InstancedMesh
new InstancedMesh(geometry?, material?, count?)THREE equivalent: THREE.InstancedMesh
Renders multiple instances of the same geometry/material pair with per-instance transforms and optional per-instance colors. Each instance becomes a separate draw call, so use for entities/particles (100s of shared models), not per-face terrain (use merged Geometry instead).
Properties
Section titled “Properties”| Name | Type | Description |
|---|---|---|
count |
number |
Number of instances to render. |
instanceMatrix |
Float32Array |
Flat buffer of 16 floats per instance (column-major matrices). Read-only. |
instanceColor |
Float32Array|undefined |
Flat buffer of 3 floats per instance (RGB). Set via setColorAt. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getMatrixAt(index: number, matrix: Matrix4): void |
Reads the transform matrix for instance at index into the target matrix. |
setMatrixAt(index: number, matrix: Matrix4): void |
Writes a transform matrix for instance at index. |
getColorAt(index: number, color: Color): void |
Reads the color for instance at index into the target color. |
setColorAt(index: number, color: Color): void |
Writes a color for instance at index. Allocates instanceColor on first call. |
dispose(): void |
Releases instance buffers. |