ReadonlyvertexReadonlyindexReadonlyindexOptional ReadonlycolorOptional per-vertex color buffer (linear RGBA vec4 per vertex), bound at
vertex slot 1 by passes that compile the HAS_VERTEX_COLOR variant. Present
only when colors was supplied to Mesh.fromData.
Optional Readonlyuv1Optional second-UV-set buffer (glTF TEXCOORD_1, vec2 per vertex), bound at
vertex slot 2 by passes that compile the HAS_UV1 variant. Present only when
uv1 was supplied to Mesh.fromData.
Optional ReadonlyvertexInterleaved vertex floats kept when keepData was requested at creation.
Optional ReadonlyindexTriangle-list indices kept when keepData was requested at creation.
ReadonlyboundsLocal-space bounding-sphere center X (origin if the mesh had no vertices).
ReadonlyboundsLocal-space bounding-sphere center Y.
ReadonlyboundsLocal-space bounding-sphere center Z.
ReadonlyboundsLocal-space bounding-sphere radius. Used for frustum culling; transformed to world space per-instance by scaling with the model matrix.
ReadonlyboundsLocal-space tight AABB half-extents (from the vertex min/max). Falls back to boundsRadius when a caller supplies only a sphere. Used e.g. by the editor's selection box for a snug fit instead of the loose sphere-cube.
ReadonlyboundsReadonlyboundsTrue when this mesh carries a per-vertex colorBuffer.
True when this mesh carries a second UV set (uv1Buffer).
Destroys the underlying GPU vertex and index buffers (and color buffer, if any). No-op for a CPU-only mesh — its buffers are a shared placeholder it doesn't own.
StaticfromCreates a mesh from interleaved vertex data and 32-bit indices.
The WebGPU device.
Interleaved vertex data laid out per VERTEX_ATTRIBUTES (12 floats per vertex).
Triangle list indices.
Optionalopts: MeshDataRetentionOptional retention flags. Default: GPU upload only, CPU arrays are not held.
A new mesh owning the uploaded GPU buffers.
StaticfromCreates a CPU-only mesh: it retains the interleaved vertex + index arrays on the CPU
(as vertexData / indexData) but performs no GPU upload — its
vertexBuffer / indexBuffer reference a tiny shared placeholder and destroy
is a no-op.
For pipelines that decode geometry only to immediately re-bake it into a different
buffer — e.g. the 3D-tile world-baking in buildDrawables, which reads vertexData,
transforms every vertex to floating-origin world space, and uploads its own buffer —
this skips allocating (and then destroying) a full per-primitive GPU buffer, which
otherwise churns the WebGPU driver's resource allocator when many tiles stream/evict.
The result MUST NEVER be drawn (its buffers are the placeholder); only its retained
vertexData / indexData are valid. Bounds are still computed so consumers that read
them keep working.
StaticfromBuild a mesh from a flat position array (xyz triples) + triangle indices, computing smooth per-vertex normals. UVs are zeroed and tangents defaulted — enough for solid-shaded procedural geometry. Wraps fromData.
Optionalopts: MeshDataRetentionStaticribbonBuild a double-sided vertical "wall" ribbon along a polyline — the light-trail
/ fence shape: each point gets a bottom + top vertex (height apart in +Y),
consecutive points span a quad. Needs ≥2 points. Wraps fromPositions.
Optionalopts: MeshDataRetentionStaticaddAppends a single axis-aligned box to an accumulator array.
Each vertex uses 12 floats (position/normal/uv/tangent — matching VERTEX_ATTRIBUTES). The box face set is identical to the one produced by createBox but allows multiple boxes to be packed into one combined mesh.
Accumulated vertex floats (12 per vertex).
Accumulated triangle-list indices.
Box center X.
Box center Y.
Box center Z.
Half-extent along X.
Half-extent along Y.
Half-extent along Z.
StaticcreateStaticcreateStaticcreateCreates a UV sphere centered at the origin with outward normals.
Tangents follow the +phi (longitude) direction.
The WebGPU device.
Sphere radius (defaults to 0.5).
Latitude (theta) subdivisions.
Longitude (phi) subdivisions.
Optionalopts: MeshDataRetentionThe sphere mesh.
StaticcreateCreates the upper half of a sphere — a dome with its apex at (0, radius, 0)
and its open rim on the XZ plane (the equator, y = 0). Outward normals,
CCW winding (front-facing from outside the dome). The rim is left open (no
base cap).
Rotate π about X to turn it into a ceiling dome bulging downward.
The WebGPU device.
Sphere radius (defaults to 0.5).
Subdivisions from apex to rim (defaults to 16).
Subdivisions around the axis (defaults to 32).
Optionalopts: MeshDataRetentionThe hemisphere (dome) mesh.
StaticcreateCreates a cone with apex at (0, height, 0) and base circle on the XZ plane.
Rotate the returned mesh so local +Y aligns with the desired axis.
The WebGPU device.
Base circle radius (defaults to 0.5).
Apex height above the base (defaults to 1.0).
Number of base ring segments.
Optionalopts: MeshDataRetentionThe cone mesh.
StaticcreateCreates a torus centered at the origin with its major axis aligned to +Y.
The WebGPU device.
Distance from the torus center to the tube center.
Tube radius.
Ring subdivisions around the major axis.
Ring subdivisions around the tube cross-section.
Optionalopts: MeshDataRetentionThe torus mesh with outward normals and CCW winding.
StaticcreateCreates a flat plane on the XZ plane (normal +Y) centered at the origin.
The WebGPU device.
Size along X (defaults to 10).
Size along Z (defaults to 10).
Subdivisions along X.
Subdivisions along Z.
Optionalopts: MeshDataRetentionThe plane mesh.
Static (non-skinned) GPU mesh: an interleaved vertex buffer plus a 32-bit index buffer.
Vertex layout matches
VERTEX_STRIDE/VERTEX_ATTRIBUTES. The mesh owns both buffers; calldestroy()to release them.When created with
keepData: true, the originalvertexDataandindexDataarrays are also retained on the instance.