/** * Experimental public entry point for the Vertex Animation Video product block. * @module three-blocks/experimental/vertex-animation-video */ import type * as THREE from 'three/webgpu'; import type { VAVMeshDiagnostics as VAVMeshDiagnosticsImplementation } from '../VAV/VAVMesh.js'; import type { VAVBase as VAVBaseImplementation, VAVManifest as VAVManifestImplementation, VAVNumericalTrack as VAVNumericalTrackImplementation, VAVTrackContainer as VAVTrackContainerImplementation } from '../VAV/VAVManifest.js'; import type { AFManifest } from '../Video/AFContainer.js'; /** Persisted Vertex Animation Video package discriminator. */ export declare const VAV_MANIFEST_TYPE = "utsubo-vav"; /** Second public Vertex Animation Video manifest schema: numerical tracks travel as one block-indexed UTSBM `.utsbm` asset per track, fetched once and streamed progressively. */ export declare const VAV_MANIFEST_VERSION = 2; /** Validated Vertex Animation Video runtime manifest. */ export type VAVManifest = Readonly; /** Exact UTSBM numerical track — one block-indexed meshopt asset per track, fetched once and streamed progressively. */ export type VAVNumericalTrack = VAVNumericalTrackImplementation; /** Parsed index and optional UV arrays from a VAV `base.bin` topology sidecar. */ export type VAVBase = VAVBaseImplementation; /** Normalized byte-index and codec descriptor shared by VAV media tracks. */ export type VAVTrackDescriptor = VAVTrackContainerImplementation; /** Media-decoder manifest assembled over a progressive VAV visual track buffer. */ export type VAVTrackDecoderManifest = AFManifest; /** Appearance source selected when a clip contains both vertex and UV media. */ export type VAVMeshAppearance = 'auto' | 'uv' | 'vertex'; /** Snapshot of VAV numerical decoding and optional UV media-decoder state. */ export type VAVMeshDiagnostics = VAVMeshDiagnosticsImplementation; /** Manifest-relative path resolver used by direct VAV construction. */ export type VAVMeshFileResolver = (file: string) => string; /** Minimal streaming response consumed by a VAV track. */ export interface VAVTrackFetchResponse { /** Whether the response completed with a successful HTTP status. */ readonly ok: boolean; /** Numeric HTTP status used in stream failures. */ readonly status: number; /** Optional HTTP headers used to validate resumed range responses. */ readonly headers?: { get(name: string): string | null; }; /** Optional progressive response body. */ readonly body?: ReadableStream | null; /** Whole-file fallback for runtimes without a readable streaming body. */ arrayBuffer?: () => Promise; } /** Injectable network function used to stream one VAV media track. */ export type VAVTrackFetch = (input: string, init?: RequestInit) => PromiseLike; /** Options for progressively fetching one VAV track. */ export interface VAVTrackStreamOptions { /** Clip frame rate used to derive decoder timestamps. */ frameRate?: number; /** Optional streaming fetch implementation. */ fetchImpl?: VAVTrackFetch; } /** Fetch response required while opening a manifest and topology sidecar. */ export interface VAVMeshFetchResponse extends VAVTrackFetchResponse { /** Read and decode a JSON manifest response. */ json(): Promise; /** Read a topology sidecar response. */ arrayBuffer(): Promise; } /** Injectable network function used by {@link VAVMesh.load}. */ export type VAVMeshFetch = (input: string, init?: RequestInit) => PromiseLike; /** The subset of `MeshoptDecoder` needed to decode UTSBM blocks — injected, never imported. */ interface MeshoptVertexDecoderLike { /** Optional readiness promise awaited before the first block decode. */ ready?: Promise; /** Decode one meshopt vertex-codec-v1 stream into `count` elements of `size` bytes each. */ decodeVertexBuffer(target: Uint8Array, count: number, size: number, source: Uint8Array): void; } /** Runtime construction and playback options for {@link VAVMesh}. */ export interface VAVMeshOptions { /** Borrowed NodeMaterial driven by the VAV geometry nodes; never disposed by the mesh. */ material?: THREE.NodeMaterial; /** Whether playback wraps after the final frame. */ loop?: boolean; /** Playback time multiplier. */ playbackSpeed?: number; /** Buffered duration required before starting or resuming a stalled stream. */ minBufferedSeconds?: number; /** Appearance-track family to load. */ appearance?: VAVMeshAppearance; /** Manifest-relative path resolver used by direct construction. */ resolveFile?: VAVMeshFileResolver; /** Streaming fetch implementation used by direct construction. */ fetchImpl?: VAVTrackFetch; /** * Meshopt vertex decoder for the UTSBM numerical tracks — pass `MeshoptDecoder` from * `three/addons/libs/meshopt_decoder.module.js` (the same module `GLTFLoader` uses). */ meshoptDecoder?: MeshoptVertexDecoderLike; } /** Network-load options; URL resolution is owned by {@link VAVMesh.load}. */ export interface VAVMeshLoadOptions extends Omit { /** Fetch implementation used for the manifest, topology, and progressive tracks. */ fetchImpl?: VAVMeshFetch; } /** Manifest-relative in-memory VAV package consumed by `loadFromFiles()`. */ export type VAVMeshFiles = Map | Record; /** * Validate and freeze an unknown Vertex Animation Video manifest. * Throws on a wrong version, malformed bounds/topology, or inconsistent track indices. */ export declare const parseVAVManifest: (input: unknown) => VAVManifest; /** * Parse and cross-check a VAV `base.bin` topology sidecar. * Throws when the sidecar is truncated or disagrees with the validated manifest. */ export declare const parseVAVBase: (buffer: ArrayBuffer, manifest: Readonly>) => VAVBase; /** * Runtime-only Vertex Animation Video mesh facade. * * The value remains the original Three.js `Mesh`, so it can be added directly to a scene. It * owns UTSBM numerical decoders, optional UV media streams, textures, and geometry. Materials * are borrowed (or transferred to the caller when created by default) and are not disposed here. */ export interface VAVMesh extends THREE.Mesh { /** Validated immutable clip manifest. */ readonly manifest: VAVManifest; /** Whether playback wraps after the final frame. */ loop: boolean; /** Playback time multiplier. */ playbackSpeed: number; /** Buffered duration required before starting or resuming after a stall. */ minBufferedSeconds: number; /** Whether `update()` is allowed to advance the playback clock. */ readonly playing: boolean; /** Current playback time in seconds. */ readonly time: number; /** Resolves after the first decoded frame reaches the GPU, or with `null` after early disposal. */ readonly firstFrame: Promise; /** Appearance-track family selected at construction. */ readonly appearance: VAVMeshAppearance; /** Clip duration in seconds. */ readonly duration: number; /** Whether playback is currently stalled waiting for streamed bytes. */ readonly isBuffering: boolean; /** Wire animated position and normal outputs into a borrowed NodeMaterial. */ registerMaterial(material: TMaterial): TMaterial; /** Wire an indirect-only baked GI output into a borrowed lit NodeMaterial. */ registerIrradiance(material: TMaterial): TMaterial; /** Begin or resume playback; advancement remains gated by the stream cushion. */ play(): void; /** Pause playback while retaining the current decoded frame pair. */ pause(): void; /** Scrub to a time in seconds, clamped to the clip duration. */ setTime(seconds: number): void; /** * Advance playback by elapsed seconds. Call once after input/control updates and before the * frame is rendered; a buffering clip holds time until every track has enough data. */ update(deltaSeconds: number): void; /** Seconds of contiguous media currently buffered ahead of the playhead. */ bufferedSecondsAhead(): number; /** Release requests and decoders while retaining the presented mesh and texture slots. */ suspend(): void; /** Recreate released decoders and continue suspended streams. */ resume(): Promise; /** Snapshot numerical binary and optional UV media-decoder state. */ getDiagnostics(): Readonly; /** * Abort streams and release decoders, decoded frames, textures, and geometry. Idempotent; * the inherited material is never disposed and remains the caller's responsibility. */ dispose(): void; } /** * Progressive runtime stream for one VAV media track. * * Encoded bytes and decoder views are owned by the stream. Consumers must only decode indices * confirmed available by this object and must stop using its manifest after disposal. */ export interface VAVTrackStream { /** Resolved track URL supplied at construction. */ readonly url: string; /** Normalized track byte-index and codec descriptor. */ readonly track: VAVTrackDescriptor; /** Number of response bytes received so far. */ readonly receivedBytes: number; /** Expected byte length declared by the track. */ readonly totalBytes: number; /** Pre-parsed manifest whose frame data views reference this stream's owned buffer. */ readonly manifest: VAVTrackDecoderManifest; /** Resolves after the full track arrives and rejects on network/truncation failure. */ readonly done: Promise; /** Whether one frame's complete encoded byte range has arrived. */ frameAvailable(index: number): boolean; /** Number of contiguous decodable frames available from the start of the clip. */ availableFrames(): number; /** Resolve when a frame becomes decodable; rejects for invalid indices or disposed streams. */ whenFrameAvailable(index: number): Promise; /** Buffered playback duration ahead of a caller-supplied frame index. */ bufferedSecondsAhead(fromFrame: number, frameRate: number): number; /** Abort the active request while retaining the received byte prefix and manifest views. */ suspend(): void; /** Continue fetching from the retained prefix. */ resume(): Promise; /** Abort the fetch and settle availability waiters. Idempotent; no new bytes arrive afterward. */ dispose(): void; } interface VAVMeshConstructor { readonly prototype: VAVMesh; new (manifest: VAVManifest, base: VAVBase, options?: VAVMeshOptions): VAVMesh; load(url: string, options?: VAVMeshLoadOptions): Promise; loadFromFiles(files: VAVMeshFiles, options?: VAVMeshOptions): Promise; } interface VAVTrackStreamConstructor { readonly prototype: VAVTrackStream; new (url: string, track: VAVTrackDescriptor, options?: VAVTrackStreamOptions): VAVTrackStream; } /** * Construct, fetch, or open a VAV mesh without wrapping its Three.js identity. Direct * construction throws for incompatible topology/media inputs or a missing meshopt decoder; * load methods reject for fetch, format, topology, or decoder initialization failures. */ export declare const VAVMesh: VAVMeshConstructor; /** * Start a progressive track fetch without wrapping the stream implementation. The `done` * promise reports HTTP, body, and truncation failures. */ export declare const VAVTrackStream: VAVTrackStreamConstructor; export {};