/** * Indexed Meshopt Track v1 (UTSBM) — the numerical-track transport for VAV/OAV clips. * * One block-indexed asset per track: GOP blocks live contiguously at declared byte offsets * inside a single file, each holding meshopt vertex-codec-v1 streams in `vertex-major` * element order (element `e = value * blockFrames + frame`), so the codec's * consecutive-element delta is a per-value temporal delta. The file ships precompressed for * HTTP `Content-Encoding` (the network stack inflates off the JS thread); the runtime issues * exactly ONE request per track and consumes the response body progressively, so a block is * decodable as soon as its extent has arrived. Integrity is a SHA-256 over each block's raw * bytes as JavaScript receives them, recorded in the manifest together with exact byte * lengths and stream extents. * * The decoder keeps at most {@link UTSBM_RESIDENT_DECODED_BLOCK_LIMIT} decoded blocks resident * (a bracketing frame pair may straddle a GOP boundary) and serves canonical lane-major * frame bytes — the same canonical layout the previous IBT1 transport produced, so the * atlas/dequantization consumers are unchanged. * * Spec: `docs/formats/utsubo-motion-track-v1.md`. * * @module IndexedMeshoptTrack */ export declare const UTSBM_FORMAT = "utsbm"; export declare const UTSBM_STREAM_CODEC = "meshopt-vertex-v1"; /** Two resident blocks cover a bracketing frame pair that straddles a GOP boundary. */ export declare const UTSBM_RESIDENT_DECODED_BLOCK_LIMIT = 2; /** Hard limits shared with the encoder — a reader fails before allocation, never after. */ export declare const UTSBM_MAX_LANES = 64; export declare const UTSBM_MAX_BLOCKS = 262144; export declare const UTSBM_MAX_GOP = 4096; export declare const UTSBM_MAX_VALUES_PER_FRAME = 16777216; /** The subset of `MeshoptDecoder` the runtime needs — injected, never imported. */ export interface MeshoptVertexDecoderLike { ready?: Promise; supported?: boolean; decodeVertexBuffer(target: Uint8Array, count: number, size: number, source: Uint8Array): void; } /** The subset of `MeshoptEncoder` the exporter needs — injected, never imported. */ export interface MeshoptVertexEncoderLike { ready?: Promise; encodeVertexBufferLevel(source: Uint8Array, count: number, size: number, level: number, version?: number): Uint8Array; } export type IndexedMeshoptLaneStorage = 'u8' | 'u16'; export interface IndexedMeshoptLane { name: string; storage: IndexedMeshoptLaneStorage; bitDepth: number; stream: string; byteOffset: number; } export interface IndexedMeshoptStream { name: string; codec: typeof UTSBM_STREAM_CODEC; elementStride: number; } export interface IndexedMeshoptBlockStream { name: string; byteOffset: number; byteLength: number; } export interface IndexedMeshoptBlock { firstFrame: number; frameCount: number; /** Start of this block inside the track file; blocks are contiguous from 0. */ byteOffset: number; byteLength: number; sha256: string; streams: readonly IndexedMeshoptBlockStream[]; } export interface IndexedMeshoptTrackDescriptor { format: typeof UTSBM_FORMAT; /** The single block-indexed track asset, manifest-relative. */ file: string; frameCount: number; gop: number; valuesPerFrame: number; elementOrder: 'vertex-major'; lanes: readonly IndexedMeshoptLane[]; streams: readonly IndexedMeshoptStream[]; blocks: readonly IndexedMeshoptBlock[]; /** Total raw bytes of the track file — the bytes JavaScript receives (Σ block byteLength). */ byteLength: number; /** Wire bytes after transport compression (informative; raw byteLength when absent). */ wireByteLength: number; } export interface IndexedMeshoptTrackDecoderDiagnostics { blockRequests: number; blockLoads: number; blockCacheHits: number; residentDecodedBlocks: number; transportBytesFetched: number; decodedBytes: number; reconstructedFrameBytes: number; hashFailures: number; suspended: boolean; disposed: boolean; } /** Minimal response surface for injected fetches (in-memory clip trees, tests). */ export interface IndexedMeshoptFetchResponse { ok?: boolean; status: number; /** When present, the track is consumed progressively; otherwise `arrayBuffer()` is used. */ body?: ReadableStream | null; arrayBuffer(): Promise; } export type IndexedMeshoptFetch = (input: string, init?: RequestInit) => PromiseLike; export interface IndexedMeshoptTrackDecoderOptions { meshoptDecoder: MeshoptVertexDecoderLike; resolveFile?: (file: string) => string; fetchImpl?: IndexedMeshoptFetch; } /** Bytes of one canonical lane-major frame (lanes concatenated in declared order). */ export declare function indexedMeshoptCanonicalFrameByteLength(track: Pick): number; /** * Validate one UTSBM track fragment from a manifest. Throws `MotionTrackError` with code * `UTSBM_MANIFEST_INVALID` on any structural violation; returns the typed descriptor. */ export declare function parseIndexedMeshoptTrack(value: unknown): IndexedMeshoptTrackDescriptor; /** * Runtime block reader: fetch → verify → meshopt-decode → one-pass transpose into canonical * lane-major frames, with a two-block resident LRU. `readFrame` resolves with a fresh copy the * caller owns. */ export declare class IndexedMeshoptTrackDecoder { #private; readonly track: IndexedMeshoptTrackDescriptor; constructor(track: IndexedMeshoptTrackDescriptor, options: IndexedMeshoptTrackDecoderOptions); getDiagnostics(): Readonly; /** Decode one canonical lane-major frame; the returned bytes belong to the caller. */ readFrame(frameIndex: number, signal?: AbortSignal): Promise; suspend(): void; resume(): void; abort(): void; dispose(): void; } export interface IndexedMeshoptEncodeLane { name: string; storage: IndexedMeshoptLaneStorage; bitDepth: number; frames: readonly (Uint8Array | Uint16Array)[]; } export interface IndexedMeshoptEncodeOptions { gop: number; /** Manifest-relative path of the single block-indexed track asset (e.g. `tracks/geometry.utsbm`). */ file: string; encoder: MeshoptVertexEncoderLike; /** meshopt encode effort (0-3ish); the codec version is always v1. */ level?: number; } export interface EncodedIndexedMeshoptTrack { /** Parsed descriptor — what a runtime consumer sees. */ track: IndexedMeshoptTrackDescriptor; /** The JSON fragment to persist into a manifest (callers may add `wireByteLength`). */ persistedTrack: Record; /** The complete track asset: every block contiguous at its declared byteOffset. */ fileBytes: Uint8Array; } /** * Encode canonical lanes into UTSBM blocks. Streams group consecutive same-storage lanes; * strides round up to the codec's multiple-of-4 rule with zero padding (which the transport * layer compresses away). Deterministic for identical input. */ export declare function encodeIndexedMeshoptTrack(lanes: readonly IndexedMeshoptEncodeLane[], options: IndexedMeshoptEncodeOptions): Promise;