/** * FrameAnimator - Frame-by-frame animation with function re-evaluation * * Supports both JavaScript functions and OpenSCAD $t variable. * * @example JavaScript * ```typescript * const code = `export default (t) => Shape.cube(10).rotate([0, t * 360, 0]);`; * const animator = new FrameAnimator(code, 'javascript', { * fps: 30, * duration: 2000, * onFrame: (geometry, t) => viewport.updateGeometry(geometry) * }); * await animator.start(); * ``` * * @example OpenSCAD * ```typescript * const code = `rotate([0, $t * 360, 0]) cube(10);`; * const animator = new FrameAnimator(code, 'openscad', { * fps: 30, * duration: 2000, * onFrame: (geometry, t) => viewport.updateGeometry(geometry) * }); * await animator.start(); * ``` */ import type { Geometry } from '../types'; export type AnimationLanguage = 'javascript' | 'openscad'; export interface FrameAnimatorOptions { /** Frames per second (default: 30) */ fps?: number; /** Total animation duration in milliseconds (default: 2000) */ duration?: number; /** Whether to loop the animation (default: false) */ loop?: boolean; /** Callback called for each frame with geometry and current t value */ onFrame: (geometry: Geometry, t: number) => void; /** Callback called when animation completes (only if not looping) */ onComplete?: () => void; /** Callback called on error */ onError?: (error: Error) => void; } export declare class FrameAnimator { private code; private language; private fps; private duration; private loop; private currentFrame; private totalFrames; private animationId; private isPlaying; private isPaused; private lastFrameTime; private onFrameCallback; private onCompleteCallback?; private onErrorCallback?; constructor(code: string, language: AnimationLanguage, options: FrameAnimatorOptions); /** * Start animation from the beginning */ start(): Promise; /** * Pause animation (can be resumed) */ pause(): void; /** * Resume paused animation */ resume(): Promise; /** * Stop animation and reset to beginning */ stop(): void; /** * Jump to specific frame */ setFrame(frameNumber: number): Promise; /** * Get current frame number */ getCurrentFrame(): number; /** * Get total number of frames */ getTotalFrames(): number; /** * Check if animation is playing */ getIsPlaying(): boolean; /** * Check if animation is paused */ getIsPaused(): boolean; /** * Get current time value (0.0 to 1.0) */ getCurrentT(): number; /** * Main animation loop - renders frames at specified FPS */ private animateFrame; /** * Evaluate code with specific t value */ private evaluateWithT; } //# sourceMappingURL=frame-animator.d.ts.map