Constructor
new InstancedMesh( geometry : BufferGeometry, material : Material | Array.<Material>, count : number )
Constructs a new instanced mesh.
| geometry |
The mesh geometry. |
| material |
The mesh material. |
| count |
The number of instances. |
Properties
.boundingBox : Box3
The bounding box of the instanced mesh. Can be computed via InstancedMesh#computeBoundingBox.
Default is null.
.boundingSphere : Sphere
The bounding sphere of the instanced mesh. Can be computed via InstancedMesh#computeBoundingSphere.
Default is null.
.instanceColor : InstancedBufferAttribute
Represents the color of all instances. You have to set its BufferAttribute#needsUpdate flag to true if you modify instanced data via InstancedMesh#setColorAt.
Default is null.
.instanceMatrix : InstancedBufferAttribute
Represents the local transformation of all instances. You have to set its BufferAttribute#needsUpdate flag to true if you modify instanced data via InstancedMesh#setMatrixAt.
.isInstancedMesh : boolean (readonly)
This flag can be used for type testing.
Default is true.
.morphTexture : DataTexture
Represents the morph target weights of all instances. You have to set its Texture#needsUpdate flag to true if you modify instanced data via InstancedMesh#setMorphAt.
Default is null.
.previousInstanceMatrix : InstancedBufferAttribute
Represents the local transformation of all instances of the previous frame. Required for computing velocity. Maintained in InstanceNode.
Default is null.
Methods
.computeBoundingBox()
Computes the bounding box of the instanced mesh, and updates InstancedMesh#boundingBox. The bounding box is not automatically computed by the engine; this method must be called by your app. You may need to recompute the bounding box if an instance is transformed via InstancedMesh#setMatrixAt.
.computeBoundingSphere()
Computes the bounding sphere of the instanced mesh, and updates InstancedMesh#boundingSphere The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling. You may need to recompute the bounding sphere if an instance is transformed via InstancedMesh#setMatrixAt.
.dispose()
Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.getColorAt( index : number, color : Color ) : Color
Gets the color of the defined instance.
| index |
The instance index. |
| color |
The target object that is used to store the method's result. |
- Returns: A reference to the target color.
.getMatrixAt( index : number, matrix : Matrix4 ) : Matrix4
Gets the local transformation matrix of the defined instance.
| index |
The instance index. |
| matrix |
The target object that is used to store the method's result. |
- Returns: A reference to the target matrix.
.getMorphAt( index : number, object : Mesh )
Gets the morph target weights of the defined instance.
| index |
The instance index. |
| object |
The target object that is used to store the method's result. |
.setColorAt( index : number, color : Color ) : InstancedMesh
Sets the given color to the defined instance. Make sure you set the needsUpdate flag of
InstancedMesh#instanceColor to true after updating all the colors.
| index |
The instance index. |
| color |
The instance color. |
- Returns: A reference to this instanced mesh.
.setMatrixAt( index : number, matrix : Matrix4 ) : InstancedMesh
Sets the given local transformation matrix to the defined instance. Make sure you set the needsUpdate flag of
InstancedMesh#instanceMatrix to true after updating all the matrices.
| index |
The instance index. |
| matrix |
The local transformation. |
- Returns: A reference to this instanced mesh.
.setMorphAt( index : number, object : Mesh ) : InstancedMesh
Sets the morph target weights to the defined instance. Make sure you set the needsUpdate flag of
InstancedMesh#morphTexture to true after updating all the influences.
| index |
The instance index. |
| object |
A mesh which |
- Returns: A reference to this instanced mesh.