Browse Source

making sure rotation is updating only when needed

Only testing if alpha is not 0. this will never happen when the device
already sending information, as no device is so exact that it will
provide an exact 0. and even if it will, it will probably be for a
single frame.
Raanan Weber 9 years ago
parent
commit
ca825a2fa9
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.ts

+ 3 - 0
src/Cameras/Inputs/babylon.freecamera.input.deviceorientation.ts

@@ -51,6 +51,9 @@ module BABYLON {
         }
 
         public checkInputs() {
+            //if no device orientation provided, don't update the rotation.
+            //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
+            if(!this._alpha) return;
             Quaternion.RotationYawPitchRollToRef(BABYLON.Tools.ToRadians(this._alpha), BABYLON.Tools.ToRadians(this._beta), -BABYLON.Tools.ToRadians(this._gamma), this.camera.rotationQuaternion)
             this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
             this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);