# Inspector rotation quaterning bugging out

**URL:** <https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648>\
**Category:** Bugs\
**Created:** [April 17, 2019, 4:37pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648 "2019-04-17T16:37:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leon/32/30387_2.png) [@Leon](https://forum.babylonjs.com/u/Leon)\
**Post date:** [April 17, 2019, 4:37pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/1 "2019-04-17T16:37:24Z")

</div>

When rotating a loaded gltf cube the quaternion is causing the cube to get distorted.

There seems to be a bug causing the rotation to also scale the cube.

### To reproduce

Drag and drop this gltf which is a simple cube with no rotation or position.

the quaternion gets set to 0,0,0,1

Then try spinning the cube with the inspector changing any of the x,y,z parameters and you should see it get all distorted.

[cube.gltf.zip](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/7dd7a9ba9f09b33c218c47c27787de2a245d2be5.zip) (1.3 KB)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 17, 2019, 4:40pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/2 "2019-04-17T16:40:48Z")

</div>

This is not a bug 🙂 but how quaternions works.  
A quaternion can store a matrix so it could store rotation AND scaling. so if you randomly change x y or z then you may end up with a non rotation quaternion

---

<div class="post-metadata">

**Author:** ![Leon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leon/32/30387_2.png) [@Leon](https://forum.babylonjs.com/u/Leon)\
**Post date:** [April 17, 2019, 5:16pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/3 "2019-04-17T17:16:57Z")

</div>

Is quaternions different between blender and babylonjs?

In blender i set the rotation mode to quaternion, and then try to change the x,y,z without changing W.  
when i do that only the rotation of the cube changes with no distortion.

But when i do it in babylon everything goes haywire.

Maybe the coupling between the inspector and the quaternion is doing something funky?

---

<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:** [April 17, 2019, 5:42pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/4 "2019-04-17T17:42:40Z")

</div>

A quaternion has the form a + x_i_ + y_j_ +z_k_ and not all quaternions are rotation quaternions.

A rotation quaternion should be a unit quaternion.

Here is an example with the quaternion randomized and normalized to produce a unit quaternion

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

and hence the box rotates as expected. ie as DK stated you no longer have scaling. Lose the normalize and you will get distortions. Blender must internally normalize the quaternion before rendering.

---

<div class="post-metadata">

**Author:** ![Leon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leon/32/30387_2.png) [@Leon](https://forum.babylonjs.com/u/Leon)\
**Post date:** [April 17, 2019, 5:56pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/5 "2019-04-17T17:56:29Z")

</div>

So in our case we should normalize the quaternion on update from the inspector so it feels more natural?  
Or what do you think?

---

<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:** [April 17, 2019, 6:02pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/6 "2019-04-17T18:02:27Z")

</div>

This is a question for @Deltakosh there may be good reason to keep quaternions not just as rotation quaternions.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 17, 2019, 6:38pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/7 "2019-04-17T18:38:52Z")

</div>

Well no good reason just wanted to let everyone input what they want. I can force a normalization but then the UI will be weird as values will change after user input ends

---

<div class="post-metadata">

**Author:** ![Leon](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leon/32/30387_2.png) [@Leon](https://forum.babylonjs.com/u/Leon)\
**Post date:** [April 17, 2019, 6:52pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/8 "2019-04-17T18:52:03Z")

</div>

Or we change so the inspector uses degrees which is easier to manipulate.  
Or maybe a drop down where you can choose between radians, degrees, and quaternion.

That way you can view the data how ever you want.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 17, 2019, 9:41pm UTC](https://forum.babylonjs.com/t/inspector-rotation-quaterning-bugging-out/2648/9 "2019-04-17T21:41:04Z")

</div>

you can force the system touse rotation in rad by setting mesh.rotationQuaternion = null
