import { type RadShCodebook, type SplatData } from '../../core/splat-data'; /** * Parser for World Labs' Spark `.rad` format (a precomputed LOD splat * tree with per-column, gzip/deflate-compressed properties). Ported from the * MIT-licensed Rust reference (`sparkjsdev/spark`, `rust/spark-lib/src/rad.rs` * and `splat_encode.rs`) since this project's worker has no Rust/WASM * toolchain - Spark's own decoder runs as WASM and writes into Spark's own * GPU texture layout, not this package's `SplatData`. * * Two entry points: * - {@link parseRad} flattens a whole file into leaf splats only (the original * capture), for a small `.rad` loaded in one piece by `loadSplatData`. * - {@link parseRadChunkStreaming} decodes one chunk keeping *every* splat - * the merged coarse LOD-tree nodes included - plus the per-splat tree * columns, for the streamed reader (see `rad.ts`), which chooses the * rendered cut across chunks at runtime. * * SH columns are repacked into the renderer's per-splat packed representation. */ export declare const RAD_MAGIC = 809779538; export declare const RAD_CHUNK_MAGIC = 1128546642; /** One chunk's location within a `.rad` file (or its external `.radc` name). */ export interface RadChunkRange { readonly offset: number; readonly bytes: number; readonly filename?: string; } /** The file-level `RAD0` metadata (a subset - only the fields we consume). */ export interface RadMeta { readonly version: number; readonly type: string; /** Total splats in the LOD tree (merged nodes + leaves). */ readonly count: number; readonly maxSh?: number; readonly lodTree?: boolean; readonly chunkSize?: number; readonly chunks: readonly RadChunkRange[]; /** Spark's free-form build-info JSON; carries `input_splat_count` (the leaf * count) among other fields. Parsed best-effort by the reader. */ readonly comment?: string; } /** Per-splat LOD-tree links: an internal node's children are the contiguous * global-index range `[childStart, childStart + childCount)`. Leaves have * `childCount === 0`. */ export interface RadTree { readonly childCount: Uint16Array; readonly childStart: Uint32Array; } export interface RadChunkProperty { readonly offset: number; readonly bytes: number; readonly property: string; readonly encoding: string; readonly compression?: string; readonly min?: number; readonly max?: number; } /** * Decodes a `.rad` file, or a lone `.radc` chunk, into a flat `SplatData` * of leaf splats only (the original capture). Merged coarse LOD-tree nodes * are dropped - they exist for streamed reading, and are meaningless once * everything is already decoded into one buffer. * * @throws {Error} if the file is malformed, an unsupported version, carries * an external `.radc` chunk reference (one-shot loading needs every chunk in * the same buffer), or uses a property encoding this parser does not * recognize. */ export declare function parseRad(buffer: ArrayBuffer): Promise; /** * Parses just the `RAD0` header: the typed metadata and the byte offset where * the chunk stream begins. `buffer` need only be long enough to hold the * header - a ranged prefix of a large single-file `.rad` is enough. */ export declare function parseRadHeaderMeta(buffer: ArrayBuffer): { meta: RadMeta; chunksStart: number; }; /** * Decodes one chunk (a `RADC`-magic byte range) into a `SplatData` holding * **every** splat in the chunk - internal LOD-tree nodes and leaves alike - * plus the per-splat tree columns when the file carries a LOD tree. The * streamed reader keeps all splats resident and chooses the rendered cut * itself from {@link SplatData.radTree}. * * @throws {Error} on a malformed chunk or an unrecognized property encoding. */ export declare function parseRadChunkStreaming(buffer: ArrayBuffer, shCodebook?: RadShCodebook, shExtent?: number, reorder?: boolean): Promise;