|
@@ -14,6 +14,11 @@ module BABYLON {
|
|
|
* Define the current rotation the camera is rotating to
|
|
|
*/
|
|
|
public cameraRotation = new Vector2(0, 0);
|
|
|
+ /**
|
|
|
+ * When set, the up vector of the camera will be updated by the rotation of the camera
|
|
|
+ */
|
|
|
+ public updateUpVectorFromRotation = false;
|
|
|
+ private _tmpQuaternion = new Quaternion();
|
|
|
|
|
|
/**
|
|
|
* Define the current rotation of the camera
|
|
@@ -178,7 +183,7 @@ module BABYLON {
|
|
|
|
|
|
this._cache.rotation.copyFrom(this.rotation);
|
|
|
if (this.rotationQuaternion) {
|
|
|
- this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
|
+ this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -294,10 +299,10 @@ module BABYLON {
|
|
|
var limit = (Math.PI / 2) * 0.95;
|
|
|
|
|
|
if (this.rotation.x > limit) {
|
|
|
- this.rotation.x = limit;
|
|
|
+ this.rotation.x = limit;
|
|
|
}
|
|
|
if (this.rotation.x < -limit) {
|
|
|
- this.rotation.x = -limit;
|
|
|
+ this.rotation.x = -limit;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -373,7 +378,14 @@ module BABYLON {
|
|
|
|
|
|
// Computing target and final matrix
|
|
|
this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
|
|
|
-
|
|
|
+ if (this.updateUpVectorFromRotation) {
|
|
|
+ if (this.rotationQuaternion) {
|
|
|
+ Axis.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
|
|
|
+ } else {
|
|
|
+ Quaternion.FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
|
|
|
+ Axis.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
|
|
|
+ }
|
|
|
+ }
|
|
|
this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
|
|
|
return this._viewMatrix;
|
|
|
}
|