# Rotations from Blender don't match up with Babylon

**URL:** <https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659>\
**Category:** Questions\
**Created:** [September 14, 2019, 7:13pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659 "2019-09-14T19:13:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigrig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bigrig/32/5548_2.png) [@bigrig](https://forum.babylonjs.com/u/bigrig)\
**Post date:** [September 14, 2019, 7:13pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/1 "2019-09-14T19:13:19Z")

</div>

Any idea why rotations from Blender, when entered exactly the same in Babylon would produce different results?

To demonstrate, I just made a simple box in Blender and rotated it. Then exported as GLB, opened in sandbox and then entered in the quaternion values. Rotation is different as you can see in screenshot.

Is it b/c Blender does WXYZ and Babylon does XYZW?

 ![32%20PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/b/b12e3a5140cd5c35f3a111d17e8c322b3dcac0da.jpeg)

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [September 15, 2019, 12:21am UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/2 "2019-09-15T00:21:48Z")

</div>

> [@bigrig](#):
>
> Is it b/c Blender does WXYZ and Babylon does XYZW?

Looks like it is that. In Blender the W axis is the first value taken into account in the X axis in Babylon and produces this shift.

It’s probably a bug of the exporter Blender I suppose. Can be exported without using Quaternion will solve your problem if using Euler suits you. (The time that this bug is fixed)

---

<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:** [September 16, 2019, 3:37pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/3 "2019-09-16T15:37:32Z")

</div>

pinging @JCPalmer or @Vinc3r or @gryff (the Blender Clan :))

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [September 16, 2019, 4:32pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/4 "2019-09-16T16:32:11Z")

</div>

Are you sure it’s an issue? Blender is Z-up while BJS is Y-up, so it looks like logic to me as I can guess from the screenshot.

---

<div class="post-metadata">

**Author:** ![bigrig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bigrig/32/5548_2.png) [@bigrig](https://forum.babylonjs.com/u/bigrig)\
**Post date:** [September 16, 2019, 4:38pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/5 "2019-09-16T16:38:10Z")

</div>

So to set up the scene in BJS so that it mirrors the scene in Blender, one would do what? Like, to make a function called “MirrorBlender” it would require what - a reorientation of the camera? Or some kind of Z to Y up conversion?

Btw, the issue i’m trying to address is getting poses in BJS to match what I see in Blender. I’m getting legs pointing straight up in the air and twisted around the wrong way. Just trying to figure out how the heck I can get a pose in BJS to match what I see in Blender.

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [September 16, 2019, 5:34pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/6 "2019-09-16T17:34:44Z")

</div>

When using the .babylon / JSON exporter, a quaternion is writing using:

```python
def format_quaternion(quaternion, precision = FLOAT_PRECISION_DEFAULT):
    fmt = '%.' + str(precision) + 'f'
    return format_float(quaternion.x, fmt) + ',' + format_float(quaternion.z, fmt) + ',' + format_float(quaternion.y, fmt) + ',' + format_float(-quaternion.w, fmt)

```

If you cannot read python, basically the z & y are flipped, and the sign is switched for w. I am not sure whether glTF is y or z up, but if it is y up, shouldn’t the BJS importer be doing the switch?

---

<div class="post-metadata">

**Author:** ![gryff](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gryff/32/1855_2.png) [@gryff](https://forum.babylonjs.com/u/gryff)\
**Post date:** [September 16, 2019, 6:39pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/7 "2019-09-16T18:39:03Z")

</div>

Well, I created a simplecube and rotated it on the Y axis and then exported it from Blender 2.80 as a .babylon file and and a glb file.

For the .glb export there is a little check box that allows you to export with “+y up”. @JCPalmer 's Babylon exporter does it automatically which is why I always use it 🙂

Below is an image showing the two exports. Note that both rotations are around the Z-axis as would be expected.

Please try it yourself see if you get the same results

As for

> [@bigrig](#):
>
> I’m getting legs pointing straight up in the air and twisted around the wrong way

With the babylon export that usually means that there scale/rotation differences between the rig and the mesh(es). Not sure how the glb exporter works with that.

cheers, gryff 🙂

@Deltakosh : PS: Looks like all the old clan is out on this 😁

 ![combo1](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/6/62fb9572a633994813433942e1acd96c6f235262.png)

---

<div class="post-metadata">

**Author:** ![bigrig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bigrig/32/5548_2.png) [@bigrig](https://forum.babylonjs.com/u/bigrig)\
**Post date:** [September 17, 2019, 4:49am UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/8 "2019-09-17T04:49:13Z")

</div>

Didn’t get a chance to try the cube experiment yet… but the alternate ordering and any other ordering is giving me a jumble of body parts (see my poor guy below). Maybe I can’t simply set the rotation quaternions to the values in the matrix in the .babylon files? Beginning to think this approach is doomed.

All of these result in a jumble:  
// tnodes[bonename].rotationQuaternion=new BABYLON.Quaternion(m[0],m[1],m[2],m[3]);  
//tnodes[bonename].rotationQuaternion=new BABYLON.Quaternion(m[4],m[5],m[6],m[7]);  
//tnodes[bonename].rotationQuaternion=new BABYLON.Quaternion(m[9],m[10],m[11],m[8]);  
//tnodes[bonename].rotationQuaternion=new BABYLON.Quaternion(m[5],m[6],m[7],m[4]);  
tnodes[bonename].rotationQuaternion=new BABYLON.Quaternion(m[5],m[7],m[6],-m[4]);

 ![17%20PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/e/e0dfcefa89b72e44d60fa9130bf3978b56bceadd.png)

Where the matrix is in Json as follows (in the values array below). I’m just looping through all of the transform nodes for frame 1 - and setting the rotation values - to try to re-create a pose… and to animate the character from a data file (since i can’t get any of the animation functions working with GLBs unless i combine all animations into a single GLB… which is impractical for my use case).

 ![26%20PM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/6/645351dc2211240a7d36062c64a544e5c1b41275.png)

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [September 17, 2019, 11:59am UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/9 "2019-09-17T11:59:29Z")

</div>

Oh yes, the character is doing a lot of gymnastics. 🙂 Sorry this message is not helpful.

Try to use this to prevent the character from distorting :  
mesh.updatePoseMatrix(BABYLON.Matrix.Identity());`

Or can be ignored Quaternion and use Euler for rotation.

`mesh.rotationQuaternion= null;`  
Then use : `mesh.rotation = new Vector3`

---

<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:** [September 17, 2019, 3:19pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/10 "2019-09-17T15:19:28Z")

</div>

> [@gryff](#):
>
> Looks like all the old clan is out on this

LOVE THAT!

---

<div class="post-metadata">

**Author:** ![bigrig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bigrig/32/5548_2.png) [@bigrig](https://forum.babylonjs.com/u/bigrig)\
**Post date:** [September 17, 2019, 3:46pm UTC](https://forum.babylonjs.com/t/rotations-from-blender-dont-match-up-with-babylon/5659/11 "2019-09-17T15:46:30Z")

</div>

Yea, i feel so sorry for the guy - with his legs coming out of his ears.

mesh.updatePoseMatrix doesn’t do anything unfortunately… even if i send it a matrix with arbitrary values - has no effect. tried updating the poseMatrix using the transform nodes also… still no effect.

Am thinking that the transform nodes / GLB format is adding a level of complexity. Going to try using an Obj instead.
