import type { SplatSceneBudget } from './splat-scene-budget'; /** * The self-contained scene formats - files (or bundles) that decode to a whole * scene on their own, with no external manifest. This is the value set of * {@link SplatData.format} and the non-`auto` half of {@link SplatFormat}. */ export type SplatDataFormat = 'ply' | 'sog' | 'spz' | 'splat' | 'ksplat' | 'rad'; /** Explicit formats accepted by {@link loadSplatData}. */ export type SplatFormat = 'auto' | SplatDataFormat; /** Explicit formats accepted by {@link StreamedSplatMesh.load}. */ export type StreamedSplatFormat = 'auto' | 'streamed-sog' | 'lcc2' | 'lcc' | 'rad'; /** * Parsers the loading worker can run on a chunk. This extends {@link SplatFormat} * with formats that are only ever reached as a streamed chunk, never as a * standalone scene handed to {@link loadSplatData}: `lcc-bin` is a byte range of an * LCC (`.lcc`) `data.bin`, and `rad-chunk` a byte range of a single-file `.rad` - * both meaningless without their manifest/header. */ export type ChunkFileFormat = Exclude | 'lcc-bin' | 'rad-chunk'; /** Serializable fetch settings that can cross the loading-worker boundary. */ export interface SplatRequestOptions { headers?: Readonly>; credentials?: RequestCredentials; mode?: RequestMode; cache?: RequestCache; } /** * Reports load progress in bytes, for a determinate progress indicator. * * `total` is 0 when the size is not known ahead of time (a response with no * `Content-Length`), which means "still working" rather than "finished". */ export type SplatProgressCallback = (loaded: number, total: number) => void; /** * Rate-limits progress reports to ~10/s. * * A body arrives in ~64 KB chunks, so an unthrottled report would post * thousands of messages no indicator can render. The final report is exempt - * it is what leaves a determinate bar exactly full rather than at 97%. * * Identifying that final report needs a known size, so the exemption requires * `total > 0`. When the size is unknown there is no bar to fill (the caller * shows a spinner) and every report is throttled alike - without the `total` * check, `loaded < total` would be false for all of them and the throttle * would never engage at all. */ export declare function createProgressThrottle(report: SplatProgressCallback, intervalMs?: number): SplatProgressCallback; /** Work currently performed by one load; promise settlement reports completion. */ export type SplatLoadStatus = 'initializing' | 'reading' | 'reading-and-decoding' | 'decoding'; /** * Options for decoding a local file. * * Shared by {@link loadSplatDataFile} and `ChunkLoader.loadFile`. There is no * `baseUrl`/`request` counterpart to {@link SplatInputOptions} here: a file has * no URL to resolve and no request to configure. */ export interface SplatDataFileLoadOptions { signal?: AbortSignal; /** Parser selection; the file name's extension is used only for `auto`. */ format?: SplatFormat; /** * Called as the file is read, for a determinate progress bar. A multi- * gigabyte PLY takes tens of seconds, so the streamed PLY path reports as it * goes; the whole-buffer formats have nothing to report until they are done. */ onProgress?: SplatProgressCallback; /** Reports work stages, without implying decoded or rendered readiness percentages. */ onStatus?: (status: SplatLoadStatus) => void; /** * Scene budget shared with the other files of the scene. The file is thinned * to its share, keeping its most visible splats; see {@link SplatSceneBudget}. */ sceneBudget?: SplatSceneBudget; } /** Shared URL, cancellation, and request options for package loaders. */ export interface SplatInputOptions { signal?: AbortSignal; baseUrl?: string | URL; request?: SplatRequestOptions; /** * Called as bytes are read. Fires from the loading worker, so it is * throttled to whole read windows rather than every byte. */ onProgress?: SplatProgressCallback; /** Reports work stages, without implying decoded or rendered readiness percentages. */ onStatus?: (status: SplatLoadStatus) => void; /** * Scene budget shared with the other files of the scene. A whole-file scene * is thinned to its share, keeping its most visible splats; see * {@link SplatSceneBudget}. Ignored for streamed chunks. */ sceneBudget?: SplatSceneBudget; } /** The stage at which a splat load failed. */ export type SplatLoadPhase = 'resolve' | 'manifest' | 'fetch' | 'decode' | 'worker'; /** Serializable error details returned by the loading worker. */ export interface SerializedSplatLoadError { name: string; message: string; phase: SplatLoadPhase; url: string; status?: number; retryable: boolean; } /** Structured error thrown for non-cancellation loading failures. */ export declare class SplatLoadError extends Error { readonly phase: SplatLoadPhase; readonly url: string; readonly status?: number; readonly retryable: boolean; constructor(message: string, options: { phase: SplatLoadPhase; url: string; status?: number; retryable: boolean; cause?: unknown; }); } /** Resolves a loader input without assuming that a browser location exists. */ export declare function resolveSplatUrl(input: string | URL, baseUrl?: string | URL): URL; /** Returns the lower-case pathname extension, excluding query/hash text. */ export declare function splatUrlExtension(url: URL): string; /** Returns the lower-case extension of a plain file name or path. */ export declare function splatNameExtension(name: string): string; /** * Maps a file extension to its parser. `label` names the input in the * failure message - a URL for a fetched scene, a file name for a local one. * * @throws {SplatLoadError} (phase `'resolve'`, not retryable) for an unknown * extension, keeping the loader contract uniform: callers of the loading * pipeline only ever see `SplatLoadError` or `AbortError`. */ export declare function splatFormatForExtension(extension: string, label: string): SplatDataFormat; /** Creates a fetch init object without sharing mutable header state. */ export declare function toRequestInit(options?: SplatRequestOptions, signal?: AbortSignal): RequestInit; /** * The largest `ArrayBuffer` a browser will allocate: 2 GiB, in every current * engine. A file bigger than this cannot be read in one piece at all - the * read fails rather than the decode. */ export declare const MAX_ARRAY_BUFFER_BYTES: number; /** * Reads a whole local file, turning the browser's two unhelpful failure modes * into messages that name the real cause. * * Chrome reports an over-2 GiB read as `NotReadableError`, whose stock text * blames file permissions - so a perfectly good 4 GB capture reads as "your * file is broken". Check the size up front instead. * * Formats with a streaming parser (see `parseSplatPlyFile`) never come here. */ export declare function readWholeFile(file: File): Promise; /** Creates an AbortError even where DOMException is unavailable. */ export declare function createAbortError(message: string): Error; /** Whether an unknown failure represents cancellation. */ export declare function isAbortError(error: unknown): boolean; /** Maps an arbitrary failure to the package's structured loading error. */ export declare function toSplatLoadError(error: unknown, options: { phase: SplatLoadPhase; url: string; status?: number; }): SplatLoadError; /** Converts a structured load failure into worker-safe data. */ export declare function serializeSplatLoadError(error: SplatLoadError): SerializedSplatLoadError; /** Reconstructs a package error received from a loading worker. */ export declare function deserializeSplatLoadError(error: SerializedSplatLoadError): SplatLoadError; /** Monotonic time where available, with an SSR-safe fallback. */ export declare function monotonicNow(): number;