/** * Experimental public entry point for the Object Animation Video product block. * @module three-blocks/experimental/object-animation-video */ import type * as THREE from 'three'; import type { ObjectAnimationVideoDiagnostics as ObjectAnimationVideoDiagnosticsImplementation } from '../OAV/ObjectAnimationVideo.js'; import type { OAVManifest } from '../OAV/OAVManifest.js'; /** Persisted Object Animation Video package discriminator. */ export declare const OAV_MANIFEST_TYPE = "utsubo-oav"; /** Second public Object Animation Video manifest schema: transforms travel as one block-indexed UTSBM `.utsbm` asset, fetched once and streamed progressively. */ export declare const OAV_MANIFEST_VERSION = 2; /** Validated Object Animation Video package manifest. */ export type ObjectAnimationVideoManifest = Readonly; /** Snapshot of OAV exact decoding and bounded-residency counters. */ export type ObjectAnimationVideoDiagnostics = ObjectAnimationVideoDiagnosticsImplementation; /** Minimal fetch response consumed while loading an OAV manifest and its block-indexed UTSBM track asset. */ export interface ObjectAnimationVideoFetchResponse { /** Whether the response completed with a successful HTTP status. */ readonly ok: boolean; /** Numeric HTTP status used in load failures. */ readonly status: number; /** Read and decode the manifest response. */ json(): Promise; /** Read one whole binary block-asset response. */ arrayBuffer?: () => Promise; } /** Injectable network function used by {@link ObjectAnimationVideo.load}. */ export type ObjectAnimationVideoFetch = (input: string, init?: RequestInit) => Promise; /** 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; } /** Playback controls shared by network, in-memory, and direct construction. */ export interface ObjectAnimationVideoPlaybackOptions { /** Whether playback wraps after the final frame. */ loop?: boolean; /** Playback time multiplier. */ playbackSpeed?: number; /** Whether the clip begins in the playing state. */ play?: boolean; /** * Meshopt vertex decoder for the UTSBM transform track — pass `MeshoptDecoder` from * `three/addons/libs/meshopt_decoder.module.js` (the same module `GLTFLoader` uses). */ meshoptDecoder?: MeshoptVertexDecoderLike; } /** Direct-construction options: how the block-indexed UTSBM track asset referenced by the manifest loads — one fetch per track, consumed progressively. */ export interface ObjectAnimationVideoOptions extends ObjectAnimationVideoPlaybackOptions { /** Manifest-relative path resolver used by direct construction. */ resolveFile?: (file: string) => string; /** Fetch implementation used for the block-indexed UTSBM track asset. */ fetchImpl?: ObjectAnimationVideoFetch; } /** Network-load options for {@link ObjectAnimationVideo.load}. */ export interface ObjectAnimationVideoLoadOptions extends ObjectAnimationVideoPlaybackOptions { /** Optional fetch implementation used for the manifest and the block-indexed UTSBM track asset. */ fetchImpl?: ObjectAnimationVideoFetch; } /** Accepted byte containers in an in-memory OAV package. */ export type ObjectAnimationVideoFileValue = ArrayBuffer | ArrayBufferView; /** Manifest-relative in-memory package consumed by `loadFromFiles()`. */ export type ObjectAnimationVideoFiles = Map | Record; /** Manifest object index or stable authored name. */ export type ObjectAnimationVideoObjectSelector = number | string; /** Result of binding all same-named descendants beneath a Three.js root. */ export interface ObjectAnimationVideoBindResult { /** Number of manifest objects successfully bound. */ bound: number; /** Authored object names not found beneath the supplied root. */ missing: string[]; } /** Options for binding same-named descendants beneath a root. */ export interface ObjectAnimationVideoBindOptions { /** Throw instead of returning missing names when any manifest object is absent. */ strict?: boolean; } /** Options for removing a previously returned binding. */ export interface ObjectAnimationVideoUnbindOptions { /** Restore an Object3D's original matrix and auto-update setting. */ restore?: boolean; } /** Removable binding to a caller-owned Three.js object. */ export interface ObjectAnimationVideoObjectBinding { /** Binding discriminator. */ readonly kind: 'object'; /** Borrowed object receiving decoded matrices. */ readonly target: THREE.Object3D; /** Original local matrix retained for restoration. */ readonly matrix: THREE.Matrix4; /** Original automatic-matrix setting retained for restoration. */ readonly matrixAutoUpdate: boolean; } /** Minimal caller-owned instancing target accepted by `bindBatchedMesh()`. */ export interface ObjectAnimationVideoInstanceTarget { /** Apply one decoded transform to an instance slot. */ setMatrixAt(index: number, matrix: THREE.Matrix4): unknown; /** Optional Three.js update flag set after an instance batch is applied. */ readonly instanceMatrix?: { needsUpdate: boolean; }; } /** Removable binding to one slot in an instanced or batched target. */ export interface ObjectAnimationVideoInstanceBinding { /** Binding discriminator. */ readonly kind: 'instance'; /** Borrowed instance target receiving decoded matrices. */ readonly target: ObjectAnimationVideoInstanceTarget; /** Destination instance slot. */ readonly instanceIndex: number; } /** Binding handle accepted by {@link ObjectAnimationVideo.unbind}. */ export type ObjectAnimationVideoBinding = ObjectAnimationVideoObjectBinding | ObjectAnimationVideoInstanceBinding; /** * Compact destination index or explicit manifest-object-to-instance mapping accepted by * {@link ObjectAnimationVideo.bindBatchedMesh}. */ export type ObjectAnimationVideoInstanceMapping = number | ({ objectIndex?: ObjectAnimationVideoObjectSelector; object?: ObjectAnimationVideoObjectSelector; } & ({ instanceIndex: number; instance?: number; } | { instanceIndex?: never; instance: number; })); /** Fatal indexed decode notification. */ export interface ObjectAnimationVideoErrorEvent { /** Range, integrity, or decode failure. */ error: unknown; } /** Notification emitted after an encoded frame is decoded and cached. */ export interface ObjectAnimationVideoDecodeEvent { /** Decoded frame index. */ frame: number; } /** Notification emitted after interpolated matrices are applied to bindings. */ export interface ObjectAnimationVideoFrameEvent { /** Fractional sampled frame. */ frame: number; /** Lower decoded interpolation frame. */ lowerFrame: number; /** Upper decoded interpolation frame. */ upperFrame: number; /** Interpolation amount between the lower and upper frames. */ alpha: number; } /** Typed Three.js events emitted during OAV decoding and playback. */ export interface ObjectAnimationVideoEventMap { /** Fatal decode event. */ error: ObjectAnimationVideoErrorEvent; /** Completed frame decode event. */ decode: ObjectAnimationVideoDecodeEvent; /** Applied interpolated frame event. */ frame: ObjectAnimationVideoFrameEvent; } /** * Validate and freeze an unknown Object Animation Video manifest. * Throws when its discriminator, version, transform layout, object table, or track is invalid. */ export declare const parseOAVManifest: (input: unknown) => ObjectAnimationVideoManifest; /** * Runtime-only Object Animation Video playback facade. * * The object retains Three.js `EventDispatcher` identity. It owns its UTSBM block decoder, frame * cache, and internal data texture; bound objects and instance targets are borrowed. */ export interface ObjectAnimationVideo extends THREE.EventDispatcher { /** Validated immutable manifest used by playback and object-name lookup. */ readonly manifest: ObjectAnimationVideoManifest; /** Whether playback wraps after the final frame. */ loop: boolean; /** Playback time multiplier. */ playbackSpeed: number; /** Whether `update()` advances playback time. */ readonly playing: boolean; /** Current playback time in seconds. */ readonly time: number; /** Clip duration in seconds. */ readonly duration: number; /** * Resolves after manifest validation and UTSBM decoder configuration. Rejects on invalid * input, a missing track asset, fetch failure, or failed integrity checks. */ readonly ready: Promise; /** Resolves after the first decoded frame is applied, or with `null` after early disposal. */ readonly firstFrame: Promise; /** Bind one authored object index or name to a borrowed Three.js object. */ bindObject(indexOrName: ObjectAnimationVideoObjectSelector, target: THREE.Object3D): ObjectAnimationVideoObjectBinding; /** Bind every manifest object to a same-named descendant beneath a borrowed root. */ bind(root: THREE.Object3D, options?: ObjectAnimationVideoBindOptions): ObjectAnimationVideoBindResult; /** Bind manifest objects to slots on a borrowed instanced or batched target. */ bindBatchedMesh(target: ObjectAnimationVideoInstanceTarget, mapping?: readonly ObjectAnimationVideoInstanceMapping[] | null): ObjectAnimationVideoInstanceBinding[]; /** Remove one binding, restoring Object3D state by default. */ unbind(binding: ObjectAnimationVideoBinding, options?: ObjectAnimationVideoUnbindOptions): boolean; /** Resume playback-time advancement. */ play(): this; /** Pause playback while retaining the currently applied matrices. */ pause(): this; /** Seek to a time in seconds and apply the best decoded interpolation immediately. */ setTime(seconds: number): this; /** Seek to an authored frame index. */ setFrame(frame: number): this; /** * Advance playback and apply decoded matrices. Call once after input/control updates and * before Three.js updates world matrices and renders the frame. */ update(deltaSeconds: number): this; /** Copy the current interpolated matrix for a custom integration. */ getMatrixAt(indexOrName: ObjectAnimationVideoObjectSelector, target?: THREE.Matrix4): THREE.Matrix4; /** * Release active decoder resources while retaining the displayed matrices, bindings, texture, * and playback position. */ suspend(): void; /** Reconfigure released decoder resources and resume frame requests. */ resume(): Promise; /** Inspect exact decoding and bounded numerical residency. */ getDiagnostics(): Readonly; /** * Release the decoder, frame cache, and internal texture. Idempotent; all Object3D bindings * are restored and borrowed scene/instance objects are never disposed. */ dispose(): void; } interface ObjectAnimationVideoConstructor { readonly prototype: ObjectAnimationVideo; new (manifest: unknown, options: ObjectAnimationVideoOptions): ObjectAnimationVideo; load(url: string, options?: ObjectAnimationVideoLoadOptions): Promise; loadFromFiles(files: ObjectAnimationVideoFiles, options?: ObjectAnimationVideoPlaybackOptions): Promise; } /** * Construct, fetch, or open OAV playback without wrapping the implementation object. * Direct construction throws for invalid manifests or a missing meshopt decoder; asynchronous * load methods reject for network, format, track, or integrity failures. */ export declare const ObjectAnimationVideo: ObjectAnimationVideoConstructor; export {};