Bläddra i källkod

Updates with PR feedback

Ryan Wedoff 5 år sedan
förälder
incheckning
63f2f3f502
2 ändrade filer med 12 tillägg och 9 borttagningar
  1. 8 7
      src/Cameras/Inputs/arcRotateCameraPointersInput.ts
  2. 4 2
      src/Cameras/arcRotateCamera.ts

+ 8 - 7
src/Cameras/Inputs/arcRotateCameraPointersInput.ts

@@ -59,9 +59,10 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
     public pinchDeltaPercentage = 0;
 
     /**
-     * useNaturalPinchZoom will be used instead of pinchPrecision if set to true.
-     * Pinch natural zoom is a calculation based off the distance of the
-     * pinch and the camera distance.
+     * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
+     * that any object in the plane at the camera's target point will scale
+     * perfectly with finger motion.
+     * Overrides pinchDeltaPercentage and pinchPrecision.
      */
     @serialize()
     public useNaturalPinchZoom: boolean = false;
@@ -143,13 +144,13 @@ export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
         var direction = this.pinchInwards ? 1 : -1;
 
         if (this.multiTouchPanAndZoom) {
-            if (this.pinchDeltaPercentage) {
+            if (this.useNaturalPinchZoom) {
+                this.camera.radius = this.camera.radius *
+                    Math.sqrt(previousPinchSquaredDistance) / Math.sqrt(pinchSquaredDistance);
+            } else if (this.pinchDeltaPercentage) {
                 this.camera.inertialRadiusOffset +=
                     (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
                     this.camera.radius * this.pinchDeltaPercentage;
-            } else if (this.useNaturalPinchZoom) {
-                this.camera.radius = this.camera.radius *
-                    Math.sqrt(previousPinchSquaredDistance) / Math.sqrt(pinchSquaredDistance);
             }
             else {
                 this.camera.inertialRadiusOffset +=

+ 4 - 2
src/Cameras/arcRotateCamera.ts

@@ -299,8 +299,10 @@ export class ArcRotateCamera extends TargetCamera {
 
     /**
      * Gets or Set the pointer use natural pinch zoom to override the pinch precision
-     * and pinch delta percentage. Natural pinch zoom  in uses the distance of the pinch
-     * in relation to the camera distance to determine the zoom.
+     * and pinch delta percentage.
+     * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
+     * that any object in the plane at the camera's target point will scale
+     * perfectly with finger motion.
      */
     public get useNaturalPinchZoom(): boolean {
         var pointers = <ArcRotateCameraPointersInput>this.inputs.attached["pointers"];