Skip to content

Commit

Permalink
Easing fix: use in_tangent from previous key frame
Browse files Browse the repository at this point in the history
  • Loading branch information
atoktoto committed Nov 9, 2024
1 parent 375c80a commit 5e16bce
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/runtime/model/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ impl Time {
let t0 = times[ix0];
let t1 = times[ix1];
let (t0_ox, t0_oy) = t0.out_tangent.map(|o| (o.x, o.y)).unwrap_or((0.0, 0.0));
let (t1_ix, t1_iy) = t1.in_tangent.map(|i| (i.x, i.y)).unwrap_or((1.0, 1.0));
let (t0_ix, t0_iy) = t0.in_tangent.map(|i| (i.x, i.y)).unwrap_or((1.0, 1.0));

Check warning on line 123 in src/runtime/model/value.rs

View workflow job for this annotation

GitHub Actions / typos

"iy" should be "it".
let easing = Easing {
o: EasingHandle { x: t0_ox, y: t0_oy },
i: EasingHandle { x: t1_ix, y: t1_iy },
i: EasingHandle { x: t0_ix, y: t0_iy },

Check warning on line 126 in src/runtime/model/value.rs

View workflow job for this annotation

GitHub Actions / typos

"iy" should be "it".
};
let hold = t0.hold;
let t = (frame - t0.frame) / (t1.frame - t0.frame);
Expand Down Expand Up @@ -160,20 +160,16 @@ pub trait Tween: Clone + Default {
}

impl Tween for f64 {
fn tween(&self, other: &Self, t: f64, _easing: &Easing) -> Self {
// TODO: We are enforcing linear interpolation for now, but a decent amount of work is done for easings.
keyframe::ease(keyframe::functions::Linear, *self, *other, t)

// FIXME: Hopefully we can finish this up one day!
//keyframe::ease(
// keyframe::functions::BezierCurve::from(
// keyframe::mint::Vector2::from_slice(&[easing.o.x, easing.o.y]),
// keyframe::mint::Vector2::from_slice(&[easing.i.x, easing.i.y]),
// ),
// *self,
// *other,
// t,
//)
fn tween(&self, other: &Self, t: f64, easing: &Easing) -> Self {
keyframe::ease(
keyframe::functions::BezierCurve::from(
keyframe::mint::Vector2::from_slice(&[easing.o.x, easing.o.y]),
keyframe::mint::Vector2::from_slice(&[easing.i.x, easing.i.y]),
),
*self,
*other,
t,
)
}
}

Expand Down

0 comments on commit 5e16bce

Please sign in to comment.