SDK JS
    Preparing search index...

    Adapts a standalone Niantic SPZ file (any version v1–v4) to the SDK's quantized streaming Decoder contract, so BVC-style splat layers can render a .spz capture through the same SplatRenderer path as any other splat container.

    Composes the float SpzDecoder (shared lazily-initialized wasm) with quantizeSpzCloud. SPZ has no cheap header: open decodes the whole file and caches the float cloud, which decodeTiles then quantizes into a single DecodedSplatTile (always tileCount: 1) and releases. Calling decodeTiles without a prior open re-decodes the bytes.

    import { SpzContainerDecoder } from '@bitruvius/turbo-spz';

    const decoder = new SpzContainerDecoder();
    const bytes = new Uint8Array(await (await fetch('scene.spz')).arrayBuffer());
    const model = await decoder.open(bytes);
    for await (const tile of decoder.decodeTiles(model, bytes)) {
    // upload the quantized tile to the GPU
    }
    decoder.dispose();

    Implements

    • Decoder
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    backend: DecodeBackend = 'cpu-wasm'

    The backend this instance reports — always 'cpu-wasm' (in-process wasm decode).

    Methods

    • Quantize the decoded cloud and yield it as the container's single tile.

      Parameters

      • model: DecodedModel

        The DecodedModel returned by open for these bytes.

      • bytes: Uint8Array

        The same .spz bytes passed to open (re-decoded only if the cached cloud is absent, e.g. decodeTiles without a prior open).

      • Optionalopts: DecodeOptions

        Optional DecodeOptions: signal to abort (checked before decode and before quantize), and onTile(tile, 0) invoked as the tile finishes.

      Returns AsyncIterable<DecodedTile>

      An async iterable yielding exactly one DecodedSplatTile.

      The provided signal's abort reason if aborted before the tile is produced; also rejects on wasm init failure or invalid SPZ bytes (see open).

    • Release the cached float cloud (the shared wasm singleton stays warm).

      Returns void

    • Decode the .spz file and report the quantized splat model shape.

      Parameters

      • bytes: Uint8Array

        The raw .spz file bytes (any SPZ version; gzip framing is handled).

      Returns Promise<DecodedModel>

      The DecodedModel: profile: 'splat', splat meta with fractionalBits: 12 and shDegree: min(3, cloud.shDegree), and tileCount: 1.

      NOT the cheap header parse of the general contract — SPZ has no header, so the whole file is decoded here and the float cloud cached for decodeTiles (which releases it).

      If the wasm fails to initialize (see WasmHostInit), or if bytes are not a valid/recognized SPZ stream — the wasm decode rejects.