How to use api.rotate()?


(Mintmedia) #1

I need to use undocumented api.rotate() function.

rotate( [nodeID], [rotateTo], [duration], [easing], [callback] )

My question is:. what should I use as a second parameter [rotateTo]? I tried nearly everything and nothing works. I need to rotate one node horizontally by 270 degrees.


(Mauricesvay) #2

@mintmedia rotateTo is a 4 dimension array containing angle (in radian), xAxis, yAxis, zAxis.


(Mintmedia) #3

Thank you for the reply. I tried to use the array but unfortunately nothing works for me. Could you give me some examples?

I tried to rotate a node by 270 degrees using X axis. This code

api.rotate(nodeId, [Math.PI*3/2, 1, 0, 0], 1, 'ease', function(){
console.log('callabck');
});

doesn't work properly. What am I doing wrong?


(Mauricesvay) #4

Hi,

the rotate api is now documented here: https://sketchfab.com/developers/viewer/functions#api-rotate

Here's a working example:

A few things you can check in your code:

  • Make sure the rotation is applied to a MatrixTransfrom node
  • Make sure the rotation is applied to the right variable, this can be tricky in JavaScript when looping over a collection

If you can post a link to some code and the model you're trying to manipulate, that could help.


(Mintmedia) #5

Hi,

thank you very much for the answer. Something has to be wrong with my model ( ec2a817b8a9c42128d9522231ea22b8c ):