Trevor Baron před 6 roky
rodič
revize
20c6c56b9c

+ 10 - 3
src/Cameras/Inputs/freeCameraMouseInput.ts

@@ -30,8 +30,15 @@ export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
     private _onMouseMove: Nullable<(e: MouseEvent) => any>;
     private _observer: Nullable<Observer<PointerInfo>>;
     private previousPosition: Nullable<{ x: number, y: number }> = null;
-    
+
+    /**
+     * Observable for when a pointer move event occurs containing the move offset
+     */
     public onPointerMovedObservable = new Observable<{ offsetX: number, offsetY: number }>();
+    /**
+     * @hidden
+     * If the camera should be rotated automatically based on pointer movement
+     */
     public _allowCameraRotation = true;
     /**
      * Manage the mouse inputs to control the movement of a free camera.
@@ -111,11 +118,11 @@ export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
                     if (this.camera.getScene().useRightHandedSystem) { offsetX *= -1; }
                     if (this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0) { offsetX *= -1; }
 
-                    if(this._allowCameraRotation){
+                    if (this._allowCameraRotation) {
                         this.camera.cameraRotation.y += offsetX / this.angularSensibility;
                         this.camera.cameraRotation.x += offsetY / this.angularSensibility;
                     }
-                    this.onPointerMovedObservable.notifyObservers({offsetX:offsetX, offsetY:offsetY})
+                    this.onPointerMovedObservable.notifyObservers({offsetX: offsetX, offsetY: offsetY});
 
                     this.previousPosition = {
                         x: evt.clientX,

+ 7 - 7
src/Cameras/deviceOrientationCamera.ts

@@ -34,18 +34,18 @@ export class DeviceOrientationCamera extends FreeCamera {
         // When the orientation sensor fires it's first event, disable mouse input
         if (this.inputs._deviceOrientationInput) {
             this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(() => {
-                if(this.inputs._mouseInput){
-                    this.inputs._mouseInput._moveCamera = false;
-                    this.inputs._mouseInput._onMouseMoved.add((e)=>{
-                        if(this._dragFactor != 0){
+                if (this.inputs._mouseInput) {
+                    this.inputs._mouseInput._allowCameraRotation = false;
+                    this.inputs._mouseInput.onPointerMovedObservable.add((e) => {
+                        if (this._dragFactor != 0) {
                             if (!this._initialQuaternion) {
                                 this._initialQuaternion = new Quaternion();
                             }
                             // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
-                            Quaternion.FromEulerAnglesToRef(0,e.offsetX*this._dragFactor,0, this._tmpDragQuaternion);
+                            Quaternion.FromEulerAnglesToRef(0, e.offsetX * this._dragFactor, 0, this._tmpDragQuaternion);
                             this._initialQuaternion.multiplyToRef(this._tmpDragQuaternion, this._initialQuaternion);
                         }
-                    })
+                    });
                 }
             });
         }
@@ -56,7 +56,7 @@ export class DeviceOrientationCamera extends FreeCamera {
      * Enabled turning on the y axis when the orientation sensor is active
      * @param dragFactor the factor that controls the turn speed (default: 1/300)
      */
-    public enableHorizontalDragging(dragFactor=1/300){
+    public enableHorizontalDragging(dragFactor= 1 / 300) {
         this._dragFactor = dragFactor;
     }