InstancedMesh class Scene graph

Many copies of one Geometry / Material pair, each placed by its own model transform.

Use an InstancedMesh for foliage, crowds, debris, or any scene that holds many copies of the same mesh. Attach it to a node with an InstancedMeshComponent; the whole set is then one render item, one pipeline, and one cull test rather than one node per copy.

Constructors

InstancedMesh({required Geometry geometry, required Material material, bool cullInstances = false, bool sortTransparentInstances = true})
Creates an instanced mesh that draws geometry shaded by material. It starts with no instances; add them with addInstance.

Properties

cullInstances → bool
Whether the renderer culls each instance after the aggregate bounds pass.
final
geometry → Geometry
The geometry drawn for every instance.
final
hashCode → int
The hash code for this object.
no setterinherited
instanceCount → int
The number of instances.
no setter
material → Material
The material every instance is shaded with.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sortTransparentInstances → bool
Whether translucent instances are sorted back to front before drawing.
final

Methods

addInstance(Matrix4 transform, {Vector4? color}) → int
Adds an instance placed by transform and returns its index.
clearInstances() → void
Removes every instance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeInstanceAt(int index) → void
Removes the instance at index. Instances after it shift down by one, so their indices change.
setInstanceColor(int index, Vector4 color) → void
Replaces the color multiplier of the instance at index.
setInstanceTransform(int index, Matrix4 transform) → void
Replaces the transform of the instance at index.
toString() → String
A string representation of this object.
inherited
updateInstanceTransforms(void update(List<Matrix4> transforms), {bool recomputeWinding = true}) → void
Updates every instance transform in place and invalidates the batch once.

Operators

operator ==(Object other) → bool
The equality operator.
inherited