aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2016-06-27 08:04:55 -0700
committerMichael Howell <michael@notriddle.com>2016-06-28 17:19:34 -0700
commit0dd99e6bd27e9463817ba6acf4a789d82fef3ea7 (patch)
tree3d7770c036360dea22c6f3ab70749db34bed73a0
parentcab6260c3242d7a5c02e80144336594f1f1afafb (diff)
downloadservo-0dd99e6bd27e9463817ba6acf4a789d82fef3ea7.tar.gz
servo-0dd99e6bd27e9463817ba6acf4a789d82fef3ea7.zip
Normalize the direction vector for rotate
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index b5a2eaef532..55ea436b5da 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -664,6 +664,10 @@ fn interpolate_transform_list(from_list: &[TransformOperation],
}
(&TransformOperation::Rotate(fx, fy, fz, fa),
&TransformOperation::Rotate(tx, ty, tz, ta)) => {
+ let norm_f = ((fx * fx) + (fy * fy) + (fz * fz)).sqrt();
+ let norm_t = ((tx * tx) + (ty * ty) + (tz * tz)).sqrt();
+ let (fx, fy, fz) = (fx / norm_f, fy / norm_f, fz / norm_f);
+ let (tx, ty, tz) = (tx / norm_t, ty / norm_t, tz / norm_t);
if fx == tx && fy == ty && fz == tz {
let ia = fa.interpolate(&ta, time).unwrap();
result.push(TransformOperation::Rotate(fx, fy, fz, ia));