SDK JS
    Preparing search index...

    Class BvcWorkerDecoder

    The off-main-thread (cpu-wasm-workers) BVC decoder: the cheap container header parse runs on the main thread, then per-tile decode jobs fan out to a WorkerPool, keeping the heavy rANS work (and large splat scenes) off the render thread. Tiles stream via onTile as they finish and are yielded in index order.

    Drop-in for BvcDecoder (same Decoder contract); createBvcDecoder chooses between them by runtime capability. The container bytes and wasm bytes are broadcast to each worker once per file (an 'open' that primes the worker's file cache), so a multi-tile container is not re-cloned per tile.

    import { BvcWorkerDecoder } from '@bitruvius/bvc';

    const decoder = new BvcWorkerDecoder({ poolSize: 4 });
    const model = await decoder.open(bytes);
    for await (const tile of decoder.decodeTiles(model, bytes)) {
    // upload tile to GPU
    }
    decoder.dispose(); // tear down the worker pool when done

    Implements

    • Decoder
    Index

    Constructors

    Properties

    backend: "cpu-wasm-workers" = ...

    Always 'cpu-wasm-workers'.

    Methods

    • Decode the container's tiles on the worker pool, yielding them in index order.

      Parameters

      • model: DecodedModel

        The DecodedModel returned by open for these bytes.

      • bytes: Uint8Array

        The same .bvc container bytes passed to open.

      • Optionalopts: DecodeOptions

        Optional DecodeOptions: signal to abort (checked before awaiting each tile) and onTile(tile, index) invoked as each tile finishes.

      Returns AsyncIterable<DecodedTile>

      An async iterable of DecodedTile (quantized SoA typed arrays transferred back from the worker, zero-copy).

      The signal's abort reason if aborted; rejects on worker spawn failure (e.g. CSP blocks a blob: worker) or wasm init failure.

    • GPU-packed splat decode (not part of the core Decoder contract): per-tile results are SplatTileGpu — typed-array views over the ONE transferred splat_tile_gpu arena, byte-identical to the splats/packing.ts textures. Splat containers only.

      Parameters

      Returns AsyncIterable<SplatTileGpu>

    • Tear down the worker pool and release its workers. Safe to call repeatedly.

      Returns void

    • Parse the BVC container header on the main thread (no per-tile decode).

      Parameters

      • bytes: Uint8Array

        The full .bvc container bytes.

      Returns Promise<DecodedModel>

      The DecodedModel (profile, meta, tileCount); pass it with the same bytes to decodeTiles.

      Rejects if wasm load/init fails (e.g. missing WASM SIMD) or bytes are not a valid container.