Taos API Reference
    Preparing search index...

    Class GltfLoader

    Loader for binary glTF 2.0 (.glb) assets.

    Parses the GLB container, decodes accessors/buffer views, computes missing tangents, builds skinned meshes, materials, skeletons, and animation clips, and uploads textures to the GPU.

    Index

    Constructors

    Methods

    • Fetches and parses a GLB file at url into GPU-ready resources.

      Creates GPU vertex/index buffers and textures owned by the returned model; the caller must invoke model.destroy() to release them.

      Parameters

      • device: GPUDevice

        WebGPU device used to create buffers and textures.

      • url: string

        URL of a binary glTF 2.0 (.glb) file.

      • Optionalopts: { keepData?: boolean; smoothNormals?: boolean }
        • OptionalkeepData?: boolean

          Retain decoded CPU geometry on each GltfMeshData.cpu (default false).

        • OptionalsmoothNormals?: boolean

      Returns Promise<GltfModel>

      Parsed meshes, optional skeleton, and animation clips.

      If the file is not a valid GLB 2.0 container or the JSON chunk is missing.

    • Parses an already-fetched GLB buffer into GPU-ready resources — the same work as GltfLoader.load without the fetch. Use this when the bytes arrive by another channel (e.g. an Electron IPC read) or when a Content Security Policy forbids fetching blob: URLs.

      Parameters

      • device: GPUDevice

        WebGPU device used to create buffers and textures.

      • arrayBuf: ArrayBuffer

        Raw bytes of a binary glTF 2.0 (.glb) container.

      • Optionalopts: { keepData?: boolean; smoothNormals?: boolean }
        • OptionalkeepData?: boolean

          Retain decoded CPU geometry on each GltfMeshData.cpu (default false).

        • OptionalsmoothNormals?: boolean

          For primitives lacking NORMAL, generate area-weighted smooth normals instead of the spec-default flat (per-face) normals (default false).

      Returns Promise<GltfModel>

      If the buffer is not a valid GLB 2.0 container or the JSON chunk is missing.

    • Loads a GLB as a flat list of static (non-skinned) Mesh primitives.

      Skips skin/animation parsing entirely; joints/weights on the source vertices are ignored, so vertices are read in their authored (bind-pose) frame. Pair with a MeshRenderer for plain rendering, or pass keepData: true so the returned meshes can feed SdfVolume.fromMesh (which needs CPU-side vertex and index data).

      Each primitive becomes one entry in meshes; the loader owns the GPU buffers and textures it allocates — call model.destroy() to release them.

      Parameters

      • device: GPUDevice

        WebGPU device used to create buffers and textures.

      • url: string

        URL of a binary glTF 2.0 (.glb) file.

      • Optionalopts: { keepData?: boolean; storageBuffers?: boolean; smoothNormals?: boolean }
        • OptionalkeepData?: boolean

          Retain CPU vertex/index arrays on each Mesh (needed for SDF baking). Default false.

        • OptionalstorageBuffers?: boolean
        • OptionalsmoothNormals?: boolean

      Returns Promise<GltfStaticModel>

      If the file is not a valid GLB 2.0 container or the JSON chunk is missing.

    • Like GltfLoader.loadStatic but parses pre-fetched GLB bytes instead of fetching a URL — for environments whose CSP forbids fetch() of the model (e.g. the editor, which reads asset bytes over IPC).

      Parameters

      • device: GPUDevice
      • arrayBuf: ArrayBuffer
      • Optionalopts: {
            keepData?: boolean;
            storageBuffers?: boolean;
            packedGeometry?: StaticPrimitiveGeometry[];
            smoothNormals?: boolean;
            recenter?: boolean;
            featureIds?: boolean;
        }

      Returns Promise<GltfStaticModel>

    • Device-free decode of every static primitive in a GLB into packed StaticPrimitiveGeometry (48-byte vertex layout + indices), in glb mesh→primitive flat order. Does GLB parsing, Draco/meshopt/quantization decompression, the tangent solve (skipped when the material has no normal map), and the vertex pack — but touches no GPUDevice, so it can run in a Worker. The result feeds GltfLoader.loadStaticFromArrayBuffer via opts.packedGeometry.

      Parameters

      • arrayBuf: ArrayBuffer
      • Optionalopts: { smoothNormals?: boolean; recenter?: boolean; featureIds?: boolean }

      Returns Promise<StaticPrimitiveGeometry[]>

      If the file is not a valid GLB 2.0 container.