import * as THREE from "three"; import type { Axis } from "../core/types.js"; interface AnimationBackup { tracks: THREE.KeyframeTrack[]; root: THREE.Object3D | null; duration: number | null; speed: number | null; repeat: boolean | null; } /** * Manages keyframe animations for CAD objects. * Supports translation (t, tx, ty, tz) and rotation (q, rx, ry, rz) transforms. */ declare class Animation { delim: string; tracks: THREE.KeyframeTrack[]; mixer: THREE.AnimationMixer | null; clip: THREE.AnimationClip | null; clipAction: THREE.AnimationAction | null; clock: THREE.Timer; duration: number | null; speed: number | null; repeat: boolean | null; root: THREE.Object3D | null; _backup: AnimationBackup | null; /** * Create an Animation manager. * @param delim - Path delimiter used in object selectors. */ constructor(delim: string); /** * Prepare selector by replacing path delimiter. */ private _prepareSelector; /** * Validate that times and values arrays have the same length. */ private _validateArrayLengths; /** * Add a position track (full 3D translation). * @param selector - Object path selector (using "/" delimiter). * @param group - The object to animate. * @param times - Array of keyframe times. * @param positions - Array of [x, y, z] position offsets. */ addPositionTrack(selector: string, group: THREE.Object3D, times: number[], positions: number[][]): void; /** * Add a single-axis translation track. * @param selector - Object path selector (using "/" delimiter). * @param group - The object to animate. * @param axis - Which axis to translate along ("x", "y", or "z"). * @param times - Array of keyframe times. * @param values - Array of translation values along the axis. */ addTranslationTrack(selector: string, group: THREE.Object3D, axis: Axis, times: number[], values: number[]): void; /** * Add a quaternion rotation track. * @param selector - Object path selector (using "/" delimiter). * @param group - The object to animate. * @param times - Array of keyframe times. * @param quaternions - Array of [x, y, z, w] quaternion values. */ addQuaternionTrack(selector: string, group: THREE.Object3D, times: number[], quaternions: number[][]): void; /** * Add a single-axis rotation track. * @param selector - Object path selector (using "/" delimiter). * @param group - The object to animate. * @param axis - Which axis to rotate around ("x", "y", or "z"). * @param times - Array of keyframe times. * @param angles - Array of rotation angles in degrees. */ addRotationTrack(selector: string, group: THREE.Object3D, axis: Axis, times: number[], angles: number[]): void; /** * Store current animation state for later restoration. */ backup(): void; /** * Restore previously backed up animation state. */ restore(): { duration: number | null; speed: number | null; repeat: boolean | null; }; /** * Clear the backup state. */ cleanBackup(): void; /** * Check if any animation tracks have been added. */ hasTracks(): boolean; /** * Check if a backup exists. */ hasBackup(): boolean; /** * Create and start the animation. * @param root - Root object containing animated children. * @param duration - Animation duration in seconds. * @param speed - Playback speed multiplier. * @param repeat - Whether to loop (true) or ping-pong (false). * @returns The created animation action. */ animate(root: THREE.Object3D, duration: number, speed: number, repeat?: boolean): THREE.AnimationAction; /** * Set the animation to a specific relative time (0-1). * Pauses the animation at that point. */ setRelativeTime(fraction: number): void; /** * Get the current relative time (0-1). */ getRelativeTime(): number; /** * Dispose of animation resources. */ dispose(): void; /** * Update the animation mixer (call each frame when animating). */ update(): void; } export { Animation };