Sfoglia il codice sorgente

Merge pull request #913 from RaananW/arcRotate-Panning

PanningAxis introduced
David Catuhe 9 anni fa
parent
commit
769dc7dcbd

+ 4 - 1
src/Cameras/babylon.arcRotateCamera.js

@@ -41,6 +41,8 @@ var BABYLON;
             this.allowUpsideDown = true;
             this._keys = [];
             this._viewMatrix = new BABYLON.Matrix();
+            // Panning
+            this.panningAxis = new BABYLON.Vector3(1, 0, 1);
             this._isRightClick = false;
             this._isCtrlPushed = false;
             this.checkCollisions = false;
@@ -402,9 +404,10 @@ var BABYLON;
                     this.inertialPanningX = 0;
                 if (Math.abs(this.inertialPanningY) < BABYLON.Engine.Epsilon)
                     this.inertialPanningY = 0;
-                this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, 0);
+                this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
                 this._viewMatrix.invertToRef(this._cameraTransformMatrix);
                 BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
+                this._transformedDirection.multiplyInPlace(this.panningAxis);
                 this.target.addInPlace(this._transformedDirection);
             }
             // Limits

+ 3 - 1
src/Cameras/babylon.arcRotateCamera.ts

@@ -46,6 +46,7 @@
         private _MSGestureHandler: MSGesture;
 
         // Panning
+        public panningAxis: Vector3 = new Vector3(1, 0, 1);
         private _localDirection: Vector3;
         private _transformedDirection: Vector3;
         private _isRightClick: boolean = false;
@@ -438,9 +439,10 @@
                 if (Math.abs(this.inertialPanningY) < Engine.Epsilon)
                     this.inertialPanningY = 0;
 
-                this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, 0);
+                this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
                 this._viewMatrix.invertToRef(this._cameraTransformMatrix);
                 Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
+                this._transformedDirection.multiplyInPlace(this.panningAxis);
                 this.target.addInPlace(this._transformedDirection);
             }