# rotationQuaternion only update the last value why?

**URL:** <https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567>\
**Category:** Questions\
**Created:** [July 16, 2020, 9:28pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567 "2020-07-16T21:28:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajid](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@wajid](https://forum.babylonjs.com/u/wajid)\
**Post date:** [July 16, 2020, 9:28pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/1 "2020-07-16T21:28:58Z")

</div>

Hi EveryOne.

I have scenario where i want to change my object x,y,z world. so what i am doing is to rotate object by 90 degree on y-axis and then rotate it on x-axis with 90 degree.By doing so i get my object at desired x,y,z.  
But rotating by using rotationQuaternion only rotate by x-axis not y-axis. why this happening?  
[PG](https://www.babylonjs-playground.com/#6XIN1E)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Raggar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raggar/32/20672_2.png) [@Raggar](https://forum.babylonjs.com/u/Raggar)\
**Post date:** [July 16, 2020, 10:11pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/2 "2020-07-16T22:11:34Z")

</div>

```
box.rotationQuaternion = new BABYLON.Quaternion.RotationAxis(new BABYLON.Vector3(0, 1, 0),Math.PI/2);
box.rotationQuaternion = new BABYLON.Quaternion.RotationAxis(new BABYLON.Vector3(1, 0, 0),Math.PI/2,BABYLON.Space.LOCAL);

```

Every time you say `box.rotationQuaternion =` you assign a new quaternion. So on the second line you ignore the first quaternion and overwrite it with the new one, so only the y-axis is rotated.

You could rotate the mesh instead:  
[https://www.babylonjs-playground.com/#6XIN1E#1](https://www.babylonjs-playground.com/#6XIN1E#1)

---

<div class="post-metadata">

**Author:** ![wajid](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@wajid](https://forum.babylonjs.com/u/wajid)\
**Post date:** [July 17, 2020, 10:56am UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/3 "2020-07-17T10:56:31Z")

</div>

Thanks @Raggar

Actually i have tried with rotation it works fine. But the my problem is that i receive Quaternion values from somewhere outside and then update the geometry. I have convert Quaternion to Axis-agnle and then rotate object works fine. But then its keep rotating for same value again and again.  
For example. I receive continues values to update the rotation of box. first i received to ratate y-axis by 90 degree then same value agian and agian. What i want is rotate the box only with new values. The box should only rotate if the value is different from current position. Sorry if it doesn’t sound very clear.  
Thanks for your time.

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [July 17, 2020, 12:28pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/4 "2020-07-17T12:28:31Z")

</div>

For clarity are the quaternion values you receive giving a change in orientation or a new orientation?

---

<div class="post-metadata">

**Author:** ![wajid](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@wajid](https://forum.babylonjs.com/u/wajid)\
**Post date:** [July 17, 2020, 1:08pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/5 "2020-07-17T13:08:43Z")

</div>

@JohnK  
Lets say i have physical rotating disc. I receive Quaternion(x,y,z,w) value of this disc every 100ms. At beginning my Desk is at (0,0,0,0). now i change my desk orientation to (.2,.3,.5,.002) and i will receive this value every 100ms. So if i use mes.rotation(.2,.3,.5,.002) mesh will keep rotating with this value in every 100ms. I want only to rotate it from (0,0,0,0) to (.2,.3,.5,.002) and then should stay there at (.2,.3,.5,.002) unless until physical disc rotation change again.  
All Quaternion value i received are when disc rotate it give new orientation with respect to origin of the desk.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 17, 2020, 2:19pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/6 "2020-07-17T14:19:32Z")

</div>

It seems you need to interpolate between one quaternion to another:

[https://www.babylonjs-playground.com/#6XIN1E#3](https://www.babylonjs-playground.com/#6XIN1E#3)

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [July 17, 2020, 2:41pm UTC](https://forum.babylonjs.com/t/rotationquaternion-only-update-the-last-value-why/12567/7 "2020-07-17T14:41:36Z")

</div>

The array simulates received quaternions. [https://www.babylonjs-playground.com/#6XIN1E#4](https://www.babylonjs-playground.com/#6XIN1E#4)
