Rotation Animation Help

Hey everyone,

I am trying to make an animation that rotates around the local Y axis, however im not sure how i can do that in an animation. Here is my attempt:
https://www.babylonjs-playground.com/indexStable.html#7EYFYW

However this goes by global axis.

I had used a setInterval function to update cube.addRotation() however setInterval is causing some other problems, and i would much rather use babylon animations.

Any ideas how i could do this?

Currently the only way i can think around it is:

Make my own class for a self box, make getter and setter for rotation that can take vector or number, if number is used addRotation is called within the setter, if vector do regular global rotation.

However thats very messy and i was hopoing there is a better way.

Here we are:
https://www.babylonjs-playground.com/indexStable.html#7EYFYW#1

3 Likes

I think that I’ve got stuck in a similar situation, but I’m not sure.

I’ve made this small demo to illustrate the problem: https://playground.babylonjs.com/#KDPAQ9#3768

I want to rotate the wheel around the X axys so it faces the camera and then to animate rotation around the Y axis.
You should uncomment the line below // Uncomment the next line. to see that I cannot achieve this behaviour.

The solution to use a parent TransformNode for the rotation about the x-axis seems to work well in your case too? :slight_smile:

1 Like

Now I understand. :sweat_smile:
Many thanks to you @Blake, the same goes to @Deltakosh for the original solution. :smile:

1 Like