/** * Evaluates a decoded `.csgs` section at a frame time into {@link SplatData}. * * The section's integer knots are dequantized once ({@link prepareCsgsSection}); * each frame then evaluates every alive splat's hat curves at a fractional * frame time ({@link evaluateCsgsFrame}) - the CPU mirror of Faltwerk's GPU * curve evaluation, with gsplat's attribute conventions: `R` is a `wxyz` * quaternion (normalized after interpolation), `S` a log-scale, `O` an opacity * logit and `D` the DC SH color. */ import { type SplatData, type SplatPackedShData } from '../../core/splat-data'; import type { CsgsParams, CsgsSection } from './parse-csgs'; /** A section with dequantized knots, ready for per-frame evaluation. */ export interface CsgsPlaybackSection { readonly g0: number; readonly nframes: number; /** Splats carried by the section (alive at some frame of it). */ readonly count: number; /** First absolute frame at which each splat is drawn. */ readonly birthFrame: Uint32Array; /** First absolute frame at which each splat is no longer drawn. */ readonly deathFrame: Uint32Array; /** Knot count per splat, per group in {@link GROUP_TAGS} order. */ readonly k: readonly Uint8Array[]; /** Start of each splat's knots in the group's float array. */ readonly knotOff: readonly Uint32Array[]; /** Dequantized knots per group, knot-major per splat. */ readonly knots: readonly Float32Array[]; /** Static higher-order SH, packed per splat for a vlam pool. */ readonly shPacked: SplatPackedShData; } /** Reusable output buffers of {@link evaluateCsgsFrame}, grown on demand. */ export interface CsgsFrameBuffers { positions: Float32Array; colors: Uint8Array; covariances: Float32Array; shPacked: Uint32Array; } /** Largest absolute SH coefficient a section's quantization table can produce. */ export declare function csgsShExtent(params: CsgsParams): number; /** * Dequantizes a section for playback. * * @param shExtent Symmetric packed-SH range to quantize against. Pass one value * for every section of a stream so the pool never has to requantize; defaults * to this section's own extent. * @throws {Error} if the stream's group layout is not the renderer's `P3 R4 S3 O1 D3` + 45 SH. */ export declare function prepareCsgsSection(section: CsgsSection, params: CsgsParams, shExtent?: number): CsgsPlaybackSection; /** Allocates frame buffers for `count` splats. */ export declare function createCsgsFrameBuffers(count: number): CsgsFrameBuffers; /** * Samples one splat's curve of group `group` (0 = P … 4 = D) at absolute frame * time `t`, writing its `dims` values to `out`. The rotation curve is returned * as interpolated, not yet normalized. */ export declare function sampleCsgsCurve(section: CsgsPlaybackSection, group: number, splat: number, t: number, out: Float32Array): void; /** Options of {@link evaluateCsgsFrame}. */ export interface CsgsFrameOptions { /** * Write every splat of the section at its own index (`count` is then the * section's), the dead ones with zero opacity and zero covariance, instead * of only the alive splats packed together. Fixed slots let a host update * a frame in place and keep the static SH of the section where it is. */ readonly allSlots?: boolean; } /** * Evaluates the section at absolute frame time `t` (fractional frames * interpolate; liveness uses the whole frame). By default only the splats * alive at `t` are written, so the returned `count` varies per frame (see * {@link CsgsFrameOptions.allSlots}). Views into `buffers` are returned, so * consume the result before the next call reuses them. */ export declare function evaluateCsgsFrame(section: CsgsPlaybackSection, t: number, buffers?: CsgsFrameBuffers, options?: CsgsFrameOptions): SplatData;