|
@@ -12,8 +12,8 @@
|
|
|
this.cameraRotation = new BABYLON.Vector2(0, 0);
|
|
|
this.rotation = new BABYLON.Vector3(0, 0, 0);
|
|
|
this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
|
|
|
- this.angularSensibility = 200000.0;
|
|
|
- this.moveSensibility = 500.0;
|
|
|
+ this.angularSensibility = 10000.0;
|
|
|
+ this.moveSensibility = 50.0;
|
|
|
|
|
|
if (!scene.activeCamera) {
|
|
|
scene.activeCamera = this;
|
|
@@ -21,7 +21,7 @@
|
|
|
// Collisions
|
|
|
this._collider = new BABYLON.Collider();
|
|
|
this._needMoveForGravity = true;
|
|
|
-
|
|
|
+
|
|
|
// Offset
|
|
|
this._offsetX = null;
|
|
|
this._offsetY = null;
|
|
@@ -29,10 +29,10 @@
|
|
|
this._orientationBeta = 0;
|
|
|
this._initialOrientationGamma = 0;
|
|
|
this._initialOrientationBeta = 0;
|
|
|
-
|
|
|
+
|
|
|
// Animations
|
|
|
this.animations = [];
|
|
|
-
|
|
|
+
|
|
|
// Internals
|
|
|
this._cameraRotationMatrix = new BABYLON.Matrix();
|
|
|
this._referencePoint = BABYLON.Vector3.Zero();
|
|
@@ -54,19 +54,20 @@
|
|
|
}
|
|
|
this._attachedCanvas = canvas;
|
|
|
|
|
|
+ var that = this;
|
|
|
if (!this._orientationChanged) {
|
|
|
this._orientationChanged = function (evt) {
|
|
|
-
|
|
|
- if (!this._initialOrientationGamma) {
|
|
|
- this._initialOrientationGamma = evt.gamma;
|
|
|
- this._initialOrientationBeta = evt.beta;
|
|
|
+
|
|
|
+ if (!that._initialOrientationGamma) {
|
|
|
+ that._initialOrientationGamma = evt.gamma;
|
|
|
+ that._initialOrientationBeta = evt.beta;
|
|
|
}
|
|
|
|
|
|
- this._orientationGamma = evt.gamma;
|
|
|
- this._orientationBeta = evt.beta;
|
|
|
+ that._orientationGamma = evt.gamma;
|
|
|
+ that._orientationBeta = evt.beta;
|
|
|
|
|
|
- this._offsetY = (this._initialOrientationBeta - this._orientationBeta) * 0.05;
|
|
|
- this._offsetX = (this._initialOrientationGamma - this._orientationGamma) * -0.05;
|
|
|
+ that._offsetY = (that._initialOrientationBeta - that._orientationBeta);
|
|
|
+ that._offsetX = (that._initialOrientationGamma - that._orientationGamma);
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -79,28 +80,24 @@
|
|
|
}
|
|
|
|
|
|
window.removeEventListener("deviceorientation", this._orientationChanged);
|
|
|
-
|
|
|
+
|
|
|
this._attachedCanvas = null;
|
|
|
this._orientationGamma = 0;
|
|
|
this._orientationBeta = 0;
|
|
|
this._initialOrientationGamma = 0;
|
|
|
this._initialOrientationBeta = 0;
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
BABYLON.DeviceOrientationCamera.prototype._checkInputs = function () {
|
|
|
if (!this._offsetX) {
|
|
|
return;
|
|
|
}
|
|
|
- this.cameraRotation.y += this._offsetX / this.angularSensibility;
|
|
|
+ this.cameraRotation.y -= this._offsetX / this.angularSensibility;
|
|
|
|
|
|
- if (this._pointerPressed.length > 1) {
|
|
|
- this.cameraRotation.x += -this._offsetY / this.angularSensibility;
|
|
|
- } else {
|
|
|
- var speed = this._computeLocalCameraSpeed();
|
|
|
- var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
|
|
|
+ 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));
|
|
|
- }
|
|
|
+ BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
|
|
|
+ this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
|
|
|
};
|
|
|
})();
|