# Perfect Camera Rotation Animation

**URL:** <https://forum.babylonjs.com/t/perfect-camera-rotation-animation/12944>\
**Category:** Questions\
**Tags:** documentation, tutorial\
**Created:** [July 28, 2020, 2:34pm UTC](https://forum.babylonjs.com/t/perfect-camera-rotation-animation/12944 "2020-07-28T14:34:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vijayxd](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vijayxd/32/4536_2.png) [@Vijayxd](https://forum.babylonjs.com/u/Vijayxd)\
**Post date:** [July 28, 2020, 2:34pm UTC](https://forum.babylonjs.com/t/perfect-camera-rotation-animation/12944/1 "2020-07-28T14:34:42Z")

</div>

[https://www.babylonjs-playground.com/#B2GLWZ#1](https://www.babylonjs-playground.com/#B2GLWZ#1)

the above example is prototype we are working on a project.

when you click on navigation point(arrows) camera rotation and position will be animated.

works fine on initial camera rotation.

some cases (spin camera 3-4 times 360 degrees in one direction) camera rotation y will change above 14 or - 14.

after click on any navigation point its spinning like TOP TOY.

how to calculate nearest Y angle value to animate perfectly.

Thank you

---

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [July 31, 2020, 8:35pm UTC](https://forum.babylonjs.com/t/perfect-camera-rotation-animation/12944/2 "2020-07-31T20:35:25Z")

</div>

Hi Vijayxd,

I think the issues you were describing are just edge cases with dealing with winding and unwinding over-large Y rotations. I noticed you already had some code in place that seemed to be checking for this issue, so I augmented it slightly to handle a few additional scenarios (prominently negative rotations) on new lines 72 through 82. Is this behavior closer to what you’re going for?

[https://www.babylonjs-playground.com/#B2GLWZ#2](https://www.babylonjs-playground.com/#B2GLWZ#2)

Best of luck!

---

<div class="post-metadata">

**Author:** ![Vijayxd](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vijayxd/32/4536_2.png) [@Vijayxd](https://forum.babylonjs.com/u/Vijayxd)\
**Post date:** [August 1, 2020, 2:08am UTC](https://forum.babylonjs.com/t/perfect-camera-rotation-animation/12944/3 "2020-08-01T02:08:34Z")

</div>

easy & perfect solution
