Browse Source

Introducing pinchDeltaPercentage

David Catuhe 7 years ago
parent
commit
19d2adf834

File diff suppressed because it is too large
+ 3263 - 3257
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 3263 - 3257
dist/preview release/babylon.module.d.ts


+ 3 - 3
src/Cameras/Inputs/babylon.arcRotateCameraMouseWheelInput.ts

@@ -9,11 +9,11 @@ module BABYLON {
         public wheelPrecision = 3.0;
 
         /**
-         * wheelPrecisionPercentage will be used instead of whellPrecision if different from 0. 
+         * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0. 
          * It defines the percentage of current camera.radius to use as delta when wheel is used.
          */
         @serialize()
-        public wheelPrecisionPercentage = 0;
+        public wheelDeltaPercentage = 0;
 
         public attachControl(element: HTMLElement, noPreventDefault?: boolean) {
             this._wheel = (p, s) => {
@@ -23,7 +23,7 @@ module BABYLON {
                 var delta = 0;
 
                 if (event.wheelDelta) {
-                    delta = this.wheelPrecisionPercentage ? (event.wheelDelta * 0.01) * this.camera.radius * this.wheelPrecisionPercentage : event.wheelDelta / (this.wheelPrecision * 40);
+                    delta = this.wheelDeltaPercentage ? (event.wheelDelta * 0.01) * this.camera.radius * this.wheelDeltaPercentage : event.wheelDelta / (this.wheelPrecision * 40);
                 } else if (event.detail) {
                     delta = -event.detail / this.wheelPrecision;
                 }

+ 21 - 8
src/Cameras/Inputs/babylon.arcRotateCameraPointersInput.ts

@@ -16,6 +16,13 @@ module BABYLON {
         @serialize()
         public pinchPrecision = 12.0;
 
+        /**
+         * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0. 
+         * It defines the percentage of current camera.radius to use as delta when wheel is used.
+         */        
+        @serialize()
+        public pinchDeltaPercentage = 0;
+
         @serialize()
         public panningSensibility: number = 1000.0;
 
@@ -171,12 +178,15 @@ module BABYLON {
                         }
 
                         if (this.multiTouchPanAndZoom) {
-                            this.camera
-                                .inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
+                            if (this.pinchDeltaPercentage) {
+                                this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) * this.camera.radius * this.pinchDeltaPercentage; 
+                            } else {
+                                this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
                                 (this.pinchPrecision *
                                     ((this.angularSensibilityX + this.angularSensibilityY) / 2) *
                                     direction);
-                            
+                                }
+
                             if (this.panningSensibility !== 0) {
                                 var pointersCenterX = (pointA.x + pointB.x) / 2;
                                 var pointersCenterY = (pointA.y + pointB.y) / 2;
@@ -194,11 +204,14 @@ module BABYLON {
                             twoFingerActivityCount++;
 
                             if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > this.camera.pinchToPanMaxDistance)) {                   
-                                this.camera
-                                .inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
-                                (this.pinchPrecision *
-                                    ((this.angularSensibilityX + this.angularSensibilityY) / 2) *
-                                    direction);
+                                if (this.pinchDeltaPercentage) {
+                                    this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) * this.camera.radius * this.pinchDeltaPercentage;
+                                } else {
+                                    this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
+                                    (this.pinchPrecision *
+                                        ((this.angularSensibilityX + this.angularSensibilityY) / 2) *
+                                        direction);
+                                }
                                 previousMultiTouchPanPosition.isPaning = false;
                                 previousMultiTouchPanPosition.isPinching = true;
                             }

+ 13 - 0
src/Cameras/babylon.arcRotateCamera.ts

@@ -108,6 +108,19 @@ module BABYLON {
             }
         }
 
+        public get pinchDeltaPercentage(): number {
+            var pointers = <ArcRotateCameraPointersInput>this.inputs.attached["pointers"];
+            if (pointers)
+                return pointers.pinchDeltaPercentage;
+        }
+
+        public set pinchDeltaPercentage(value: number) {
+            var pointers = <ArcRotateCameraPointersInput>this.inputs.attached["pointers"];
+            if (pointers) {
+                pointers.pinchDeltaPercentage = value;
+            }
+        }        
+
         public get panningSensibility(): number {
             var pointers = <ArcRotateCameraPointersInput>this.inputs.attached["pointers"];
             if (pointers)