@flare-engine/animation 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/NOTICE +2 -0
- package/README.md +8 -3
- package/dist/index.d.mts +139 -132
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +139 -132
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +286 -287
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -232
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -10
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sprite-animator.ts","../src/tween.ts","../src/spring.ts","../src/tween-manager.ts","../src/periodic.ts","../src/step-sequence.ts","../src/timed-modifier.ts"],"sourcesContent":["export {\n type SpriteAnimatorState,\n createSpriteAnimator,\n playAnimation,\n stopAnimation,\n pauseAnimation,\n resumeAnimation,\n updateAnimator,\n getCurrentFrame,\n} from './sprite-animator.js';\n\nexport {\n type Tween,\n tween,\n updateTween,\n chainTween,\n resetTween,\n} from './tween.js';\n\nexport {\n type SpringConfig,\n type Spring,\n spring,\n updateSpring,\n setSpringTarget,\n resetSpring,\n} from './spring.js';\n\nexport {\n type TweenManager,\n createTweenManager,\n addTween,\n updateTweens,\n clearTweens,\n} from './tween-manager.js';\n\nexport {\n type PeriodicTween,\n periodicTween,\n updatePeriodicTween,\n resetPeriodicTween,\n} from './periodic.js';\n\nexport {\n type StepSequenceStep,\n type StepSequence,\n createStepSequence,\n tickStepSequence,\n resetStepSequence,\n} from './step-sequence.js';\n\nexport {\n type TimedModifier,\n createTimedModifier,\n tickModifier,\n isModifierActive,\n applyModifier,\n} from './timed-modifier.js';\n","import type { SpriteFrame, SpriteSheet } from '@flare-engine/assets';\n\n/** State of a sprite animator. */\nexport interface SpriteAnimatorState {\n /** The sprite sheet data source. */\n sheet: SpriteSheet;\n /** Current animation name, or null if none. */\n currentAnimation: string | null;\n /** Current frame index within the animation sequence. */\n frameIndex: number;\n /** Accumulated time within current frame (seconds). */\n elapsed: number;\n /** Whether animation is paused. */\n paused: boolean;\n /** Whether the current sequence has finished (non-looping). */\n finished: boolean;\n}\n\n/** Create a sprite animator state bound to a sprite sheet. */\nexport function createSpriteAnimator(sheet: SpriteSheet): SpriteAnimatorState {\n return {\n sheet,\n currentAnimation: null,\n frameIndex: 0,\n elapsed: 0,\n paused: false,\n finished: false,\n };\n}\n\n/** Play a named animation. Resets to frame 0. */\nexport function playAnimation(state: SpriteAnimatorState, name: string): void {\n const seq = state.sheet.animations.get(name);\n if (!seq) return;\n state.currentAnimation = name;\n state.frameIndex = 0;\n state.elapsed = 0;\n state.paused = false;\n state.finished = false;\n}\n\n/** Stop the current animation. */\nexport function stopAnimation(state: SpriteAnimatorState): void {\n state.currentAnimation = null;\n state.frameIndex = 0;\n state.elapsed = 0;\n state.paused = false;\n state.finished = false;\n}\n\n/** Pause the current animation. */\nexport function pauseAnimation(state: SpriteAnimatorState): void {\n state.paused = true;\n}\n\n/** Resume the current animation. */\nexport function resumeAnimation(state: SpriteAnimatorState): void {\n state.paused = false;\n}\n\n/**\n * Tick the animator forward by dt seconds.\n * Returns the current SpriteFrame, or null if no animation is playing.\n */\nexport function updateAnimator(state: SpriteAnimatorState, dt: number): SpriteFrame | null {\n if (!state.currentAnimation || state.paused || state.finished) {\n return getCurrentFrame(state);\n }\n\n const seq = state.sheet.animations.get(state.currentAnimation);\n if (!seq || seq.frameIndices.length === 0) return null;\n\n state.elapsed += dt;\n\n while (state.elapsed >= seq.frameDuration) {\n state.elapsed -= seq.frameDuration;\n state.frameIndex++;\n\n if (state.frameIndex >= seq.frameIndices.length) {\n if (seq.loop) {\n state.frameIndex = 0;\n } else {\n state.frameIndex = seq.frameIndices.length - 1;\n state.finished = true;\n state.elapsed = 0;\n break;\n }\n }\n }\n\n return getCurrentFrame(state);\n}\n\n/** Get the current SpriteFrame without advancing time. */\nexport function getCurrentFrame(state: SpriteAnimatorState): SpriteFrame | null {\n if (!state.currentAnimation) return null;\n const seq = state.sheet.animations.get(state.currentAnimation);\n if (!seq || seq.frameIndices.length === 0) return null;\n const globalIdx = seq.frameIndices[state.frameIndex];\n if (globalIdx === undefined) return null;\n return state.sheet.frames[globalIdx] ?? null;\n}\n","import type { EasingFn } from '@flare-engine/math';\n\n/** Tween state. */\nexport interface Tween {\n /** Start value. */\n from: number;\n /** End value. */\n to: number;\n /** Duration in seconds. */\n duration: number;\n /** Easing function. */\n easing: EasingFn;\n /** Elapsed time in seconds. */\n elapsed: number;\n /** Current interpolated value. */\n value: number;\n /** Whether the tween is complete. */\n done: boolean;\n /** Optional callback when tween completes. */\n onComplete: (() => void) | null;\n /** Chained tween to start after this one completes. */\n next: Tween | null;\n}\n\n/** Linear easing fallback. */\nfunction linearEasing(t: number): number {\n return t;\n}\n\n/** Create a tween. */\nexport function tween(from: number, to: number, duration: number, easing?: EasingFn): Tween {\n return {\n from,\n to,\n duration,\n easing: easing ?? linearEasing,\n elapsed: 0,\n value: from,\n done: false,\n onComplete: null,\n next: null,\n };\n}\n\n/**\n * Update a tween by dt seconds. Returns the current value.\n * When complete, triggers onComplete callback and advances to chained tween.\n */\nexport function updateTween(tw: Tween, dt: number): number {\n if (tw.done) return tw.value;\n\n tw.elapsed += dt;\n\n if (tw.elapsed >= tw.duration) {\n tw.elapsed = tw.duration;\n tw.value = tw.to;\n tw.done = true;\n tw.onComplete?.();\n return tw.value;\n }\n\n const t = tw.elapsed / tw.duration;\n tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);\n return tw.value;\n}\n\n/** Chain another tween to run after this one completes. Returns the chained tween. */\nexport function chainTween(tw: Tween, next: Tween): Tween {\n tw.next = next;\n return next;\n}\n\n/** Reset a tween to its initial state. */\nexport function resetTween(tw: Tween): void {\n tw.elapsed = 0;\n tw.value = tw.from;\n tw.done = false;\n}\n","/** Spring configuration. */\nexport interface SpringConfig {\n /** Spring stiffness (higher = faster oscillation). Default: 100. */\n stiffness: number;\n /** Damping coefficient (higher = less oscillation). Default: 10. */\n damping: number;\n /** Mass of the spring body. Default: 1. */\n mass: number;\n}\n\n/** Spring state. */\nexport interface Spring {\n /** Current value. */\n value: number;\n /** Current velocity. */\n velocity: number;\n /** Target value. */\n target: number;\n /** Configuration. */\n config: SpringConfig;\n /** Whether the spring has settled (within rest threshold). */\n atRest: boolean;\n}\n\nconst REST_THRESHOLD = 0.001;\nconst VELOCITY_THRESHOLD = 0.001;\n\n/** Create a spring with initial value. */\nexport function spring(value: number, target: number, config?: Partial<SpringConfig>): Spring {\n return {\n value,\n velocity: 0,\n target,\n config: {\n stiffness: config?.stiffness ?? 100,\n damping: config?.damping ?? 10,\n mass: config?.mass ?? 1,\n },\n atRest: value === target,\n };\n}\n\n/**\n * Update a spring by dt seconds. Returns the current value.\n * Uses semi-implicit Euler integration for stability.\n */\nexport function updateSpring(s: Spring, dt: number): number {\n if (s.atRest) return s.value;\n\n const { stiffness, damping, mass } = s.config;\n const displacement = s.value - s.target;\n const springForce = -stiffness * displacement;\n const dampingForce = -damping * s.velocity;\n const acceleration = (springForce + dampingForce) / mass;\n\n // Semi-implicit Euler: update velocity first, then position\n s.velocity += acceleration * dt;\n s.value += s.velocity * dt;\n\n // Check if settled\n if (Math.abs(s.value - s.target) < REST_THRESHOLD && Math.abs(s.velocity) < VELOCITY_THRESHOLD) {\n s.value = s.target;\n s.velocity = 0;\n s.atRest = true;\n }\n\n return s.value;\n}\n\n/** Set a new target for the spring. Wakes it if at rest. */\nexport function setSpringTarget(s: Spring, target: number): void {\n s.target = target;\n s.atRest = false;\n}\n\n/** Reset both value and target, zeroing velocity. */\nexport function resetSpring(s: Spring, value: number): void {\n s.value = value;\n s.target = value;\n s.velocity = 0;\n s.atRest = true;\n}\n","import type { Tween } from './tween.js';\nimport { updateTween } from './tween.js';\n\n/**\n * Manages a collection of active tweens.\n * Automatically removes completed tweens (or advances to chained tweens).\n */\nexport interface TweenManager {\n /** Active tweens. */\n readonly tweens: Tween[];\n}\n\n/** Create a new TweenManager. */\nexport function createTweenManager(): TweenManager {\n return { tweens: [] };\n}\n\n/** Add a tween to the manager. */\nexport function addTween(mgr: TweenManager, tw: Tween): void {\n (mgr.tweens as Tween[]).push(tw);\n}\n\n/**\n * Update all managed tweens by dt seconds.\n * Completed tweens are removed; chained tweens replace completed ones.\n */\nexport function updateTweens(mgr: TweenManager, dt: number): void {\n const tweens = mgr.tweens as Tween[];\n let i = 0;\n while (i < tweens.length) {\n const tw: Tween = tweens[i]!;\n updateTween(tw, dt);\n if (tw.done) {\n if (tw.next) {\n // Replace with chained tween\n tweens[i] = tw.next;\n i++;\n } else {\n // Swap-remove\n tweens[i] = tweens[tweens.length - 1]!;\n tweens.pop();\n }\n } else {\n i++;\n }\n }\n}\n\n/** Remove all tweens. */\nexport function clearTweens(mgr: TweenManager): void {\n (mgr.tweens as Tween[]).length = 0;\n}\n","import { type EasingFn, easeInOutSine } from '@flare-engine/math';\n\n/** Oscillating tween that ping-pongs between `from` and `to` indefinitely. */\nexport interface PeriodicTween {\n /** Start value. */\n readonly from: number;\n /** End value. */\n readonly to: number;\n /** Full cycle period in seconds (from → to → from). */\n readonly period: number;\n /** Easing function (default: easeInOutSine). */\n readonly easing: EasingFn;\n /** Elapsed time in seconds — mutable, advanced by updatePeriodicTween. */\n elapsed: number;\n /** Current interpolated value — written by updatePeriodicTween. */\n value: number;\n}\n\n/**\n * Create a periodic oscillating tween.\n *\n * @param from Start value.\n * @param to End value.\n * @param period Full cycle duration in seconds (must be > 0).\n * @param easing Easing function. Defaults to easeInOutSine.\n */\nexport function periodicTween(\n from: number,\n to: number,\n period: number,\n easing: EasingFn = easeInOutSine,\n): PeriodicTween {\n if (period <= 0) throw new Error('periodicTween: period must be > 0');\n return { from, to, period, easing, elapsed: 0, value: from };\n}\n\n/**\n * Advance a periodic tween by `dt` seconds. Wraps elapsed modulo period,\n * computes ping-pong t, applies easing, writes `value`, returns it.\n */\nexport function updatePeriodicTween(tw: PeriodicTween, dt: number): number {\n tw.elapsed = (tw.elapsed + dt) % tw.period;\n const halfPeriod = tw.period * 0.5;\n // t in [0,1] ping-pong: forward for first half, backward for second half.\n const halfPhase = tw.elapsed / halfPeriod;\n const t = halfPhase <= 1 ? halfPhase : 2 - halfPhase;\n tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);\n return tw.value;\n}\n\n/**\n * Reset a periodic tween: zero elapsed, restore value to `from`.\n */\nexport function resetPeriodicTween(tw: PeriodicTween): void {\n tw.elapsed = 0;\n tw.value = tw.from;\n}\n","export interface StepSequenceStep {\n readonly duration: number;\n}\n\nexport interface StepSequence {\n readonly steps: readonly StepSequenceStep[];\n current: number;\n elapsed: number;\n}\n\nexport function createStepSequence(steps: readonly StepSequenceStep[]): StepSequence {\n if (steps.length === 0) throw new Error('createStepSequence: steps must not be empty');\n for (let i = 0; i < steps.length; i++) {\n if ((steps[i]?.duration ?? 0) <= 0)\n throw new Error('createStepSequence: each step duration must be > 0');\n }\n return { steps, current: 0, elapsed: 0 };\n}\n\nexport function tickStepSequence(seq: StepSequence, dt: number): number {\n seq.elapsed += dt;\n while (seq.elapsed >= (seq.steps[seq.current]?.duration ?? 0)) {\n seq.elapsed -= seq.steps[seq.current]!.duration;\n seq.current = (seq.current + 1) % seq.steps.length;\n }\n return seq.current;\n}\n\nexport function resetStepSequence(seq: StepSequence): void {\n seq.current = 0;\n seq.elapsed = 0;\n}\n","export interface TimedModifier<T> {\n readonly value: T;\n readonly combine: (base: T, modifier: T) => T;\n remaining: number;\n}\n\nexport function createTimedModifier<T>(\n value: T,\n duration: number,\n combine: (base: T, modifier: T) => T,\n): TimedModifier<T> {\n if (duration <= 0) throw new Error('createTimedModifier: duration must be > 0');\n return { value, combine, remaining: duration };\n}\n\nexport function tickModifier<T>(mod: TimedModifier<T>, dt: number): void {\n mod.remaining = mod.remaining - dt < 0 ? 0 : mod.remaining - dt;\n}\n\nexport function isModifierActive<T>(mod: TimedModifier<T>): boolean {\n return mod.remaining > 0;\n}\n\n/**\n * Returns combine(base, mod.value) when active, base otherwise.\n * Zero-alloc only when T is number and combine is pure arithmetic.\n */\nexport function applyModifier<T>(base: T, mod: TimedModifier<T>): T {\n return mod.remaining > 0 ? mod.combine(base, mod.value) : base;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,qBAAqB,OAAyC;AAC5E,SAAO;AAAA,IACL;AAAA,IACA,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF;AAGO,SAAS,cAAc,OAA4B,MAAoB;AAC5E,QAAM,MAAM,MAAM,MAAM,WAAW,IAAI,IAAI;AAC3C,MAAI,CAAC,IAAK;AACV,QAAM,mBAAmB;AACzB,QAAM,aAAa;AACnB,QAAM,UAAU;AAChB,QAAM,SAAS;AACf,QAAM,WAAW;AACnB;AAGO,SAAS,cAAc,OAAkC;AAC9D,QAAM,mBAAmB;AACzB,QAAM,aAAa;AACnB,QAAM,UAAU;AAChB,QAAM,SAAS;AACf,QAAM,WAAW;AACnB;AAGO,SAAS,eAAe,OAAkC;AAC/D,QAAM,SAAS;AACjB;AAGO,SAAS,gBAAgB,OAAkC;AAChE,QAAM,SAAS;AACjB;AAMO,SAAS,eAAe,OAA4B,IAAgC;AACzF,MAAI,CAAC,MAAM,oBAAoB,MAAM,UAAU,MAAM,UAAU;AAC7D,WAAO,gBAAgB,KAAK;AAAA,EAC9B;AAEA,QAAM,MAAM,MAAM,MAAM,WAAW,IAAI,MAAM,gBAAgB;AAC7D,MAAI,CAAC,OAAO,IAAI,aAAa,WAAW,E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,IAAI,MAAM,QAAQ,KAAK;AACrC,SAAK,MAAM,CAAC,GAAG,YAAY,MAAM;AAC/B,YAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,SAAO,EAAE,OAAO,SAAS,GAAG,SAAS,EAAE;AACzC;AAEO,SAAS,iBAAiB,KAAmB,IAAoB;AACtE,MAAI,WAAW;AACf,SAAO,IAAI,YAAY,IAAI,MAAM,IAAI,OAAO,GAAG,YAAY,IAAI;AAC7D,QAAI,WAAW,IAAI,MAAM,IAAI,OAAO,EAAG;AACvC,QAAI,WAAW,IAAI,UAAU,KAAK,IAAI,MAAM;AAAA,EAC9C;AACA,SAAO,IAAI;AACb;AAEO,SAAS,kBAAkB,KAAyB;AACzD,MAAI,UAAU;AACd,MAAI,UAAU;AAChB;;;ACzBO,SAAS,oBACd,OACA,UACA,SACkB;AAClB,MAAI,YAAY,EAAG,OAAM,IAAI,MAAM,2CAA2C;AAC9E,SAAO,EAAE,OAAO,SAAS,WAAW,SAAS;AAC/C;AAEO,SAAS,aAAgB,KAAuB,IAAkB;AACvE,MAAI,YAAY,IAAI,YAAY,KAAK,IAAI,IAAI,IAAI,YAAY;AAC/D;AAEO,SAAS,iBAAoB,KAAgC;AAClE,SAAO,IAAI,YAAY;AACzB;AAMO,SAAS,cAAiB,MAAS,KAA0B;AAClE,SAAO,IAAI,YAAY,IAAI,IAAI,QAAQ,MAAM,IAAI,KAAK,IAAI;AAC5D;","names":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["easeInOutSine"],"sources":["../src/periodic.ts","../src/spring.ts","../src/sprite-animator.ts","../src/step-sequence.ts","../src/timed-modifier.ts","../src/tween.ts","../src/tween-manager.ts"],"sourcesContent":["import { type EasingFn, easeInOutSine } from '@flare-engine/math';\n\n/** Oscillating tween that ping-pongs between `from` and `to` indefinitely. */\nexport interface PeriodicTween {\n /** Start value. */\n readonly from: number;\n /** End value. */\n readonly to: number;\n /** Full cycle period in seconds (from → to → from). */\n readonly period: number;\n /** Easing function (default: easeInOutSine). */\n readonly easing: EasingFn;\n /** Elapsed time in seconds — mutable, advanced by updatePeriodicTween. */\n elapsed: number;\n /** Current interpolated value — written by updatePeriodicTween. */\n value: number;\n}\n\n/**\n * Create a periodic oscillating tween.\n *\n * @param from Start value.\n * @param to End value.\n * @param period Full cycle duration in seconds (must be > 0).\n * @param easing Easing function. Defaults to easeInOutSine.\n */\nexport function periodicTween(\n from: number,\n to: number,\n period: number,\n easing: EasingFn = easeInOutSine,\n): PeriodicTween {\n if (period <= 0) throw new Error('periodicTween: period must be > 0');\n return { from, to, period, easing, elapsed: 0, value: from };\n}\n\n/**\n * Advance a periodic tween by `dt` seconds. Wraps elapsed modulo period,\n * computes ping-pong t, applies easing, writes `value`, returns it.\n */\nexport function updatePeriodicTween(tw: PeriodicTween, dt: number): number {\n tw.elapsed = (tw.elapsed + dt) % tw.period;\n const halfPeriod = tw.period * 0.5;\n // t in [0,1] ping-pong: forward for first half, backward for second half.\n const halfPhase = tw.elapsed / halfPeriod;\n const t = halfPhase <= 1 ? halfPhase : 2 - halfPhase;\n tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);\n return tw.value;\n}\n\n/**\n * Reset a periodic tween: zero elapsed, restore value to `from`.\n */\nexport function resetPeriodicTween(tw: PeriodicTween): void {\n tw.elapsed = 0;\n tw.value = tw.from;\n}\n","/** Spring configuration. */\nexport interface SpringConfig {\n /** Spring stiffness (higher = faster oscillation). Default: 100. */\n stiffness: number;\n /** Damping coefficient (higher = less oscillation). Default: 10. */\n damping: number;\n /** Mass of the spring body. Default: 1. */\n mass: number;\n}\n\n/** Spring state. */\nexport interface Spring {\n /** Current value. */\n value: number;\n /** Current velocity. */\n velocity: number;\n /** Target value. */\n target: number;\n /** Configuration. */\n config: SpringConfig;\n /** Whether the spring has settled (within rest threshold). */\n atRest: boolean;\n}\n\nconst REST_THRESHOLD = 0.001;\nconst VELOCITY_THRESHOLD = 0.001;\n\n/** Create a spring with initial value. */\nexport function spring(value: number, target: number, config?: Partial<SpringConfig>): Spring {\n return {\n value,\n velocity: 0,\n target,\n config: {\n stiffness: config?.stiffness ?? 100,\n damping: config?.damping ?? 10,\n mass: config?.mass ?? 1,\n },\n atRest: value === target,\n };\n}\n\n/**\n * Update a spring by dt seconds. Returns the current value.\n * Uses semi-implicit Euler integration for stability.\n */\nexport function updateSpring(s: Spring, dt: number): number {\n if (s.atRest) return s.value;\n\n const { stiffness, damping, mass } = s.config;\n const displacement = s.value - s.target;\n const springForce = -stiffness * displacement;\n const dampingForce = -damping * s.velocity;\n const acceleration = (springForce + dampingForce) / mass;\n\n // Semi-implicit Euler: update velocity first, then position\n s.velocity += acceleration * dt;\n s.value += s.velocity * dt;\n\n // Check if settled\n if (Math.abs(s.value - s.target) < REST_THRESHOLD && Math.abs(s.velocity) < VELOCITY_THRESHOLD) {\n s.value = s.target;\n s.velocity = 0;\n s.atRest = true;\n }\n\n return s.value;\n}\n\n/** Set a new target for the spring. Wakes it if at rest. */\nexport function setSpringTarget(s: Spring, target: number): void {\n s.target = target;\n s.atRest = false;\n}\n\n/** Reset both value and target, zeroing velocity. */\nexport function resetSpring(s: Spring, value: number): void {\n s.value = value;\n s.target = value;\n s.velocity = 0;\n s.atRest = true;\n}\n","import type { SpriteFrame, SpriteSheet } from '@flare-engine/assets';\n\n/** State of a sprite animator. */\nexport interface SpriteAnimatorState {\n /** The sprite sheet data source. */\n sheet: SpriteSheet;\n /** Current animation name, or null if none. */\n currentAnimation: string | null;\n /** Current frame index within the animation sequence. */\n frameIndex: number;\n /** Accumulated time within current frame (seconds). */\n elapsed: number;\n /** Whether animation is paused. */\n paused: boolean;\n /** Whether the current sequence has finished (non-looping). */\n finished: boolean;\n}\n\n/** Create a sprite animator state bound to a sprite sheet. */\nexport function createSpriteAnimator(sheet: SpriteSheet): SpriteAnimatorState {\n return {\n sheet,\n currentAnimation: null,\n frameIndex: 0,\n elapsed: 0,\n paused: false,\n finished: false,\n };\n}\n\n/** Play a named animation. Resets to frame 0. */\nexport function playAnimation(state: SpriteAnimatorState, name: string): void {\n const seq = state.sheet.animations.get(name);\n if (!seq) return;\n state.currentAnimation = name;\n state.frameIndex = 0;\n state.elapsed = 0;\n state.paused = false;\n state.finished = false;\n}\n\n/** Stop the current animation. */\nexport function stopAnimation(state: SpriteAnimatorState): void {\n state.currentAnimation = null;\n state.frameIndex = 0;\n state.elapsed = 0;\n state.paused = false;\n state.finished = false;\n}\n\n/** Pause the current animation. */\nexport function pauseAnimation(state: SpriteAnimatorState): void {\n state.paused = true;\n}\n\n/** Resume the current animation. */\nexport function resumeAnimation(state: SpriteAnimatorState): void {\n state.paused = false;\n}\n\n/**\n * Tick the animator forward by dt seconds.\n * Returns the current SpriteFrame, or null if no animation is playing.\n */\nexport function updateAnimator(state: SpriteAnimatorState, dt: number): SpriteFrame | null {\n if (!state.currentAnimation || state.paused || state.finished) {\n return getCurrentFrame(state);\n }\n\n const seq = state.sheet.animations.get(state.currentAnimation);\n if (!seq || seq.frameIndices.length === 0) return null;\n if (seq.frameDuration <= 0) throw new Error('updateAnimator: frameDuration must be > 0');\n\n state.elapsed += dt;\n\n while (state.elapsed >= seq.frameDuration) {\n state.elapsed -= seq.frameDuration;\n state.frameIndex++;\n\n if (state.frameIndex >= seq.frameIndices.length) {\n if (seq.loop) {\n state.frameIndex = 0;\n } else {\n state.frameIndex = seq.frameIndices.length - 1;\n state.finished = true;\n state.elapsed = 0;\n break;\n }\n }\n }\n\n return getCurrentFrame(state);\n}\n\n/** Get the current SpriteFrame without advancing time. */\nexport function getCurrentFrame(state: SpriteAnimatorState): SpriteFrame | null {\n if (!state.currentAnimation) return null;\n const seq = state.sheet.animations.get(state.currentAnimation);\n if (!seq || seq.frameIndices.length === 0) return null;\n const globalIdx = seq.frameIndices[state.frameIndex];\n if (globalIdx === undefined) return null;\n return state.sheet.frames[globalIdx] ?? null;\n}\n","export interface StepSequenceStep {\n readonly duration: number;\n}\n\nexport interface StepSequence {\n readonly steps: readonly StepSequenceStep[];\n current: number;\n elapsed: number;\n}\n\nexport function createStepSequence(steps: readonly StepSequenceStep[]): StepSequence {\n if (steps.length === 0) throw new Error('createStepSequence: steps must not be empty');\n for (let i = 0; i < steps.length; i++) {\n if ((steps[i]?.duration ?? 0) <= 0)\n throw new Error('createStepSequence: each step duration must be > 0');\n }\n return { steps, current: 0, elapsed: 0 };\n}\n\nexport function tickStepSequence(seq: StepSequence, dt: number): number {\n seq.elapsed += dt;\n while (seq.elapsed >= (seq.steps[seq.current]?.duration ?? 0)) {\n seq.elapsed -= seq.steps[seq.current]!.duration;\n seq.current = (seq.current + 1) % seq.steps.length;\n }\n return seq.current;\n}\n\nexport function resetStepSequence(seq: StepSequence): void {\n seq.current = 0;\n seq.elapsed = 0;\n}\n","export interface TimedModifier<T> {\n readonly value: T;\n readonly combine: (base: T, modifier: T) => T;\n remaining: number;\n}\n\nexport function createTimedModifier<T>(\n value: T,\n duration: number,\n combine: (base: T, modifier: T) => T,\n): TimedModifier<T> {\n if (duration <= 0) throw new Error('createTimedModifier: duration must be > 0');\n return { value, combine, remaining: duration };\n}\n\nexport function tickModifier<T>(mod: TimedModifier<T>, dt: number): void {\n mod.remaining = mod.remaining - dt < 0 ? 0 : mod.remaining - dt;\n}\n\nexport function isModifierActive<T>(mod: TimedModifier<T>): boolean {\n return mod.remaining > 0;\n}\n\n/**\n * Returns combine(base, mod.value) when active, base otherwise.\n * Zero-alloc only when T is number and combine is pure arithmetic.\n */\nexport function applyModifier<T>(base: T, mod: TimedModifier<T>): T {\n return mod.remaining > 0 ? mod.combine(base, mod.value) : base;\n}\n","import type { EasingFn } from '@flare-engine/math';\n\n/** Tween state. */\nexport interface Tween {\n /** Start value. */\n from: number;\n /** End value. */\n to: number;\n /** Duration in seconds. */\n duration: number;\n /** Easing function. */\n easing: EasingFn;\n /** Elapsed time in seconds. */\n elapsed: number;\n /** Current interpolated value. */\n value: number;\n /** Whether the tween is complete. */\n done: boolean;\n /** Optional callback when tween completes. */\n onComplete: (() => void) | null;\n /** Chained tween to start after this one completes. */\n next: Tween | null;\n}\n\n/** Linear easing fallback. */\nfunction linearEasing(t: number): number {\n return t;\n}\n\n/** Create a tween. */\nexport function tween(from: number, to: number, duration: number, easing?: EasingFn): Tween {\n return {\n from,\n to,\n duration,\n easing: easing ?? linearEasing,\n elapsed: 0,\n value: from,\n done: false,\n onComplete: null,\n next: null,\n };\n}\n\n/**\n * Update a tween by dt seconds. Returns the current value.\n * When complete, triggers onComplete callback and advances to chained tween.\n */\nexport function updateTween(tw: Tween, dt: number): number {\n if (tw.done) return tw.value;\n\n tw.elapsed += dt;\n\n if (tw.elapsed >= tw.duration) {\n tw.elapsed = tw.duration;\n tw.value = tw.to;\n tw.done = true;\n tw.onComplete?.();\n return tw.value;\n }\n\n const t = tw.elapsed / tw.duration;\n tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);\n return tw.value;\n}\n\n/** Chain another tween to run after this one completes. Returns the chained tween. */\nexport function chainTween(tw: Tween, next: Tween): Tween {\n tw.next = next;\n return next;\n}\n\n/** Reset a tween to its initial state. */\nexport function resetTween(tw: Tween): void {\n tw.elapsed = 0;\n tw.value = tw.from;\n tw.done = false;\n}\n","import type { Tween } from './tween.js';\nimport { updateTween } from './tween.js';\n\n/**\n * Manages a collection of active tweens.\n * Automatically removes completed tweens (or advances to chained tweens).\n */\nexport interface TweenManager {\n /** Active tweens. */\n readonly tweens: Tween[];\n}\n\n/** Create a new TweenManager. */\nexport function createTweenManager(): TweenManager {\n return { tweens: [] };\n}\n\n/** Add a tween to the manager. */\nexport function addTween(mgr: TweenManager, tw: Tween): void {\n (mgr.tweens as Tween[]).push(tw);\n}\n\n/**\n * Update all managed tweens by dt seconds.\n * Completed tweens are removed; chained tweens replace completed ones.\n */\nexport function updateTweens(mgr: TweenManager, dt: number): void {\n const tweens = mgr.tweens as Tween[];\n let i = 0;\n while (i < tweens.length) {\n const tw: Tween = tweens[i]!;\n updateTween(tw, dt);\n if (tw.done) {\n if (tw.next) {\n // Replace with chained tween\n tweens[i] = tw.next;\n i++;\n } else {\n // Swap-remove\n tweens[i] = tweens[tweens.length - 1]!;\n tweens.pop();\n }\n } else {\n i++;\n }\n }\n}\n\n/** Remove all tweens. */\nexport function clearTweens(mgr: TweenManager): void {\n (mgr.tweens as Tween[]).length = 0;\n}\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgB,cACd,MACA,IACA,QACA,SAAmBA,mBAAAA,eACJ;CACf,IAAI,UAAU,GAAG,MAAM,IAAI,MAAM,mCAAmC;CACpE,OAAO;EAAE;EAAM;EAAI;EAAQ;EAAQ,SAAS;EAAG,OAAO;CAAK;AAC7D;;;;;AAMA,SAAgB,oBAAoB,IAAmB,IAAoB;CACzE,GAAG,WAAW,GAAG,UAAU,MAAM,GAAG;CACpC,MAAM,aAAa,GAAG,SAAS;CAE/B,MAAM,YAAY,GAAG,UAAU;CAC/B,MAAM,IAAI,aAAa,IAAI,YAAY,IAAI;CAC3C,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpD,OAAO,GAAG;AACZ;;;;AAKA,SAAgB,mBAAmB,IAAyB;CAC1D,GAAG,UAAU;CACb,GAAG,QAAQ,GAAG;AAChB;;;AChCA,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;;AAG3B,SAAgB,OAAO,OAAe,QAAgB,QAAwC;CAC5F,OAAO;EACL;EACA,UAAU;EACV;EACA,QAAQ;GACN,WAAW,QAAQ,aAAa;GAChC,SAAS,QAAQ,WAAW;GAC5B,MAAM,QAAQ,QAAQ;EACxB;EACA,QAAQ,UAAU;CACpB;AACF;;;;;AAMA,SAAgB,aAAa,GAAW,IAAoB;CAC1D,IAAI,EAAE,QAAQ,OAAO,EAAE;CAEvB,MAAM,EAAE,WAAW,SAAS,SAAS,EAAE;CACvC,MAAM,eAAe,EAAE,QAAQ,EAAE;CAGjC,MAAM,gBAFc,CAAC,YAAY,eACZ,CAAC,UAAU,EAAE,YACkB;CAGpD,EAAE,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AK,OAAmB,KAAK,EAAE;AACjC;;;;;AAMA,SAAgB,aAAa,KAAmB,IAAkB;CAChE,MAAM,SAAS,IAAI;CACnB,IAAI,IAAI;CACR,OAAO,IAAI,OAAO,QAAQ;EACxB,MAAM,KAAY,OAAO;EACzB,YAAY,IAAI,EAAE;EAClB,IAAI,GAAG,MACL,IAAI,GAAG,MAAM;GAEX,OAAO,KAAK,GAAG;GACf;EACF,OAAO;GAEL,OAAO,KAAK,OAAO,OAAO,SAAS;GACnC,OAAO,IAAI;EACb;OAEA;CAEJ;AACF;;AAGA,SAAgB,YAAY,KAAyB;CACnD,IAAK,OAAmB,SAAS;AACnC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,266 +1,291 @@
|
|
|
1
|
-
|
|
1
|
+
import { easeInOutSine } from "@flare-engine/math";
|
|
2
|
+
//#region src/periodic.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create a periodic oscillating tween.
|
|
5
|
+
*
|
|
6
|
+
* @param from Start value.
|
|
7
|
+
* @param to End value.
|
|
8
|
+
* @param period Full cycle duration in seconds (must be > 0).
|
|
9
|
+
* @param easing Easing function. Defaults to easeInOutSine.
|
|
10
|
+
*/
|
|
11
|
+
function periodicTween(from, to, period, easing = easeInOutSine) {
|
|
12
|
+
if (period <= 0) throw new Error("periodicTween: period must be > 0");
|
|
13
|
+
return {
|
|
14
|
+
from,
|
|
15
|
+
to,
|
|
16
|
+
period,
|
|
17
|
+
easing,
|
|
18
|
+
elapsed: 0,
|
|
19
|
+
value: from
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Advance a periodic tween by `dt` seconds. Wraps elapsed modulo period,
|
|
24
|
+
* computes ping-pong t, applies easing, writes `value`, returns it.
|
|
25
|
+
*/
|
|
26
|
+
function updatePeriodicTween(tw, dt) {
|
|
27
|
+
tw.elapsed = (tw.elapsed + dt) % tw.period;
|
|
28
|
+
const halfPeriod = tw.period * .5;
|
|
29
|
+
const halfPhase = tw.elapsed / halfPeriod;
|
|
30
|
+
const t = halfPhase <= 1 ? halfPhase : 2 - halfPhase;
|
|
31
|
+
tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);
|
|
32
|
+
return tw.value;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reset a periodic tween: zero elapsed, restore value to `from`.
|
|
36
|
+
*/
|
|
37
|
+
function resetPeriodicTween(tw) {
|
|
38
|
+
tw.elapsed = 0;
|
|
39
|
+
tw.value = tw.from;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/spring.ts
|
|
43
|
+
const REST_THRESHOLD = .001;
|
|
44
|
+
const VELOCITY_THRESHOLD = .001;
|
|
45
|
+
/** Create a spring with initial value. */
|
|
46
|
+
function spring(value, target, config) {
|
|
47
|
+
return {
|
|
48
|
+
value,
|
|
49
|
+
velocity: 0,
|
|
50
|
+
target,
|
|
51
|
+
config: {
|
|
52
|
+
stiffness: config?.stiffness ?? 100,
|
|
53
|
+
damping: config?.damping ?? 10,
|
|
54
|
+
mass: config?.mass ?? 1
|
|
55
|
+
},
|
|
56
|
+
atRest: value === target
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Update a spring by dt seconds. Returns the current value.
|
|
61
|
+
* Uses semi-implicit Euler integration for stability.
|
|
62
|
+
*/
|
|
63
|
+
function updateSpring(s, dt) {
|
|
64
|
+
if (s.atRest) return s.value;
|
|
65
|
+
const { stiffness, damping, mass } = s.config;
|
|
66
|
+
const displacement = s.value - s.target;
|
|
67
|
+
const acceleration = (-stiffness * displacement + -damping * s.velocity) / mass;
|
|
68
|
+
s.velocity += acceleration * dt;
|
|
69
|
+
s.value += s.velocity * dt;
|
|
70
|
+
if (Math.abs(s.value - s.target) < REST_THRESHOLD && Math.abs(s.velocity) < VELOCITY_THRESHOLD) {
|
|
71
|
+
s.value = s.target;
|
|
72
|
+
s.velocity = 0;
|
|
73
|
+
s.atRest = true;
|
|
74
|
+
}
|
|
75
|
+
return s.value;
|
|
76
|
+
}
|
|
77
|
+
/** Set a new target for the spring. Wakes it if at rest. */
|
|
78
|
+
function setSpringTarget(s, target) {
|
|
79
|
+
s.target = target;
|
|
80
|
+
s.atRest = false;
|
|
81
|
+
}
|
|
82
|
+
/** Reset both value and target, zeroing velocity. */
|
|
83
|
+
function resetSpring(s, value) {
|
|
84
|
+
s.value = value;
|
|
85
|
+
s.target = value;
|
|
86
|
+
s.velocity = 0;
|
|
87
|
+
s.atRest = true;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/sprite-animator.ts
|
|
91
|
+
/** Create a sprite animator state bound to a sprite sheet. */
|
|
2
92
|
function createSpriteAnimator(sheet) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
93
|
+
return {
|
|
94
|
+
sheet,
|
|
95
|
+
currentAnimation: null,
|
|
96
|
+
frameIndex: 0,
|
|
97
|
+
elapsed: 0,
|
|
98
|
+
paused: false,
|
|
99
|
+
finished: false
|
|
100
|
+
};
|
|
11
101
|
}
|
|
102
|
+
/** Play a named animation. Resets to frame 0. */
|
|
12
103
|
function playAnimation(state, name) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
state.finished = false;
|
|
104
|
+
if (!state.sheet.animations.get(name)) return;
|
|
105
|
+
state.currentAnimation = name;
|
|
106
|
+
state.frameIndex = 0;
|
|
107
|
+
state.elapsed = 0;
|
|
108
|
+
state.paused = false;
|
|
109
|
+
state.finished = false;
|
|
20
110
|
}
|
|
111
|
+
/** Stop the current animation. */
|
|
21
112
|
function stopAnimation(state) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
113
|
+
state.currentAnimation = null;
|
|
114
|
+
state.frameIndex = 0;
|
|
115
|
+
state.elapsed = 0;
|
|
116
|
+
state.paused = false;
|
|
117
|
+
state.finished = false;
|
|
27
118
|
}
|
|
119
|
+
/** Pause the current animation. */
|
|
28
120
|
function pauseAnimation(state) {
|
|
29
|
-
|
|
121
|
+
state.paused = true;
|
|
30
122
|
}
|
|
123
|
+
/** Resume the current animation. */
|
|
31
124
|
function resumeAnimation(state) {
|
|
32
|
-
|
|
125
|
+
state.paused = false;
|
|
33
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Tick the animator forward by dt seconds.
|
|
129
|
+
* Returns the current SpriteFrame, or null if no animation is playing.
|
|
130
|
+
*/
|
|
34
131
|
function updateAnimator(state, dt) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return getCurrentFrame(state);
|
|
132
|
+
if (!state.currentAnimation || state.paused || state.finished) return getCurrentFrame(state);
|
|
133
|
+
const seq = state.sheet.animations.get(state.currentAnimation);
|
|
134
|
+
if (!seq || seq.frameIndices.length === 0) return null;
|
|
135
|
+
if (seq.frameDuration <= 0) throw new Error("updateAnimator: frameDuration must be > 0");
|
|
136
|
+
state.elapsed += dt;
|
|
137
|
+
while (state.elapsed >= seq.frameDuration) {
|
|
138
|
+
state.elapsed -= seq.frameDuration;
|
|
139
|
+
state.frameIndex++;
|
|
140
|
+
if (state.frameIndex >= seq.frameIndices.length) if (seq.loop) state.frameIndex = 0;
|
|
141
|
+
else {
|
|
142
|
+
state.frameIndex = seq.frameIndices.length - 1;
|
|
143
|
+
state.finished = true;
|
|
144
|
+
state.elapsed = 0;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return getCurrentFrame(state);
|
|
56
149
|
}
|
|
150
|
+
/** Get the current SpriteFrame without advancing time. */
|
|
57
151
|
function getCurrentFrame(state) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
152
|
+
if (!state.currentAnimation) return null;
|
|
153
|
+
const seq = state.sheet.animations.get(state.currentAnimation);
|
|
154
|
+
if (!seq || seq.frameIndices.length === 0) return null;
|
|
155
|
+
const globalIdx = seq.frameIndices[state.frameIndex];
|
|
156
|
+
if (globalIdx === void 0) return null;
|
|
157
|
+
return state.sheet.frames[globalIdx] ?? null;
|
|
64
158
|
}
|
|
65
|
-
|
|
66
|
-
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/step-sequence.ts
|
|
161
|
+
function createStepSequence(steps) {
|
|
162
|
+
if (steps.length === 0) throw new Error("createStepSequence: steps must not be empty");
|
|
163
|
+
for (let i = 0; i < steps.length; i++) if ((steps[i]?.duration ?? 0) <= 0) throw new Error("createStepSequence: each step duration must be > 0");
|
|
164
|
+
return {
|
|
165
|
+
steps,
|
|
166
|
+
current: 0,
|
|
167
|
+
elapsed: 0
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function tickStepSequence(seq, dt) {
|
|
171
|
+
seq.elapsed += dt;
|
|
172
|
+
while (seq.elapsed >= (seq.steps[seq.current]?.duration ?? 0)) {
|
|
173
|
+
seq.elapsed -= seq.steps[seq.current].duration;
|
|
174
|
+
seq.current = (seq.current + 1) % seq.steps.length;
|
|
175
|
+
}
|
|
176
|
+
return seq.current;
|
|
177
|
+
}
|
|
178
|
+
function resetStepSequence(seq) {
|
|
179
|
+
seq.current = 0;
|
|
180
|
+
seq.elapsed = 0;
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/timed-modifier.ts
|
|
184
|
+
function createTimedModifier(value, duration, combine) {
|
|
185
|
+
if (duration <= 0) throw new Error("createTimedModifier: duration must be > 0");
|
|
186
|
+
return {
|
|
187
|
+
value,
|
|
188
|
+
combine,
|
|
189
|
+
remaining: duration
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function tickModifier(mod, dt) {
|
|
193
|
+
mod.remaining = mod.remaining - dt < 0 ? 0 : mod.remaining - dt;
|
|
194
|
+
}
|
|
195
|
+
function isModifierActive(mod) {
|
|
196
|
+
return mod.remaining > 0;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Returns combine(base, mod.value) when active, base otherwise.
|
|
200
|
+
* Zero-alloc only when T is number and combine is pure arithmetic.
|
|
201
|
+
*/
|
|
202
|
+
function applyModifier(base, mod) {
|
|
203
|
+
return mod.remaining > 0 ? mod.combine(base, mod.value) : base;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/tween.ts
|
|
207
|
+
/** Linear easing fallback. */
|
|
67
208
|
function linearEasing(t) {
|
|
68
|
-
|
|
209
|
+
return t;
|
|
69
210
|
}
|
|
211
|
+
/** Create a tween. */
|
|
70
212
|
function tween(from, to, duration, easing) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
213
|
+
return {
|
|
214
|
+
from,
|
|
215
|
+
to,
|
|
216
|
+
duration,
|
|
217
|
+
easing: easing ?? linearEasing,
|
|
218
|
+
elapsed: 0,
|
|
219
|
+
value: from,
|
|
220
|
+
done: false,
|
|
221
|
+
onComplete: null,
|
|
222
|
+
next: null
|
|
223
|
+
};
|
|
82
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Update a tween by dt seconds. Returns the current value.
|
|
227
|
+
* When complete, triggers onComplete callback and advances to chained tween.
|
|
228
|
+
*/
|
|
83
229
|
function updateTween(tw, dt) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
230
|
+
if (tw.done) return tw.value;
|
|
231
|
+
tw.elapsed += dt;
|
|
232
|
+
if (tw.elapsed >= tw.duration) {
|
|
233
|
+
tw.elapsed = tw.duration;
|
|
234
|
+
tw.value = tw.to;
|
|
235
|
+
tw.done = true;
|
|
236
|
+
tw.onComplete?.();
|
|
237
|
+
return tw.value;
|
|
238
|
+
}
|
|
239
|
+
const t = tw.elapsed / tw.duration;
|
|
240
|
+
tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);
|
|
241
|
+
return tw.value;
|
|
96
242
|
}
|
|
243
|
+
/** Chain another tween to run after this one completes. Returns the chained tween. */
|
|
97
244
|
function chainTween(tw, next) {
|
|
98
|
-
|
|
99
|
-
|
|
245
|
+
tw.next = next;
|
|
246
|
+
return next;
|
|
100
247
|
}
|
|
248
|
+
/** Reset a tween to its initial state. */
|
|
101
249
|
function resetTween(tw) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
250
|
+
tw.elapsed = 0;
|
|
251
|
+
tw.value = tw.from;
|
|
252
|
+
tw.done = false;
|
|
105
253
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var VELOCITY_THRESHOLD = 1e-3;
|
|
110
|
-
function spring(value, target, config) {
|
|
111
|
-
return {
|
|
112
|
-
value,
|
|
113
|
-
velocity: 0,
|
|
114
|
-
target,
|
|
115
|
-
config: {
|
|
116
|
-
stiffness: config?.stiffness ?? 100,
|
|
117
|
-
damping: config?.damping ?? 10,
|
|
118
|
-
mass: config?.mass ?? 1
|
|
119
|
-
},
|
|
120
|
-
atRest: value === target
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function updateSpring(s, dt) {
|
|
124
|
-
if (s.atRest) return s.value;
|
|
125
|
-
const { stiffness, damping, mass } = s.config;
|
|
126
|
-
const displacement = s.value - s.target;
|
|
127
|
-
const springForce = -stiffness * displacement;
|
|
128
|
-
const dampingForce = -damping * s.velocity;
|
|
129
|
-
const acceleration = (springForce + dampingForce) / mass;
|
|
130
|
-
s.velocity += acceleration * dt;
|
|
131
|
-
s.value += s.velocity * dt;
|
|
132
|
-
if (Math.abs(s.value - s.target) < REST_THRESHOLD && Math.abs(s.velocity) < VELOCITY_THRESHOLD) {
|
|
133
|
-
s.value = s.target;
|
|
134
|
-
s.velocity = 0;
|
|
135
|
-
s.atRest = true;
|
|
136
|
-
}
|
|
137
|
-
return s.value;
|
|
138
|
-
}
|
|
139
|
-
function setSpringTarget(s, target) {
|
|
140
|
-
s.target = target;
|
|
141
|
-
s.atRest = false;
|
|
142
|
-
}
|
|
143
|
-
function resetSpring(s, value) {
|
|
144
|
-
s.value = value;
|
|
145
|
-
s.target = value;
|
|
146
|
-
s.velocity = 0;
|
|
147
|
-
s.atRest = true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/tween-manager.ts
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/tween-manager.ts
|
|
256
|
+
/** Create a new TweenManager. */
|
|
151
257
|
function createTweenManager() {
|
|
152
|
-
|
|
258
|
+
return { tweens: [] };
|
|
153
259
|
}
|
|
260
|
+
/** Add a tween to the manager. */
|
|
154
261
|
function addTween(mgr, tw) {
|
|
155
|
-
|
|
262
|
+
mgr.tweens.push(tw);
|
|
156
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Update all managed tweens by dt seconds.
|
|
266
|
+
* Completed tweens are removed; chained tweens replace completed ones.
|
|
267
|
+
*/
|
|
157
268
|
function updateTweens(mgr, dt) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
i++;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
269
|
+
const tweens = mgr.tweens;
|
|
270
|
+
let i = 0;
|
|
271
|
+
while (i < tweens.length) {
|
|
272
|
+
const tw = tweens[i];
|
|
273
|
+
updateTween(tw, dt);
|
|
274
|
+
if (tw.done) if (tw.next) {
|
|
275
|
+
tweens[i] = tw.next;
|
|
276
|
+
i++;
|
|
277
|
+
} else {
|
|
278
|
+
tweens[i] = tweens[tweens.length - 1];
|
|
279
|
+
tweens.pop();
|
|
280
|
+
}
|
|
281
|
+
else i++;
|
|
282
|
+
}
|
|
175
283
|
}
|
|
284
|
+
/** Remove all tweens. */
|
|
176
285
|
function clearTweens(mgr) {
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/periodic.ts
|
|
181
|
-
import { easeInOutSine } from "@flare-engine/math";
|
|
182
|
-
function periodicTween(from, to, period, easing = easeInOutSine) {
|
|
183
|
-
if (period <= 0) throw new Error("periodicTween: period must be > 0");
|
|
184
|
-
return { from, to, period, easing, elapsed: 0, value: from };
|
|
185
|
-
}
|
|
186
|
-
function updatePeriodicTween(tw, dt) {
|
|
187
|
-
tw.elapsed = (tw.elapsed + dt) % tw.period;
|
|
188
|
-
const halfPeriod = tw.period * 0.5;
|
|
189
|
-
const halfPhase = tw.elapsed / halfPeriod;
|
|
190
|
-
const t = halfPhase <= 1 ? halfPhase : 2 - halfPhase;
|
|
191
|
-
tw.value = tw.from + (tw.to - tw.from) * tw.easing(t);
|
|
192
|
-
return tw.value;
|
|
193
|
-
}
|
|
194
|
-
function resetPeriodicTween(tw) {
|
|
195
|
-
tw.elapsed = 0;
|
|
196
|
-
tw.value = tw.from;
|
|
286
|
+
mgr.tweens.length = 0;
|
|
197
287
|
}
|
|
288
|
+
//#endregion
|
|
289
|
+
export { addTween, applyModifier, chainTween, clearTweens, createSpriteAnimator, createStepSequence, createTimedModifier, createTweenManager, getCurrentFrame, isModifierActive, pauseAnimation, periodicTween, playAnimation, resetPeriodicTween, resetSpring, resetStepSequence, resetTween, resumeAnimation, setSpringTarget, spring, stopAnimation, tickModifier, tickStepSequence, tween, updateAnimator, updatePeriodicTween, updateSpring, updateTween, updateTweens };
|
|
198
290
|
|
|
199
|
-
// src/step-sequence.ts
|
|
200
|
-
function createStepSequence(steps) {
|
|
201
|
-
if (steps.length === 0) throw new Error("createStepSequence: steps must not be empty");
|
|
202
|
-
for (let i = 0; i < steps.length; i++) {
|
|
203
|
-
if ((steps[i]?.duration ?? 0) <= 0)
|
|
204
|
-
throw new Error("createStepSequence: each step duration must be > 0");
|
|
205
|
-
}
|
|
206
|
-
return { steps, current: 0, elapsed: 0 };
|
|
207
|
-
}
|
|
208
|
-
function tickStepSequence(seq, dt) {
|
|
209
|
-
seq.elapsed += dt;
|
|
210
|
-
while (seq.elapsed >= (seq.steps[seq.current]?.duration ?? 0)) {
|
|
211
|
-
seq.elapsed -= seq.steps[seq.current].duration;
|
|
212
|
-
seq.current = (seq.current + 1) % seq.steps.length;
|
|
213
|
-
}
|
|
214
|
-
return seq.current;
|
|
215
|
-
}
|
|
216
|
-
function resetStepSequence(seq) {
|
|
217
|
-
seq.current = 0;
|
|
218
|
-
seq.elapsed = 0;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// src/timed-modifier.ts
|
|
222
|
-
function createTimedModifier(value, duration, combine) {
|
|
223
|
-
if (duration <= 0) throw new Error("createTimedModifier: duration must be > 0");
|
|
224
|
-
return { value, combine, remaining: duration };
|
|
225
|
-
}
|
|
226
|
-
function tickModifier(mod, dt) {
|
|
227
|
-
mod.remaining = mod.remaining - dt < 0 ? 0 : mod.remaining - dt;
|
|
228
|
-
}
|
|
229
|
-
function isModifierActive(mod) {
|
|
230
|
-
return mod.remaining > 0;
|
|
231
|
-
}
|
|
232
|
-
function applyModifier(base, mod) {
|
|
233
|
-
return mod.remaining > 0 ? mod.combine(base, mod.value) : base;
|
|
234
|
-
}
|
|
235
|
-
export {
|
|
236
|
-
addTween,
|
|
237
|
-
applyModifier,
|
|
238
|
-
chainTween,
|
|
239
|
-
clearTweens,
|
|
240
|
-
createSpriteAnimator,
|
|
241
|
-
createStepSequence,
|
|
242
|
-
createTimedModifier,
|
|
243
|
-
createTweenManager,
|
|
244
|
-
getCurrentFrame,
|
|
245
|
-
isModifierActive,
|
|
246
|
-
pauseAnimation,
|
|
247
|
-
periodicTween,
|
|
248
|
-
playAnimation,
|
|
249
|
-
resetPeriodicTween,
|
|
250
|
-
resetSpring,
|
|
251
|
-
resetStepSequence,
|
|
252
|
-
resetTween,
|
|
253
|
-
resumeAnimation,
|
|
254
|
-
setSpringTarget,
|
|
255
|
-
spring,
|
|
256
|
-
stopAnimation,
|
|
257
|
-
tickModifier,
|
|
258
|
-
tickStepSequence,
|
|
259
|
-
tween,
|
|
260
|
-
updateAnimator,
|
|
261
|
-
updatePeriodicTween,
|
|
262
|
-
updateSpring,
|
|
263
|
-
updateTween,
|
|
264
|
-
updateTweens
|
|
265
|
-
};
|
|
266
291
|
//# sourceMappingURL=index.mjs.map
|