MeshGeometry class
A triangle mesh built at runtime from vertex attribute arrays.
MeshGeometry is the general-purpose Geometry for procedurally
generated content. Build one directly from attribute arrays with
MeshGeometry.fromArrays, or assemble it incrementally with a
GeometryBuilder.
Callers supply attributes as independent typed arrays (positions, normals, texture coordinates, colors) and never pack vertex bytes by hand; the arrays are interleaved into the engine vertex layout internally.
Pass GeometryStorage.updatable as the storage mode to create a geometry that can be mutated in place. updatePositions, updateNormals, updateTexCoords, and updateColors replace one attribute when the vertex count is unchanged; rebuild replaces everything and reallocates only when the data outgrows the spare capacity.
- Inheritance
-
- Object
- Geometry
- UnskinnedGeometry
- MeshGeometry
- Implementers
Constructors
-
MeshGeometry.fromArrays({required Float32List positions, Float32List? normals, Float32List? texCoords, Float32List? colors, List<
int> ? indices, PrimitiveType primitiveType = gpu.PrimitiveType.triangle, GeometryStorage storage = GeometryStorage.fixed}) - Builds a mesh from structure-of-arrays vertex attributes.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isUpdatable → bool
-
Whether this geometry can be updated in place.
no setter
- localBoundingSphere → Sphere?
-
Local-space bounding sphere paired with localBounds. Same
nullability semantics.
no setterinherited
- localBounds → Aabb3?
-
Local-space axis-aligned bounding box of this geometry's vertex
positions, or
nullif bounds are unknown. Computed by uploadVertexData for procedural geometry, populated from the.modelflatbuffer for imported geometry, and (for the advanced setVertices path where the caller manages its own GPU buffer) leftnullunless the caller assigns it via setLocalBounds.no setterinherited - localBoundsVersion → int
-
A counter that increments each time setLocalBounds changes the
bounds.
no setterinherited
- primitiveType ↔ PrimitiveType
-
How the vertex/index data is assembled into primitives when drawn.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storage → GeometryStorage
-
How this geometry's GPU buffers are managed; see GeometryStorage.
final
- vertexCount → int
-
The number of vertices currently drawn.
no setter
- vertexShader → Shader
-
The vertex shader used when rendering this geometry.
no setterinherited
Methods
-
bind(
RenderPass pass, HostBuffer transientsBuffer, Matrix4 modelTransform, Matrix4 cameraTransform, Vector3 cameraPosition) → void -
Binds vertex/index buffers and per-frame uniforms onto
passin preparation for a draw call.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rebuild(
{required Float32List positions, Float32List? normals, Float32List? texCoords, Float32List? colors, List< int> ? indices}) → void - Replaces all of this geometry's data, allowing the vertex and index counts to change.
-
setIndices(
BufferView indices, IndexType indexType) → void -
Binds an already-uploaded index buffer view, with element width
determined by
indexType.inherited -
setJointsTexture(
Texture? texture, int width) → void -
Hook for skinned geometries to receive the joints texture computed
by Skin.getJointsTexture.
inherited
-
setLocalBounds(
Aabb3? aabb, Sphere? sphere) → void -
Override the bounds. Useful for callers driving setVertices from
a caller-managed
gpu.DeviceBufferwho want to participate in bounds-driven scene queries (e.g. frustum culling).inherited -
setVertexShader(
Shader shader) → void -
Assigns the vertex
shaderused when this geometry is drawn.inherited -
setVertices(
BufferView vertices, int vertexCount) → void -
Binds an already-uploaded vertex buffer view as this geometry's
vertex source.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateColors(
Float32List colors) → void - Replaces every vertex color, keeping the vertex count unchanged.
-
updateNormals(
Float32List normals) → void - Replaces every vertex normal, keeping the vertex count unchanged.
-
updatePositions(
Float32List positions) → void - Replaces every vertex position, keeping the vertex count unchanged.
-
updateTexCoords(
Float32List texCoords) → void - Replaces every texture coordinate, keeping the vertex count unchanged.
-
uploadVertexData(
ByteData vertices, int vertexCount, ByteData? indices, {IndexType indexType = gpu.IndexType.int16}) → void -
Allocates a
gpu.DeviceBufferand uploadsvertices(and optionalindices) into it in one step.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- kInterleavedVertexBytes → const int
- Bytes per vertex in the interleaved unskinned layout.