# VR Scene with Z axis up

**URL:** <https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624>\
**Category:** Questions\
**Tags:** webvr\
**Created:** [January 17, 2018, 2:51am UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624 "2018-01-17T02:51:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelmike](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@pixelmike](https://discourse.threejs.org/u/pixelmike)\
**Post date:** [January 17, 2018, 2:51am UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/1 "2018-01-17T02:51:32Z")

</div>

I have a scene with the Z axis up and the XY axes along the ground plane. To do this I use this trick:

```
camera.rotation.order = "ZXY"
camera.rotation.x = Math.PI * 0.5
camera.rotation.y = Math.PI * 0.5
camera.rotation.z = Math.PI
camera.up.set(0.0, 0.0, 1.0)

camHolder = new THREE.Object3D()
camHolder.rotation.order = "ZYX"
camHolder.add(this.camera)

scene.add(camHolder)

```

Then I move/rotate camHolder around the scene.

However when I enable VR using the Vive, my scene is sideways. Is there any workaround for this or must I use the Y axis as up in my scene?

---

<div class="post-metadata">

**Author:** ![looeee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/looeee/32/59_2.png) [@looeee](https://discourse.threejs.org/u/looeee)\
**Post date:** [January 17, 2018, 5:13am UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/2 "2018-01-17T05:13:16Z")

</div>

I’m not sure if there’s a way of doing this for VR, but it’s generally strongly recommended to keep y as the up axis.

Is there a reason that you need to change this?

---

<div class="post-metadata">

**Author:** ![pixelmike](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@pixelmike](https://discourse.threejs.org/u/pixelmike)\
**Post date:** [January 17, 2018, 1:34pm UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/3 "2018-01-17T13:34:58Z")

</div>

Mainly because I have existing projects I wanted to add VR support to.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [January 17, 2018, 2:14pm UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/4 "2018-01-17T14:14:45Z")

</div>

The standard for WebVR is as follows (see [reference](https://developer.mozilla.org/en-US/docs/Web/API/VRPose/position)):

- positive X is to the user’s right
- positive Y is up
- positive Z is behind the user

This setup is immutable and you should not perform any weird manual conversion. I suggest to use Y-UP in your scenes.

---

<div class="post-metadata">

**Author:** ![pixelmike](https://avatars.discourse-cdn.com/v4/letter/p/f1d935/32.png) [@pixelmike](https://discourse.threejs.org/u/pixelmike)\
**Post date:** [January 17, 2018, 3:51pm UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/5 "2018-01-17T15:51:03Z")

</div>

All right, I guess that decides it. Thanks.

---

<div class="post-metadata">

**Author:** ![ManuelGraf](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/manuelgraf/32/1011_2.png) [@ManuelGraf](https://discourse.threejs.org/u/ManuelGraf)\
**Post date:** [January 26, 2018, 12:07pm UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/6 "2018-01-26T12:07:05Z")

</div>

Well, I have the exact same Problem. I am bound to use a right handed coordinate system with a XY ground plane, as positions get synced to a 2d map and rely on geopositions.

but there are workarounds for that:

1. you rotate your camera 90° around x before everything else:  
this.xOffset = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1,0,0), THREE.Math.degToRad(90));  
this.deviceOrientation = new THREE.Quaternion();  
this.deviceOrientation.fromArray( pose.orientation );  
this.objectQuat = new THREE.Quaternion();  
this.objectQuat.multiplyQuaternions(this.xOffset,this.deviceOrientation);

2. you transform every pose you get by the following conversion:

---

<div class="post-metadata">

**Author:** ![ManuelGraf](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/manuelgraf/32/1011_2.png) [@ManuelGraf](https://discourse.threejs.org/u/ManuelGraf)\
**Post date:** [January 26, 2018, 12:10pm UTC](https://discourse.threejs.org/t/vr-scene-with-z-axis-up/1624/7 "2018-01-26T12:10:33Z")

</div>

being immutable doesnt necessarily mean it is hard to workaround. you just have to adjust the sensor data/pose. Although this might get messy when using the standingMatrix.
