babylon.vrDeviceOrientationCamera.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var VRDeviceOrientationCamera = (function (_super) {
  10. __extends(VRDeviceOrientationCamera, _super);
  11. function VRDeviceOrientationCamera(name, position, scene) {
  12. _super.call(this, name, position, scene);
  13. this._alpha = 0;
  14. this._beta = 0;
  15. this._gamma = 0;
  16. }
  17. VRDeviceOrientationCamera.prototype._onOrientationEvent = function (evt) {
  18. this._alpha = +evt.alpha | 0;
  19. this._beta = +evt.beta | 0;
  20. this._gamma = +evt.gamma | 0;
  21. if (this._gamma < 0) {
  22. this._gamma = 90 + this._gamma;
  23. }
  24. else {
  25. // Incline it in the correct angle.
  26. this._gamma = 270 - this._gamma;
  27. }
  28. this.rotation.x = this._gamma / 180.0 * Math.PI;
  29. this.rotation.y = -this._alpha / 180.0 * Math.PI;
  30. this.rotation.z = this._beta / 180.0 * Math.PI;
  31. };
  32. return VRDeviceOrientationCamera;
  33. })(BABYLON.OculusCamera);
  34. BABYLON.VRDeviceOrientationCamera = VRDeviceOrientationCamera;
  35. })(BABYLON || (BABYLON = {}));
  36. //# sourceMappingURL=babylon.vrDeviceOrientationCamera.js.map