|
@@ -1,20 +1,37 @@
|
|
|
module BABYLON {
|
|
|
// We're mainly based on the logic defined into the FreeCamera code
|
|
|
+ /**
|
|
|
+ * This is a camera specifically designed to react to device orientation events such as a modern mobile device
|
|
|
+ * being tilted forward or back and left or right.
|
|
|
+ */
|
|
|
export class DeviceOrientationCamera extends FreeCamera {
|
|
|
|
|
|
private _initialQuaternion: Quaternion;
|
|
|
private _quaternionCache: Quaternion;
|
|
|
|
|
|
+ /**
|
|
|
+ * Creates a new device orientation camera. @see DeviceOrientationCamera
|
|
|
+ * @param name The name of the camera
|
|
|
+ * @param position The starts position camera
|
|
|
+ * @param scene The scene the camera belongs to
|
|
|
+ */
|
|
|
constructor(name: string, position: Vector3, scene: Scene) {
|
|
|
super(name, position, scene);
|
|
|
this._quaternionCache = new Quaternion();
|
|
|
this.inputs.addDeviceOrientation();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the current instance class name ("DeviceOrientationCamera").
|
|
|
+ * This helps avoiding instanceof at run time.
|
|
|
+ */
|
|
|
public getClassName(): string {
|
|
|
return "DeviceOrientationCamera";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Checks and applies the current values of the inputs to the camera. (Internal use only)
|
|
|
+ */
|
|
|
public _checkInputs(): void {
|
|
|
super._checkInputs();
|
|
|
this._quaternionCache.copyFrom(this.rotationQuaternion);
|
|
@@ -23,7 +40,11 @@ module BABYLON {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public resetToCurrentRotation(axis: Axis = Axis.Y) {
|
|
|
+ /**
|
|
|
+ * Reset the camera to its default orientation on the specified axis only.
|
|
|
+ * @param axis The axis to reset
|
|
|
+ */
|
|
|
+ public resetToCurrentRotation(axis: Axis = Axis.Y): void {
|
|
|
//can only work if this camera has a rotation quaternion already.
|
|
|
if (!this.rotationQuaternion) return;
|
|
|
|