import { Sprite2DMaterial } from "../materials/Sprite2DMaterial.js"; import { SortLayerValue } from "../pipeline/sortLayers.js"; import { SpriteSheet } from "./types.js"; import { Sprite2D } from "./Sprite2D.js"; import { Animation, AnimationSetDefinition, PlayOptions } from "../animation/types.js"; import { AnimationController } from "../animation/AnimationController.js"; import { Color, Vector2 } from "three"; //#region src/sprites/AnimatedSprite2D.d.ts /** * Options for creating an AnimatedSprite2D. */ interface AnimatedSprite2DOptions { /** SpriteSheet containing animation frames */ spriteSheet: SpriteSheet; /** Custom material (sprites with same material instance batch together) */ material?: Sprite2DMaterial; /** Animation definitions */ animations?: Animation[]; /** Animation set definition (alternative to animations array) */ animationSet?: AnimationSetDefinition; /** Initial animation to play */ animation?: string; /** Auto-play on creation (default: true) */ autoPlay?: boolean; /** Anchor/pivot point (0-1), default [0.5, 0.5] (center) */ anchor?: Vector2 | [number, number]; /** Tint color, default white */ tint?: Color | string | number; /** Opacity 0-1, default 1 */ alpha?: number; /** Flip horizontally */ flipX?: boolean; /** Flip vertically */ flipY?: boolean; /** Sort layer — registered name or numeric order */ sortLayer?: SortLayerValue; /** Z-index within sortLayer */ zIndex?: number; /** Pixel-perfect rendering (snap to pixels) */ pixelPerfect?: boolean; } /** * A 2D sprite with animation support. * * @example * ```typescript * const player = new AnimatedSprite2D({ * spriteSheet: sheet, * animationSet: { * animations: { * idle: { frames: ['player_idle_0', 'player_idle_1'], fps: 8 }, * walk: { frames: ['player_walk_0', 'player_walk_1', 'player_walk_2'], fps: 12 }, * } * }, * animation: 'idle', * }); * * // In update loop * player.update(deltaMs); * * // Change animation * player.play('walk'); * ``` */ declare class AnimatedSprite2D extends Sprite2D { /** Animation controller */ readonly controller: AnimationController; /** Source spritesheet */ private _spriteSheet; /** True when alphaMap was inherited from a sheet, false when explicitly set by the user */ private _usesSpriteSheetAlphaMap; /** * Create a new AnimatedSprite2D. * Can be called with no arguments for R3F compatibility - set spriteSheet via property. */ constructor(options?: AnimatedSprite2DOptions); /** * Get the spritesheet. */ get spriteSheet(): SpriteSheet | null; /** * Set a new spritesheet. */ set spriteSheet(value: SpriteSheet | null); /** * Set animation set definition (R3F compatible). * Loads animations from the definition. */ set animationSet(value: AnimationSetDefinition | null); /** * Set the current animation by name (R3F compatible). * Plays the animation if found. */ set animation(value: string | null); /** * Load animations from an animation set definition. */ loadAnimationSet(definition: AnimationSetDefinition): this; /** * Add an animation. */ addAnimation(animation: Animation): this; /** * Add animation from frame names. */ addAnimationFromFrames(name: string, frameNames: string[], options?: { fps?: number; loop?: boolean; pingPong?: boolean; }): this; /** * Play an animation. */ play(name: string, options?: PlayOptions): this; /** * Pause the current animation. */ pause(): this; /** * Resume a paused animation. */ resume(): this; /** * Stop the current animation. */ stop(): this; /** * Go to a specific frame. */ gotoFrame(index: number): this; /** * Update animation (call in render loop). * @param deltaMs Time since last frame in milliseconds */ update(deltaMs: number): void; private readonly _onAnimFrame; private readonly _onAnimEvent; /** * Override to handle animation events. */ protected onAnimationEvent(_event: string, _frameIndex: number): void; /** * Check if an animation is playing. */ isPlaying(name?: string): boolean; /** * Get current animation name. */ get currentAnimation(): string | null; /** * Get playback speed. */ get speed(): number; /** * Set playback speed. */ set speed(value: number); /** * Get animation duration. */ getAnimationDuration(name?: string): number; /** * Clone the animated sprite. */ clone(recursive?: boolean): this; /** * Dispose of resources. */ dispose(): void; } //#endregion export { AnimatedSprite2D, AnimatedSprite2DOptions }; //# sourceMappingURL=AnimatedSprite2D.d.ts.map