Api.rotate() not working as expected + problem with reverse rotation?

Hi!

We are currently testing the API to animate some part of our model with basic rotation. This appear to be more complicated then we have predicted.

First of all, we discovered that, maybe, the documentation of the api.rotate() may be out of date:

This line from the documentation will not animate the rotation:

api.rotate(myNode, [Math.PI, 1, 0, 0], 1.0, 'easeOutQuad',function(err, rotateTo) { console.log('Object has been rotated according to', rotateTo);});

But this one will:

api.rotate(myNode, [Math.PI, 1, 0, 0], {duration: 1,easing: 'easeOutQuad'},function( err,rotateTo){console.log('Object has been rotated according to', rotateTo);});	

Also, if we want to do the reverse rotation, it’s not working as expected:

If we change this: [Math.PI, 1, 0, 0] to this [-Math.PI, 1, 0, 0], this will not do the same rotation on the other way. So we can’t do an “open” animation and “close” animation".

Here is a simple demo of our problem.

Also, how can we apply different angle per axis? Why X, Y and Z are not angles specified per axis?
Actually, it is counterintuitive compared to other engine.

Thanks for the documentation bug report!

here’s a sample on how to do it, mostly using node matrix to get the correct angle axis to be able to revert.

Note the “suzanne” boolean that should help testing on a simpler model.

Also, how can we apply different angle per axis? Why X, Y and Z are not angles specified per axis?
Actually, it is counterintuitive compared to other engine.

The sample linked shows how to extract angle, x, y, z from an arbitrary matrix, that should help solve that case.
Could you link to what other engine API does so we can compare ?

1 Like

Hey thank you for you Fiddle! This help a lot.

Could you link to what other engine API does so we can compare ?

We were thinking about game engines (Unity, Unreal, Playcanvas, others) that offers simple function like this:

cube1.transform.Rotate(xAngle, yAngle, zAngle, Space.World); Source

That way, you have a direct control on each axis and the engine handle everything behind.
The only things with these engines is that you have to call the rotate function in loop for the animation.