UNPKG

@shopware-ag/dive

Version:

Shopware Spatial Framework

141 lines (140 loc) 5.12 kB
import { AnimationClip, Object3D } from 'three/webgpu'; import { DIVETicker } from '../../../../index.ts'; type ClipAnimator = import('../animator/ClipAnimator.ts').ClipAnimator; type TargetAnimator = import('../animator/TargetAnimator.ts').TargetAnimator; type TargetAnimatorOptions = import('../animator/TargetAnimator.ts').TargetAnimatorOptions; type AnimationTarget = import('../animator/TargetAnimator.ts').AnimationTarget; /** * Central animation system that manages all animators (target-based and clip-based). * * Create "to-target" animators with `fromTargets()` and "animation-clip" animators with `fromClips()`. * * Implements DIVETicker so it can be registered with DIVEClock for per-frame updates. * * @module */ export declare class AnimationSystem implements DIVETicker { uuid: string; readonly Easing: Readonly<{ Linear: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; } & { None: (amount: number) => number; }>; Quadratic: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Cubic: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Quartic: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Quintic: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Sinusoidal: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Exponential: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Circular: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Elastic: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Back: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; Bounce: Readonly<{ In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }>; generatePow(power?: number): { In: (amount: number) => number; Out: (amount: number) => number; InOut: (amount: number) => number; }; }>; private _animators; dispose(): void; tick(deltaTime: number): void; /** * Creates a TargetAnimator and returns it asynchronously. * * @example * // Animate a single target (e.g. position). * const animator = await animationSystem.fromTargets( * { position: { x: 0, y: 0, z: 0 }, to: { x: 10, y: 10, z: 10 } }, * 1000, * ); * // animate the target * animator.play(); * * @example * // Animate multiple targets (e.g. position and rotation) at once using an array. * const animator = await animationSystem.fromTargets( * [ * { position: { x: 0, y: 0, z: 0 }, to: { x: 10, y: 10, z: 10 } }, * { rotation: { x: 0, y: 0, z: 0 }, to: { x: 0, y: Math.PI / 2, z: 0 } }, * ], * 1000, * ); * // animate all targets in the array at once * animator.play(); * @param targets - The targets to animate. * @param duration - The duration of the animation in milliseconds. * @param options - The options for the animation. * @returns Promise<TargetAnimator>. */ fromTargets(targets: AnimationTarget | AnimationTarget[], duration: number, options?: TargetAnimatorOptions): Promise<TargetAnimator>; /** * Creates a ClipAnimator and returns it asynchronously. * * @example * // Animate a single clip (e.g. a single animation) at once. * const animator = await animationSystem.fromClips( * model, * model.animations, * ); * // plays first clip by default * animator.play(); * // plays plays "Idle" clip by name * animator.play("Idle"); * * @param root - The root object to animate. * @param clips - The animation clips to animate. * @returns Promise<ClipAnimator>. */ fromClips(root: Object3D, clips: AnimationClip[]): Promise<ClipAnimator>; /** * Removes an animator from the system. * * @param uuid - The UUID of the animator to remove. */ remove(uuid: string): void; } export {};