UNPKG

@lightningjs/renderer

Version:
63 lines (62 loc) 1.98 kB
import { type CoreNode, type CoreNodeAnimateProps } from '../CoreNode.js'; import { type TimingFunction } from '../utils.js'; import { EventEmitter } from '../../common/EventEmitter.js'; export interface AnimationSettings { duration: number; delay: number; easing: string | TimingFunction; loop: boolean; repeat: number; stopMethod: 'reverse' | 'reset' | false; } type PropGroup = { keys: string[]; starts: number[]; targets: number[]; isColor: boolean[]; length: number; }; type PropValuesMap = { props: PropGroup | null; shaderProps: PropGroup | null; }; export declare class CoreAnimation extends EventEmitter { id: number; duration: number; easing: string | TimingFunction; loop: boolean; repeat: number; stopMethod: 'reverse' | 'reset' | false; private hasEasing; private invDuration; private progress; private delayFor; private delay; private timingFunction; private node; activeIndex: number; private propsGroup; private shaderPropsGroup; static readonly EVENTS: readonly ["finished", "animating", "tick", "destroyed"]; propValuesMap: PropValuesMap; constructor(); /** * Initialize (or reinitialize) this animation with new parameters. * Called both on first use and when recycled from the pool. */ init(node: CoreNode, props: Partial<CoreNodeAnimateProps>, settings: Partial<AnimationSettings>): void; reset(): void; private restoreValues; restore(): void; private reverseValues; reverse(): void; /** * Interpolate a single property value given the current progress. * progress is passed as a parameter so callers can cache it in a local, * avoiding repeated this.progress reads (which box floats in V8). */ updateValue(isColor: boolean, propValue: number, startValue: number, progress: number): number; private updateValues; update(dt: number): void; } export {};