/** * Packing and requantization for per-splat higher-order SH. * * Every streamed format that keeps view-dependent color stores it in one * layout: {@link SplatPackedShData}, a `DecodePacked_11_10_11` word per * coefficient (R: bits 0-10 /2047, G: 11-20 /1023, B: 21-31 /2047) dequantized * across a per-channel range. LCC `Quality` captures and `.rad` deliver it directly; a * streamed SOG (or `.lcc2`) palette is *converted* into it at decode * ({@link packPaletteSh}) so it survives the shared pool - see * `docs/formats/streamed-shn-notes.md` (M11). The pool decodes the whole scene through * one range uniform, so a chunk whose range differs is requantized into the * scene's range at append ({@link requantizeShWord}). * * Pure array math, no THREE - safe to import in the decode worker. */ import type { SplatPackedShData, SplatShData } from './splat-data'; /** A per-channel `[min, max]` dequantization range for packed SH. */ export type ShRange = SplatPackedShData['range']; /** * Grows an absolute extent, ignoring NaN/±Infinity. `Math.max(x, NaN)` is NaN, * so a single bad source value must not turn the scene-wide range into NaN. */ export declare function growFiniteExtent(extent: number, value: number): number; /** Coefficients per channel for a band count (0 → none, 3 → 3rd order). */ export declare function shCoefficientCount(bands: number): number; /** Symmetric three-channel range used by packed per-splat SH. */ export declare function symmetricShRange(extent: number): ShRange; /** * Packs one RGB coefficient against a scene-wide symmetric extent. * * Kept separate from {@link packShCoefficients} so fixed-stride parsers can * measure their extent in one pass and pack directly from source records in a * second pass, without retaining a full float coefficient array. */ export declare function packShCoefficient(r: number, g: number, b: number, extent: number): number; /** * Quantizes splat-major coefficient triples into packed 11/10/11 words: * `count * shCoefficientCount(bands)` words, each holding one coefficient's * (R, G, B). `knownExtent` pins the symmetric range to a scene-wide value * (values outside clamp); without it the extent is measured from * `coefficients` - only safe when they are the whole scene, since every chunk * must share one range. */ export declare function packShCoefficients(coefficients: Float32Array, count: number, bands: 1 | 2 | 3, knownExtent?: number): SplatPackedShData; /** * Converts a palette-compressed SH source ({@link SplatShData}, as SOG/`.lcc2` * store it) into the per-splat packed form, keeping the lowest `bands` bands. * Each splat's palette label indexes the codebook image; the coefficients are * read out into splat-major triples and quantized against this chunk's own * measured extent. Later chunks may measure a different extent - the pool * requantizes any mismatch into the scene's range at append. * `targetRange`, when already locked by the pool, moves that exact second * quantization into the shared palette before expanding its labels. */ export declare function packPaletteSh(sh: SplatShData, count: number, bands: 1 | 2 | 3, targetRange?: ShRange): SplatPackedShData; /** The packed word that decodes to 0.0 in every channel under `range`. */ export declare function neutralShWord(range: ShRange): number; /** Whether two packed-SH ranges are bit-identical (no requantization needed). */ export declare function packedRangesEqual(a: ShRange, b: ShRange): boolean; /** * Re-encodes one packed word so it decodes to the same three channel values * under `to` as it did under `from`. Values outside `to` clip to its endpoints; * a zero-width `to` channel collapses to code 0. This is what lets chunks * quantized against different ranges share one pool range. */ export declare function requantizeShWord(word: number, from: ShRange, to: ShRange): number; /** Shifted channel codes for an exact packed-SH range conversion. */ export type ShRequantizationLookup = readonly [Uint32Array, Uint32Array, Uint32Array]; /** * Precomputes every 11/10/11 channel code for a fixed pair of chunk/pool ranges. * LCC2 stages many row batches from the same chunk; lookup avoids repeating * range arithmetic and allocating channel arrays for every coefficient. */ export declare function createShRequantizationLookup(from: ShRange, to: ShRange): ShRequantizationLookup;