# In right handed coordinate system (three js) How can i swap the y axis with z axis?

**URL:** <https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733>\
**Category:** Questions\
**Tags:** coordinate-system\
**Created:** [August 15, 2017, 9:37am UTC](https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733 "2017-08-15T09:37:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarah](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sarah/32/370_2.png) [@sarah](https://discourse.threejs.org/u/sarah)\
**Post date:** [August 15, 2017, 9:37am UTC](https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733/1 "2017-08-15T09:37:01Z")

</div>

I have a function rotate(). This will check if the user has set axisUp to ‘Y’ or ‘Z’. if the user has set the axis to Y then we dont do anything because in both left and right handed y is up. but if they choose the z axis for up then i need to rotate the scene. I am not sure if the following code is correct.

Some feeedback would be great. Is the code correct? will it be enough to rotate to z? will i need to do anything else after rotating the scene object?

thank you in advance.

my code:

```
    //if axisUp === y then do nothing as already y up in right handed
    if (axis.axisUp === "z_positive") {
        scene.rotation.x = -90 * Math.PI/180;
    } else {
         console.warn( 'WARNING: Not supported');
    }
```

---

<div class="post-metadata">

**Author:** ![Fyrestar](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fyrestar/32/52793_2.png) [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Post date:** [August 15, 2017, 4:32pm UTC](https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733/2 "2017-08-15T16:32:53Z")

</div>

As my reply to your [other post](https://discourse.threejs.org/t/how-to-rotate-scene-object-based-on-x-y-z-coordinates/732/2), you can set it on each individual object or mesh with myObject.up.set(0.0, 0.0, 1.0) or on `THREE.Object3D.DefaultUp` before any object is created.

---

<div class="post-metadata">

**Author:** ![sarah](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/sarah/32/370_2.png) [@sarah](https://discourse.threejs.org/u/sarah)\
**Post date:** [August 15, 2017, 7:41pm UTC](https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733/3 "2017-08-15T19:41:10Z")

</div>

I cant set it on object creation. the purpose of this is to rotate the scene after it has been created.

i tried : scene.up.set(0.0, 0.0, 1.0); but nothing happens. the vector gets set but the model doesnt change.

---

<div class="post-metadata">

**Author:** ![selmernoid](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/selmernoid/32/10410_2.png) [@selmernoid](https://discourse.threejs.org/u/selmernoid)\
**Post date:** [April 14, 2020, 1:00pm UTC](https://discourse.threejs.org/t/in-right-handed-coordinate-system-three-js-how-can-i-swap-the-y-axis-with-z-axis/733/4 "2020-04-14T13:00:34Z")

</div>

Use this  
`THREE.Object3D.DefaultUp.set(0, 0, 1);`
