Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eg.animate - Support rotate3d and fix interpolation bug on rotation. #166

Closed
jongmoon opened this issue Mar 25, 2016 · 2 comments
Closed
Assignees
Milestone

Comments

@jongmoon
Copy link
Contributor

Description

2 Things

1. Support rotate3d, rotateX, rotateY, rotateZ

image

AS IS: support only "rotate"

2. Fix interpolation bug on rotating calculation.(matrix)

The AS-IS way to interpolate the value to get an intermediate values is not applicable on rotation.

AS IS way

interpolate: function(m2, t, context) {
    var me = this,
        m  = context ? new Matrix(context) : new Matrix();

    m.a = me.a + (m2.a - me.a) * t;
    m.b = me.b + (m2.b - me.b) * t;
    m.c = me.c + (m2.c - me.c) * t;
    m.d = me.d + (m2.d - me.d) * t;
    m.e = me.e + (m2.e - me.e) * t;
    m.f = me.f + (m2.f - me.f) * t;

    return m._x()
},

I found the solution, It decompose a matrix to transform information(eg. translateX(10px) rotateY(20deg)) but it is not applicable to 3d. We need to check other solution.

@jongmoon jongmoon self-assigned this Mar 25, 2016
@jongmoon
Copy link
Contributor Author

More information about second issue above.

When matrix contains "rotate" or "skew" which have degree value, It can not be interpolated. Interpolation using matrix makes user-unexpected result (That may be expected to computer.)

Below screen-shot shows drawing of movements of box for animate.

rotate-interpolation-error

  • Left one is interpolation using matrix.
  • Right one is interpolation using transform string.

In other words, matrix must be disassembled as a transform string(eg. translateX(10px) rotateY(20deg).

But I couldn't find the solution for decompsing 4x4 matrix(3d) (matrix3d --> transform string)although 3x3 matrix(2d) could be found. Velocity.js library does not solve this problem also. It avoid this problem by below.

  1. It does not support transform order.
    • It follows first order of transform animation.
  2. It does not support absolute transform.
    • It moves from previous state.

So velocity may not act as you expected. How about below ?

image

Is result is same as expected?

image

And several consideration. It can be solved by (matrix * transform string). This will be added later.

@jongmoon
Copy link
Contributor Author

Solution

When these (below) are applied, we may solve the problem.

  • Do not convert from transform string to matrix to make an interpolated value.
  • Instead, combine current position matrix with interpolated transform like a relative(+=) process.
  • Store transform element names which makes current position.
  • When making interpolated transforms, initialize(set 0) value of transform elements stored above.

jongmoon pushed a commit to jongmoon/egjs that referenced this issue Apr 11, 2016
jongmoon pushed a commit to jongmoon/egjs that referenced this issue Apr 11, 2016
jongmoon pushed a commit to jongmoon/egjs that referenced this issue Apr 12, 2016
@jongmoon jongmoon added this to the 1.2.0 milestone Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant