|
@@ -5,9 +5,7 @@ module BABYLON {
|
|
|
export class WebVRFreeCamera extends FreeCamera {
|
|
|
public _hmdDevice = null;
|
|
|
public _sensorDevice = null;
|
|
|
- public _cacheState = null;
|
|
|
- public _cacheQuaternion = new Quaternion();
|
|
|
- public _cacheRotation = Vector3.Zero();
|
|
|
+ private _cacheState = null;
|
|
|
public _vrEnabled = false;
|
|
|
|
|
|
constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true) {
|
|
@@ -51,12 +49,10 @@ module BABYLON {
|
|
|
public _checkInputs(): void {
|
|
|
if (this._vrEnabled) {
|
|
|
this._cacheState = this._sensorDevice.getState();
|
|
|
- this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x, this._cacheState.orientation.y, this._cacheState.orientation.z, this._cacheState.orientation.w);
|
|
|
- this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation);
|
|
|
-
|
|
|
- this.rotation.x = -this._cacheRotation.x;
|
|
|
- this.rotation.y = -this._cacheRotation.y;
|
|
|
- this.rotation.z = this._cacheRotation.z;
|
|
|
+ this.rotationQuaternion.copyFrom(this._cacheState.orientation);
|
|
|
+ //Flip in XY plane
|
|
|
+ this.rotationQuaternion.z *= -1;
|
|
|
+ this.rotationQuaternion.w *= -1;
|
|
|
}
|
|
|
|
|
|
super._checkInputs();
|
|
@@ -80,6 +76,11 @@ module BABYLON {
|
|
|
this._vrEnabled = false;
|
|
|
}
|
|
|
|
|
|
+ public requestVRFullscreen(requestPointerlock: boolean) {
|
|
|
+ if (!this._hmdDevice) return;
|
|
|
+ this.getEngine().switchFullscreen(requestPointerlock, { vrDisplay: this._hmdDevice })
|
|
|
+ }
|
|
|
+
|
|
|
public getTypeName(): string {
|
|
|
return "WebVRFreeCamera";
|
|
|
}
|