|
@@ -4,24 +4,7 @@ import { FreeCamera } from "../../Cameras/freeCamera";
|
|
|
import { CameraInputTypes } from "../../Cameras/cameraInputsManager";
|
|
|
import { BaseCameraMouseWheelInput } from "../../Cameras/Inputs/BaseCameraMouseWheelInput";
|
|
|
import { Matrix, Vector3 } from "../../Maths/math.vector";
|
|
|
-
|
|
|
-/**
|
|
|
- * Defines the potential axis to be altered in a transform operation.
|
|
|
- */
|
|
|
-export enum AXIS {
|
|
|
- /**
|
|
|
- * X axis.
|
|
|
- */
|
|
|
- X,
|
|
|
- /**
|
|
|
- * Y axis.
|
|
|
- */
|
|
|
- Y,
|
|
|
- /**
|
|
|
- * Z axis.
|
|
|
- */
|
|
|
- Z
|
|
|
-}
|
|
|
+import { Coordinate } from "../../Maths/math.axis";
|
|
|
|
|
|
/**
|
|
|
* Manage the mouse wheel inputs to control a free camera.
|
|
@@ -48,13 +31,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelXMoveRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelXMoveRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelXAction !== this._moveRelative) {
|
|
|
// Attempting to clear different _wheelXAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelXAction = this._moveRelative;
|
|
|
- this._wheelXActionProperty = axis;
|
|
|
+ this._wheelXActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -62,11 +45,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's X axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelXMoveRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelXMoveRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelXAction !== this._moveRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelXActionProperty;
|
|
|
+ return this._wheelXActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -75,13 +58,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelYMoveRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelYMoveRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelYAction !== this._moveRelative) {
|
|
|
// Attempting to clear different _wheelYAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelYAction = this._moveRelative;
|
|
|
- this._wheelYActionProperty = axis;
|
|
|
+ this._wheelYActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -89,11 +72,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's Y axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelYMoveRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelYMoveRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelYAction !== this._moveRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelYActionProperty;
|
|
|
+ return this._wheelYActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -102,13 +85,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelZMoveRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelZMoveRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelZAction !== this._moveRelative) {
|
|
|
// Attempting to clear different _wheelZAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelZAction = this._moveRelative;
|
|
|
- this._wheelZActionProperty = axis;
|
|
|
+ this._wheelZActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -116,11 +99,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's Z axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelZMoveRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelZMoveRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelZAction !== this._moveRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelZActionProperty;
|
|
|
+ return this._wheelZActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -129,13 +112,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelXRotateRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelXRotateRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelXAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelXAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelXAction = this._rotateRelative;
|
|
|
- this._wheelXActionProperty = axis;
|
|
|
+ this._wheelXActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -143,11 +126,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's X axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelXRotateRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelXRotateRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelXAction !== this._rotateRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelXActionProperty;
|
|
|
+ return this._wheelXActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -156,13 +139,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelYRotateRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelYRotateRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelYAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelYAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelYAction = this._rotateRelative;
|
|
|
- this._wheelYActionProperty = axis;
|
|
|
+ this._wheelYActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -170,11 +153,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's Y axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelYRotateRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelYRotateRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelYAction !== this._rotateRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelYActionProperty;
|
|
|
+ return this._wheelYActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -183,13 +166,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelZRotateRelative(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelZRotateRelative(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelZAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelZAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelZAction = this._rotateRelative;
|
|
|
- this._wheelZActionProperty = axis;
|
|
|
+ this._wheelZActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -197,11 +180,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* mouse wheel's Z axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelZRotateRelative(): Nullable<AXIS> {
|
|
|
+ public get wheelZRotateRelative(): Nullable<Coordinate> {
|
|
|
if (this._wheelZAction !== this._rotateRelative) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelZActionProperty;
|
|
|
+ return this._wheelZActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -210,13 +193,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelXMoveScene(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelXMoveScene(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelXAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelXAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelXAction = this._moveScene;
|
|
|
- this._wheelXActionProperty = axis;
|
|
|
+ this._wheelXActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -224,11 +207,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* X axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelXMoveScene(): Nullable<AXIS> {
|
|
|
+ public get wheelXMoveScene(): Nullable<Coordinate> {
|
|
|
if (this._wheelXAction !== this._moveScene) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelXActionProperty;
|
|
|
+ return this._wheelXActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -237,13 +220,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelYMoveScene(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelYMoveScene(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelYAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelYAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelYAction = this._moveScene;
|
|
|
- this._wheelYActionProperty = axis;
|
|
|
+ this._wheelYActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -251,11 +234,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* Y axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelYMoveScene(): Nullable<AXIS> {
|
|
|
+ public get wheelYMoveScene(): Nullable<Coordinate> {
|
|
|
if (this._wheelYAction !== this._moveScene) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelYActionProperty;
|
|
|
+ return this._wheelYActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -264,13 +247,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* @param axis The axis to be moved. Set null to clear.
|
|
|
*/
|
|
|
@serialize()
|
|
|
- public set wheelZMoveScene(axis: Nullable<AXIS>) {
|
|
|
+ public set wheelZMoveScene(axis: Nullable<Coordinate>) {
|
|
|
if (axis === null && this._wheelZAction !== this._rotateRelative) {
|
|
|
// Attempting to clear different _wheelZAction.
|
|
|
return;
|
|
|
}
|
|
|
this._wheelZAction = this._moveScene;
|
|
|
- this._wheelZActionProperty = axis;
|
|
|
+ this._wheelZActionCoordinate = axis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -278,11 +261,11 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* Z axis controls.
|
|
|
* @returns The configured axis or null if none.
|
|
|
*/
|
|
|
- public get wheelZMoveScene(): Nullable<AXIS> {
|
|
|
+ public get wheelZMoveScene(): Nullable<Coordinate> {
|
|
|
if (this._wheelZAction !== this._moveScene) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._wheelZActionProperty;
|
|
|
+ return this._wheelZActionCoordinate;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -295,13 +278,13 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // Clear the camera properties that we might be updating.
|
|
|
this._moveRelative.setAll(0);
|
|
|
this._rotateRelative.setAll(0);
|
|
|
this._moveScene.setAll(0);
|
|
|
|
|
|
- this._updateCamera(this._wheelDeltaX, this._wheelXAction, this._wheelXActionProperty);
|
|
|
- this._updateCamera(this._wheelDeltaY, this._wheelYAction, this._wheelYActionProperty);
|
|
|
- this._updateCamera(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionProperty);
|
|
|
+ // Set the camera properties that are to be updated.
|
|
|
+ this._updateCamera();
|
|
|
|
|
|
if (this.camera.getScene().useRightHandedSystem) {
|
|
|
// TODO: Does this need done for worldUpdate too?
|
|
@@ -334,38 +317,48 @@ export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
|
|
|
* These are set to the desired default behaviour.
|
|
|
*/
|
|
|
private _wheelXAction: Nullable<Vector3> = this._moveRelative;
|
|
|
- private _wheelXActionProperty: Nullable<AXIS> = AXIS.X;
|
|
|
+ private _wheelXActionCoordinate: Nullable<Coordinate> = Coordinate.X;
|
|
|
private _wheelYAction: Nullable<Vector3> = this._moveRelative;
|
|
|
- private _wheelYActionProperty: Nullable<AXIS> = AXIS.Z;
|
|
|
+ private _wheelYActionCoordinate: Nullable<Coordinate> = Coordinate.Z;
|
|
|
private _wheelZAction: Nullable<Vector3> = null;
|
|
|
- private _wheelZActionProperty: Nullable<AXIS> = null;
|
|
|
+ private _wheelZActionCoordinate: Nullable<Coordinate> = null;
|
|
|
|
|
|
/**
|
|
|
- * Called once per mouse wheel axis. Will update the camera according to any
|
|
|
- * configured properties for that axis.
|
|
|
+ * Update the camera according to any configured properties for the 3
|
|
|
+ * mouse-wheel axis.
|
|
|
*/
|
|
|
- private _updateCamera(
|
|
|
- value: number, action: Nullable<Vector3>, property: Nullable<AXIS>): void {
|
|
|
- if (value === 0) {
|
|
|
- // Mouse wheel has not moved.
|
|
|
- return;
|
|
|
- }
|
|
|
- if (action === null || property === null) {
|
|
|
- // Mouse wheel axis not configured.
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- switch (property) {
|
|
|
- case AXIS.X:
|
|
|
- action.set(value, 0, 0);
|
|
|
- break;
|
|
|
- case AXIS.Y:
|
|
|
- action.set(0, value, 0);
|
|
|
- break;
|
|
|
- case AXIS.Z:
|
|
|
- action.set(0, 0, value);
|
|
|
- break;
|
|
|
+ private _updateCamera(): void {
|
|
|
+ let updateCameraProperty = function(value: number,
|
|
|
+ action: Nullable<Vector3>,
|
|
|
+ coordinate: Nullable<Coordinate>): void {
|
|
|
+ if (value === 0) {
|
|
|
+ // Mouse wheel has not moved.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (action === null || coordinate === null) {
|
|
|
+ // Mouse wheel axis not configured.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (coordinate) {
|
|
|
+ case Coordinate.X:
|
|
|
+ action.set(value, 0, 0);
|
|
|
+ break;
|
|
|
+ case Coordinate.Y:
|
|
|
+ action.set(0, value, 0);
|
|
|
+ break;
|
|
|
+ case Coordinate.Z:
|
|
|
+ action.set(0, 0, value);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ // Do the camera updates for each of the 3 touch-wheel axis.
|
|
|
+ updateCameraProperty(
|
|
|
+ this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate);
|
|
|
+ updateCameraProperty(
|
|
|
+ this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate);
|
|
|
+ updateCameraProperty(
|
|
|
+ this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate);
|
|
|
}
|
|
|
|
|
|
}
|