Skip to content

[Feature] Animation clip and keyframes #159

@vmarcella

Description

@vmarcella

Overview

Add keyframe-based animation clips that can animate multiple properties with
independent timing.

Current State

No response

Scope

Goals:

  • Define keyframes with time and value
  • Interpolate between keyframes
  • Support multiple tracks (properties) per clip
  • Per-track easing options

Non-Goals:

  • Animation blending
  • Skeletal animation
  • Visual animation editor

Proposed API

pub struct Keyframe<T> {
  pub time: f32,
  pub value: T,
  pub easing: Easing,
}

pub struct AnimationTrack<T> {
  keyframes: Vec<Keyframe<T>>,
}

impl<T: Lerp + Clone> AnimationTrack<T> {
  pub fn new() -> Self;
  pub fn add_keyframe(&mut self, time: f32, value: T, easing: Easing);
  pub fn sample(&self, time: f32) -> T;
  pub fn duration(&self) -> f32;
}

pub struct AnimationClip {
  tracks: HashMap<String, Box<dyn AnyTrack>>,
  duration: f32,
}

impl AnimationClip {
  pub fn new() -> Self;
  pub fn add_track<T: 'static>(&mut self, name: &str, track: AnimationTrack<T>);
  pub fn sample<T: 'static>(&self, name: &str, time: f32) -> Option<T>;
  pub fn duration(&self) -> f32;
}

Acceptance Criteria

  • Keyframes sample correctly at exact times
  • Interpolation works between keyframes
  • Multiple tracks in one clip
  • Tracks can have different durations
  • Before first / after last keyframe handled

Affected Crates

lambda-rs

Notes

  • Type-erased tracks for heterogeneous clips
  • Consider animation asset format

Metadata

Metadata

Assignees

No one assigned

    Labels

    animationAll things related to animationsenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions