소스 검색

freeCameraTouchInput bug.

duncan law 4 년 전
부모
커밋
32fc8ccf7c
1개의 변경된 파일18개의 추가작업 그리고 13개의 파일을 삭제
  1. 18 13
      src/Cameras/Inputs/freeCameraTouchInput.ts

+ 18 - 13
src/Cameras/Inputs/freeCameraTouchInput.ts

@@ -163,19 +163,24 @@ export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
      * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
      */
     public checkInputs(): void {
-        if (this._offsetX && this._offsetY) {
-            var camera = this.camera;
-            camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
-
-            if (this._pointerPressed.length > 1) {
-                camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
-            } else {
-                var speed = camera._computeLocalCameraSpeed();
-                var direction = new Vector3(0, 0, speed * this._offsetY / this.touchMoveSensibility);
-
-                Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
-                camera.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
-            }
+        if (this._offsetX === null || this._offsetY === null) {
+            return;
+        }
+        if (this._offsetX === 0 && this._offsetY === 0) {
+            return;
+        }
+
+        var camera = this.camera;
+        camera.cameraRotation.y = this._offsetX / this.touchAngularSensibility;
+
+        if (this._pointerPressed.length > 1) {
+            camera.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
+        } else {
+            var speed = camera._computeLocalCameraSpeed();
+            var direction = new Vector3(0, 0, speed * this._offsetY / this.touchMoveSensibility);
+
+            Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
+            camera.cameraDirection.addInPlace(Vector3.TransformCoordinates(direction, camera._cameraRotationMatrix));
         }
     }