rotateAround and get back to initial position

How can we rotate a mesh around a position, increment and decrement the rotate speed and get back to its initial position?

box.registerAfterRender((e) => {
    box.rotateAround(BABYLON.Vector3.Zero(), axis, speed);

    if (forward && speed < 1) {
        speed += step;
    } else if (speed > 0) {
        forward = false;
        speed -= step;
    }
});

Initial position:
Screenshot from 2021-12-23 21-27-17

Final position (Wrong):
Screenshot from 2021-12-23 21-27-00

You should check the rotation instead of the speed to be sure of where the box is ?

An easier way IMO is to set the mesh’s pivot point to the point that you want to rotate around and then use the createAndStartAnimation helper to simply animate rotation.x from 0 to numRotations * TwoPi, with ease in and ease out. Below for example you can adjust the value 40 to adjust the speed and change the value 5 to however many full 360 degree rotations you want. :slightly_smiling_face: :beers:

Thanks @Blake this is exactly what I want :grin:
Based on your description and code, I did a function to set rotation animation to any mesh around a Point:

:santa: MERRY CHRISTMAS TO YOU ALL! :christmas_tree:

Yeah, I realize later that where I treat as “speed” was the angle, and that the rotateAround is cumulative, so, off course, values like 1 and 0 are not compatible with the final angle.
Many thanks! :slight_smile: