import type { SplatData } from '../core/splat-data'; import type { RadChunkRangeRequest, SogShPackingOptions } from './load-worker-protocol'; import type { LccChunkParams } from '../formats/lcc/parse-lcc'; import { type SplatDataFileLoadOptions, type SplatFormat, type SplatInputOptions } from './loading'; /** * Client for the persistent scene/chunk loading workers. Multiple requests * may be in flight; each can be cancelled through an `AbortSignal`, which * aborts the worker-side fetches (useful when the camera has moved on * before a chunk arrived). * * There are two workers behind this one class. The streaming worker is * constructed eagerly and handles everything the LOD paths need; the one-shot * worker ({@link ONE_SHOT_FORMATS}) is constructed the first time a `.spz`, * `.splat` or `.ksplat` is requested. Both decode off the main thread - the * split exists only to keep the one-shot parsers out of the published entry. * * @example * const loader = new ChunkLoader(); * const chunk = await loader.load('/scene/0_0/', { kind: 'directory' }); */ export declare class ChunkLoader { private readonly streaming; /** The in-flight construction; `null` until a one-shot format is requested. */ private oneShot; /** The constructed one-shot client, so `dispose` does not have to await. */ private oneShotClient; private readonly waitingForWorker; private disposed; constructor(); /** * Fetches and decodes one scene file or chunk directory. * * @param url - Scene URL, absolute or relative to the page. * @param options.kind - 'file' (default) selects a parser by extension; * 'directory' decodes an unbundled SOG chunk directory. * @param options.format - Explicit parser; `lcc-bin` additionally needs * `options.lcc` to say which byte range of the file to fetch. * @param options.signal - Abort signal for cancellation; the returned * promise then rejects with a `DOMException` named `AbortError`. * @param options.lcc - Byte-range plumbing for `lcc-bin`. This path exists * for {@link StreamedSplatMesh} and is **not** part of the stable surface; * the type is nameable as `LccChunkParams` on `@voluma/vlam/formats/lcc`. * @param options.rad - Byte-range plumbing for `rad-chunk`, on the same * footing; the type is `RadChunkRangeRequest` on `@voluma/vlam/formats/rad`. * @throws Rejects only with {@link SplatLoadError} (resolve, fetch, decode or * worker failures - `error.phase` says which; a worker that cannot start at * all, e.g. under a CSP that blocks `blob:` workers, reports * `phase: 'worker'`) or an `Error` named `AbortError` (cancellation or * {@link dispose}). */ load(url: string, options?: SplatInputOptions & { kind?: 'file' | 'directory'; format?: SplatFormat | 'lcc-bin' | 'rad-chunk'; lcc?: LccChunkParams; rad?: RadChunkRangeRequest; sog?: SogShPackingOptions; files?: Readonly>; }): Promise; /** * Decodes a local file (from a file input or a drop) in the worker - the * bytes are read worker-side, so a multi-million-splat decode still never * blocks the main thread. * * Only self-contained files are supported: `.ply`, `.spz`, `.splat`, * `.ksplat` and bundled `.sog`. An unbundled SOG directory needs sibling * fetches and so requires {@link load} with `kind: 'directory'`. * * @param file - The file; its name selects the parser unless `format` is given. * @throws Rejects only with {@link SplatLoadError} (unknown extension, read * or decode failures) or an `Error` named `AbortError` (cancellation or * {@link dispose}). */ loadFile(file: File, options?: SplatDataFileLoadOptions): Promise; /** * Runs one load, holding a share of `budget` from the moment the worker * knows the decoded count until the data is returned (committed) or the * load fails (released). */ private budgeted; /** Routes one load to the worker that owns its format. */ private request; /** * The worker for `format`, constructing the one-shot worker on first need. * * The in-flight promise is cached, not just the resolved client, so two * concurrent `.spz` loads share one worker instead of racing to build two. */ private clientFor; /** Terminates both workers and rejects all in-flight requests. */ dispose(): void; }