Taos API Reference
    Preparing search index...

    Class 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; call destroy() to release them.

    When created with keepData: true, the original vertexData and indexData arrays are also retained on the instance.

    Index

    Properties

    vertexBuffer: GPUBuffer
    indexBuffer: GPUBuffer
    indexCount: number
    colorBuffer?: GPUBuffer

    Optional 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.

    uv1Buffer?: GPUBuffer

    Optional 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.

    vertexData?: Float32Array<ArrayBufferLike>

    Interleaved vertex floats kept when keepData was requested at creation.

    indexData?: Uint32Array<ArrayBufferLike>

    Triangle-list indices kept when keepData was requested at creation.

    boundsCenterX: number

    Local-space bounding-sphere center X (origin if the mesh had no vertices).

    boundsCenterY: number

    Local-space bounding-sphere center Y.

    boundsCenterZ: number

    Local-space bounding-sphere center Z.

    boundsRadius: number

    Local-space bounding-sphere radius. Used for frustum culling; transformed to world space per-instance by scaling with the model matrix.

    Accessors

    Methods

    • Destroys the underlying GPU vertex and index buffers (and color buffer, if any).

      Returns void

    • Creates a mesh from interleaved vertex data and 32-bit indices.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • vertices: Float32Array

        Interleaved vertex data laid out per VERTEX_ATTRIBUTES (12 floats per vertex).

      • indices: Uint32Array

        Triangle list indices.

      • Optionalopts: MeshDataRetention

        Optional retention flags. Default: GPU upload only, CPU arrays are not held.

      Returns Mesh

      A new mesh owning the uploaded GPU buffers.

    • Appends 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.

      Parameters

      • verts: number[]

        Accumulated vertex floats (12 per vertex).

      • indices: number[]

        Accumulated triangle-list indices.

      • cx: number

        Box center X.

      • cy: number

        Box center Y.

      • cz: number

        Box center Z.

      • sx: number

        Half-extent along X.

      • sy: number

        Half-extent along Y.

      • sz: number

        Half-extent along Z.

      Returns void

    • Creates an axis-aligned box centered at the origin with outward-facing normals.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • width: number

        Total width along X.

      • height: number

        Total height along Y.

      • depth: number

        Total depth along Z.

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The box mesh.

    • Creates an axis-aligned cube centered at the origin with outward-facing CCW winding.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • size: number = 1

        Edge length of the cube (defaults to 1).

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The cube mesh.

    • Creates a UV sphere centered at the origin with outward normals.

      Tangents follow the +phi (longitude) direction.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • radius: number = 0.5

        Sphere radius (defaults to 0.5).

      • latSegments: number = 32

        Latitude (theta) subdivisions.

      • lonSegments: number = 32

        Longitude (phi) subdivisions.

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The sphere mesh.

    • Creates 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.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • radius: number = 0.5

        Sphere radius (defaults to 0.5).

      • latSegments: number = 16

        Subdivisions from apex to rim (defaults to 16).

      • lonSegments: number = 32

        Subdivisions around the axis (defaults to 32).

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The hemisphere (dome) mesh.

    • Creates 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.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • radius: number = 0.5

        Base circle radius (defaults to 0.5).

      • height: number = 1.0

        Apex height above the base (defaults to 1.0).

      • segments: number = 16

        Number of base ring segments.

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The cone mesh.

    • Creates a torus centered at the origin with its major axis aligned to +Y.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • majorRadius: number = 0.5

        Distance from the torus center to the tube center.

      • minorRadius: number = 0.2

        Tube radius.

      • majorSegments: number = 32

        Ring subdivisions around the major axis.

      • minorSegments: number = 16

        Ring subdivisions around the tube cross-section.

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The torus mesh with outward normals and CCW winding.

    • Creates a flat plane on the XZ plane (normal +Y) centered at the origin.

      Parameters

      • device: GPUDevice

        The WebGPU device.

      • width: number = 10

        Size along X (defaults to 10).

      • depth: number = 10

        Size along Z (defaults to 10).

      • segX: number = 1

        Subdivisions along X.

      • segZ: number = 1

        Subdivisions along Z.

      • Optionalopts: MeshDataRetention

      Returns Mesh

      The plane mesh.