Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRotate animation #11873
Rotate animation #11873
Conversation
highfive
commented
Jun 26, 2016
|
Heads up! This PR modifies the following files:
|
| let ia = fa.interpolate(&ta, time).unwrap(); | ||
| result.push(TransformOperation::Rotate(fx, fy, fz, ia)); | ||
| } else { | ||
| // TODO(gw): Implement matrix decomposition and interpolation |
This comment has been minimized.
This comment has been minimized.
dzbarsky
Jun 26, 2016
Member
We should try to interpolate component-by-component when we can, see https://drafts.csswg.org/css-transforms-1/#interpolation-of-transform-functions
Specifically, "For interpolations with the primitive rotate3d(), the direction vectors of the transform functions get normalized first. If the normalized vectors are equal, the rotation angle gets interpolated numerically. Otherwise the transform functions get converted into 4x4 matrices first and interpolated as defined in section Interpolation of Matrices afterwards."
| 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)); |
This comment has been minimized.
This comment has been minimized.
dzbarsky
Jun 28, 2016
Member
I wonder if the spec says anything about what the interpolated values for the direction vector should be...script can see this, right? Worth checking what other browsers do and adding a test if you're feeling particularly pedantic
This comment has been minimized.
This comment has been minimized.
notriddle
Jun 28, 2016
Author
Contributor
It says that, if the direction vectors normalize to be the same thing, just interpolate the angle. It doesn't say what to do with the direction vector in the meantime.
If they're different, it says to do the matrix conversion.
|
|
|
r? @glennw |
|
@bors-servo r+ |
|
|
|
|
Rotate animation Add rotation interpolation code for the case where their direction vectors are equal. ___ - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11808 (github issue number if applicable). - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11873) <!-- Reviewable:end -->
|
|
notriddle commentedJun 26, 2016
•
edited by larsbergstrom
Add rotation interpolation code for the case where their direction vectors are equal.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is