GeometryBuilder class Geometry
Assembles a MeshGeometry one vertex and triangle at a time.
The attribute setters (normal, texCoord, texCoord1, color, and tangent) are sticky. Each value applies to every addVertex call that follows until it is changed. addVertex returns the index of the added vertex. When deduplicate is set, a vertex equal to one already added is merged and the existing index is returned instead.
final geometry = (GeometryBuilder()
..color(Vector4(1, 0, 0, 1))
..addVertex(Vector3(0, 0, 0))
..addVertex(Vector3(1, 0, 0))
..addVertex(Vector3(0, 1, 0))
..addTriangle(0, 1, 2))
.build();
Constructors
- GeometryBuilder({bool deduplicate = true})
- Creates an empty builder.
Properties
- deduplicate → bool
-
Whether addVertex merges a vertex equal to one already added.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- triangleCount → int
-
The number of triangles added so far.
no setter
- vertexCount → int
-
The number of vertices added so far.
no setter
Methods
-
addTriangle(
int a, int b, int c) → GeometryBuilder - Adds a triangle referencing three previously added vertex indices.
-
addVertex(
Vector3 position) → int -
Adds a vertex at
positioncarrying the current sticky attributes and returns its index. -
build(
{GeometryStorage storage = GeometryStorage.fixed, GeometryBufferArena? bufferArena, bool retainCpuData = true}) → MeshGeometry - Builds and GPU-uploads the accumulated mesh.
-
color(
Vector4 value) → GeometryBuilder - Sets the color applied to vertices added after this call.
-
normal(
Vector3 value) → GeometryBuilder - Sets the normal applied to vertices added after this call.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
packVertices(
) → Uint8List - Packs the accumulated vertices into the interleaved layout.
-
tangent(
Vector4 value) → GeometryBuilder - Sets the tangent applied to vertices added after this call.
-
texCoord(
Vector2 value) → GeometryBuilder - Sets the texture coordinate applied to vertices added after this call.
-
texCoord1(
Vector2 value) → GeometryBuilder - Sets the secondary texture coordinate for subsequent vertices.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited