Homesplat-transform API Reference - v2.6.0
    Preparing search index...

    Class WorkerQueue

    A small cross-platform (Node + browser) worker pool running the CPU-heavy tasks defined in tasks.ts off the main thread. The worker entry is built and shipped as dist/worker.mjs; the pool spawns it from a URL resolved relative to the library bundle. Node and bundlers that rewrite new Worker(new URL('./worker.mjs', import.meta.url)) (e.g. Vite, webpack) pick it up automatically; with other bundlers, set WorkerQueue.workerUrl to the deployed worker asset (mirroring WebPCodec.wasmUrl).

    Workers spawn lazily on demand and run one task at a time. When workers are unavailable (running from source via tsx, maxWorkers = 0, or spawn fails) every task runs inline on the calling thread instead - same code, same results, just serial.

    Index

    Accessors

    Methods

    Accessors

    • get maxWorkers(): number

      Maximum number of worker threads. Defaults to one less than the available hardware concurrency, capped at 4. (Peak memory scales with worker count, since each holds its own WebP WASM heap; 4 captures most of the parallelism for SOG writes.)

      Returns number

      The configured limit, or null when auto-sized.

    • set maxWorkers(value: number): void

      Sets the maximum number of worker threads. Set to 0 to force inline execution on the calling thread, or null to auto-size. Configure once before the first run() (as the CLI does); changing it while tasks are in flight is not supported.

      Parameters

      • value: number

        Maximum worker threads, or null to auto-size.

      Returns void

    • get workerUrl(): string

      URL of the worker script, or null when auto-resolved relative to the bundle.

      Returns string

      The configured worker URL, or null.

    • set workerUrl(value: string): void

      Sets the URL of the worker script (the shipped dist/worker.mjs). Set this before first use in browser environments whose bundler does not rewrite new Worker(new URL('./worker.mjs', import.meta.url)) - e.g.

      import workerUrl from '@playcanvas/splat-transform/worker?url'; WorkerQueue.workerUrl = workerUrl;

      Parameters

      • value: string

        Absolute URL of the worker script, or null to auto-resolve.

      Returns void

    Methods

    • Waits for in-flight tasks to settle, then terminates all workers. Optional: idle workers don't keep the Node process alive, and workers respawn lazily on the next run() call.

      Returns Promise<void>

      A promise that resolves once all workers are terminated.