# Some trouble with the Blender exporter (rotations and unwanted Z/Y flip)

**URL:** <https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454>\
**Category:** Questions\
**Tags:** blender\
**Created:** [February 6, 2020, 11:01am UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454 "2020-02-06T11:01:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cronvel](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cronvel/32/6760_2.png) [@cronvel](https://forum.babylonjs.com/u/cronvel)\
**Post date:** [February 6, 2020, 11:01am UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/1 "2020-02-06T11:01:38Z")

</div>

Hi there,

First, thanks for this excellent framework: currently migrating some hobby project from Three.js to Babylon and very happy with it!

Anyway, I have few troubles with the Blender exporter:

- When the model have transformations, they are kept in the .babylon file. Is there an option to always convert positions to the world coordinate (like the glTF exporter does)?
- Moreover, rotation do not work at all (except quaternions), it seems that the exporter doesn’t save the Euler order along with axis angles.
- The exporter flip Z and Y, and I would like to prevent it from doing so, but can’t find how.

I can fix the first and second by “applying transforms” in Blender, however I can’t find an easy way to fix the last.

They said I should ping @JCPalmer for that! 😉

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [February 6, 2020, 1:44pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/2 "2020-02-06T13:44:10Z")

</div>

Hi! And welcome to the forum!

Maybe @Drigax might be able to help as well.

---

<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:** [February 6, 2020, 6:29pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/3 "2020-02-06T18:29:21Z")

</div>

The short answer to stop flipping is to change the source code, specifically `format_vector` in [package\_level.py](https://github.com/BabylonJS/BlenderExporter/blob/master/src/babylon_js/package_level.py#L161).

Once done, you are “on your own”, not that you actually bought support in the first place though.

This exporter is designed to send data in native format to BJS. BJS is Y-Up, so everything is flipped, **including** rotations.

---

<div class="post-metadata">

**Author:** ![cronvel](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cronvel/32/6760_2.png) [@cronvel](https://forum.babylonjs.com/u/cronvel)\
**Post date:** [February 6, 2020, 8:56pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/4 "2020-02-06T20:56:01Z")

</div>

@Cedric @JCPalmer Thanks for the reply!

The project I’m migrating to Babylon is Z-up (and right-handed), so I have to make it work that way.  
So far Babylon looks flexible enough, except rotation, so I will use quaternions everywhere, and I already coded few helpers to convert easily Z-up yaw/pitch/roll into quaternions.

For the Blender exporter, I decided (before reading your reply) to patch directly the `.babylon` output file (too much things to learn to patch the exporter itself, and I’m not enjoying Python programming). So far, for every mesh, my script swap Y/Z in the “positions” and “normals” arrays, and for the “indices” array, the first and the last of each group of three are swapped (to restore the correct face side). Is there anything else that need to be done for models? (UV?)

If there is too much work here, I would eventually prefer modifying the Python exporter, I just want to go with the shortest path. In `package_level.py`, if I change `format_vector()` and `format_quaternion()`, everything will be ok? Or is there other things to patch?

---

<div class="post-metadata">

**Author:** ![cronvel](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cronvel/32/6760_2.png) [@cronvel](https://forum.babylonjs.com/u/cronvel)\
**Post date:** [February 6, 2020, 10:42pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/5 "2020-02-06T22:42:30Z")

</div>

@JCPalmer BTW would you accept a PR for that? I got it working with an opt-in option inside the “world” tab.

---

<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:** [February 6, 2020, 11:16pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/6 "2020-02-06T23:16:24Z")

</div>

Go ahead. One thing that will also need to change is the version. It should now be 6.3, since functionality has changed. This is in the **initial**.py at the highest level.

I can also change it prior to merge, though I don’t know how.

---

<div class="post-metadata">

**Author:** ![cronvel](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cronvel/32/6760_2.png) [@cronvel](https://forum.babylonjs.com/u/cronvel)\
**Post date:** [February 7, 2020, 2:37pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/7 "2020-02-07T14:37:04Z")

</div>

@JCPalmer Great! The [PR is ready](https://github.com/BabylonJS/BlenderExporter/pull/17).

---

<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:** [February 7, 2020, 4:18pm UTC](https://forum.babylonjs.com/t/some-trouble-with-the-blender-exporter-rotations-and-unwanted-z-y-flip/8454/8 "2020-02-07T16:18:38Z")

</div>

Ok, I will not get a look at till Monday.
