@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.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../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":["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":";AAmBO,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;A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cAAiB,MAAS,KAA0B;AAClE,SAAO,IAAI,YAAY,IAAI,IAAI,QAAQ,MAAM,IAAI,KAAK,IAAI;AAC5D;","names":[]}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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,SAAmB,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,SAAg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;CACZ;CAEA,MAAM,IAAI,GAAG,UAAU,GAAG;CAC1B,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpD,OAAO,GAAG;AACZ;;AAGA,SAAgB,WAAW,IAAW,MAAoB;CACxD,GAAG,OAAO;CACV,OAAO;AACT;;AAGA,SAAgB,WAAW,IAAiB;CAC1C,GAAG,UAAU;CACb,GAAG,QAAQ,GAAG;CACd,GAAG,OAAO;AACZ;;;;AChEA,SAAgB,qBAAmC;CACjD,OAAO,EAAE,QAAQ,CAAC,EAAE;AACtB;;AAGA,SAAgB,SAAS,KAAmB,IAAiB;CAC3D,IAAK,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/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/animation",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Sprite animation, tweens, springs,
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Sprite animation, tweens, springs, step sequences",
|
|
5
5
|
"keywords": ["flare-engine", "animation", "tween", "spring"],
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"author": "Grzegorz Otto",
|
|
8
8
|
"homepage": "https://github.com/grzott/flare-engine#readme",
|
|
9
9
|
"bugs": {
|
|
@@ -19,21 +19,29 @@
|
|
|
19
19
|
"types": "dist/index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
|
-
"files": ["dist", "README.md", "LICENSE"],
|
|
32
|
+
"files": ["dist", "README.md", "LICENSE", "NOTICE"],
|
|
28
33
|
"scripts": {
|
|
29
|
-
"build": "
|
|
34
|
+
"build": "tsdown",
|
|
30
35
|
"test": "bun test",
|
|
31
36
|
"lint": "biome check src/",
|
|
32
37
|
"typecheck": "tsc --noEmit"
|
|
33
38
|
},
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"@flare-engine/assets": "^0.
|
|
36
|
-
"@flare-engine/math": "^0.
|
|
40
|
+
"@flare-engine/assets": "^0.3.0",
|
|
41
|
+
"@flare-engine/math": "^0.3.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=20"
|
|
37
45
|
},
|
|
38
46
|
"publishConfig": {
|
|
39
47
|
"access": "restricted",
|