var __extends = this.__extends || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }; var BABYLON; (function (BABYLON) { // We're mainly based on the logic defined into the FreeCamera code var DeviceOrientationCamera = (function (_super) { __extends(DeviceOrientationCamera, _super); function DeviceOrientationCamera(name, position, scene) { var _this = this; _super.call(this, name, position, scene); this._offsetX = null; this._offsetY = null; this._orientationGamma = 0; this._orientationBeta = 0; this._initialOrientationGamma = 0; this._initialOrientationBeta = 0; this._isLandscape = true; this.angularSensibility = 10000.0; this.moveSensibility = 50.0; http: window.addEventListener("resize", function () { _this._isLandscape = (window.innerWidth > window.innerHeight) ? true : false; _this._initialOrientationGamma = null; }, false); } DeviceOrientationCamera.prototype.attachControl = function (canvas, noPreventDefault) { if (this._attachedCanvas) { return; } this._attachedCanvas = canvas; var that = this; if (!this._orientationChanged) { this._orientationChanged = function (evt) { if (!that._initialOrientationGamma) { if (!this._isLandscape) { that._initialOrientationGamma = evt.gamma; that._initialOrientationBeta = evt.beta; } else { that._initialOrientationGamma = evt.beta; that._initialOrientationBeta = evt.gamma; } } if (!this._isLandscape) { that._orientationGamma = evt.gamma; that._orientationBeta = evt.beta; } else { that._orientationGamma = evt.beta; that._orientationBeta = evt.gamma; } that._offsetY = (that._initialOrientationBeta - that._orientationBeta); that._offsetX = (that._initialOrientationGamma - that._orientationGamma); }; } window.addEventListener("deviceorientation", this._orientationChanged); }; DeviceOrientationCamera.prototype.detachControl = function (canvas) { if (this._attachedCanvas != canvas) { return; } window.removeEventListener("deviceorientation", this._orientationChanged); this._attachedCanvas = null; this._orientationGamma = 0; this._orientationBeta = 0; this._initialOrientationGamma = 0; this._initialOrientationBeta = 0; }; DeviceOrientationCamera.prototype._checkInputs = function () { if (!this._offsetX) { return; } this.cameraRotation.y -= this._offsetX / this.angularSensibility; var speed = this._computeLocalCameraSpeed(); var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility); BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix); this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix)); }; return DeviceOrientationCamera; })(BABYLON.FreeCamera); BABYLON.DeviceOrientationCamera = DeviceOrientationCamera; })(BABYLON || (BABYLON = {})); //# sourceMappingURL=babylon.deviceOrientationCamera.js.map