import { type SplatData, type SplatPackedShData } from '../../core/splat-data'; import { type SplatProgressCallback } from '../../loaders/loading'; import { parsePlyHeader, type PlyElement } from '../../loaders/ply-header'; /** * Parses a binary Gaussian splat PLY file into flat, GPU-friendly arrays - * either the uncompressed 3DGS flavor or the compressed SuperSplat one, which * is detected from the header. * * For the uncompressed flavor the spherical harmonics DC term is baked into an * 8-bit RGB color; optional `f_rest_*` higher-order coefficients are packed * into per-splat `shPacked`. Opacity is passed through a sigmoid, and per-splat * (log-space) + rotation (quaternion) are folded into a 3D covariance matrix - * all per the 3DGS paper's parameterization. * * @throws {Error} if the file is not a binary little-endian splat PLY. * * A direct parser call sits outside the `SplatLoadError`-or-`AbortError` * contract of the worker-mediated loaders ({@link loadSplatData}, * {@link loadSplatDataFile}, `ChunkLoader`, `StreamedSplatMesh`): malformed input * surfaces here as a plain `Error`. */ export declare function parseSplatPly(buffer: ArrayBuffer, options?: { maxSplats?: number; }): SplatData; /** * Bytes read per slice while streaming. Large enough that a multi-gigabyte * file costs tens of reads rather than thousands, small enough to stay far * below the 2 GiB an ArrayBuffer can hold. */ export declare const STREAM_WINDOW_BYTES: number; /** * Parses a local splat PLY without ever holding the whole file. * * A browser cannot allocate an ArrayBuffer over 2 GiB, so `file.arrayBuffer()` * fails outright on a raw 3DGS export of a few million splats (a full-SH * `point_cloud.ply` runs ~248 bytes per splat). The uncompressed flavor has * fixed-stride records, so it is read a window at a time. Higher-order * `f_rest_*` coefficients ride in the same stride and are decoded per window. * * The compressed flavor is read whole: it is ~10× smaller, and its chunked * layout would need a second pass to stream for no practical gain. * * @param options.windowBytes - Bytes read per slice; defaults to 64 MiB. Lower * trades read count for peak memory. * @param options.onProgress - Called after each window with the vertex bytes * decoded so far and the total. A multi-gigabyte decode takes tens of seconds, * which needs a determinate indicator rather than a spinner. * @throws {Error} if the file is not a binary little-endian splat PLY; * a `DOMException` named `AbortError` when cancelled. */ export declare function parseSplatPlyFile(file: File, options?: { signal?: AbortSignal; windowBytes?: number; onProgress?: SplatProgressCallback; /** * Keep at most this many splats, the most visible ones, thinned while * decoding so the dropped splats' arrays are never allocated. A function * is called once with the file's splat count. Costs one extra read pass * over the file when it thins. */ maxSplats?: number | ((count: number) => number | Promise); }): Promise; /** The vertex element of a splat PLY, with its required properties checked. */ export declare function requireSplatVertexElement(header: ReturnType): PlyElement; export interface RestLayout { bands: 1 | 2 | 3; coefficients: number; offsets: readonly number[]; } /** Resolves optional `f_rest_*` higher-order SH in a 3DGS vertex element. */ export declare function restLayout(vertices: PlyElement): RestLayout | null; export declare function finalizePlyDecode(count: number, out: SplatArrays, shPacked: SplatPackedShData | undefined, sourceCount?: number): SplatData; export interface SplatArrays { positions: Float32Array; colors: Uint8Array; covariances: Float32Array; } export declare function allocate(count: number): SplatArrays; /** Byte offsets of the properties the decoder reads, within one record. */ export interface VertexOffsets { x: number; y: number; z: number; r: number; g: number; b: number; alpha: number; s0: number; s1: number; s2: number; q0: number; q1: number; q2: number; q3: number; } export declare function vertexOffsets(vertices: PlyElement): VertexOffsets; /** * Decodes records `[from, to)` into `out`, reading from a view whose byte 0 * holds record `viewFirst`. Shared by the whole-buffer and streamed paths, so * both produce identical arrays. * * With `keep`, only marked records are written, packed from output index * `outFirst`; without it, record `i` lands at index `i`. * * @returns The next output index. */ export declare function decodeRecords(view: DataView, o: VertexOffsets, stride: number, viewFirst: number, from: number, to: number, out: SplatArrays, keep?: Uint8Array | null, outFirst?: number): number; /** Finds the largest absolute SH coefficient in a fixed-stride record range. */ export declare function measureRestExtent(view: DataView, stride: number, viewFirst: number, from: number, to: number, rest: RestLayout, initial: number): number; /** Allocates the final packed SH array after its scene-wide extent is known. */ export declare function allocatePackedRest(count: number, rest: RestLayout, extent: number): SplatPackedShData; /** * Packs channel-major `f_rest_*` directly into coefficient-major RGB words. * `keep` and `outFirst` select and place records as in {@link decodeRecords}. * * @returns The next output index. */ export declare function writePackedRest(view: DataView, stride: number, viewFirst: number, from: number, to: number, rest: RestLayout, extent: number, out: Uint32Array, keep?: Uint8Array | null, outFirst?: number): number;