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"
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?
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?
Mainly because I have existing projects I wanted to add VR support to.
The standard for WebVR is as follows (see reference):
- 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.
All right, I guess that decides it. Thanks.
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:
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();
you transform every pose you get by the following conversion:
var adjustedPos = new THREE.Vector3(
pose.position * (-1),
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.