Browse Source

Added a inertia epsilon on free camera movment (like in arcRotateCamera).

Julien 11 years ago
parent
commit
51b9cb9307
1 changed files with 15 additions and 0 deletions
  1. 15 0
      Babylon/Cameras/babylon.freeCamera.js

+ 15 - 0
Babylon/Cameras/babylon.freeCamera.js

@@ -344,9 +344,24 @@ var BABYLON = BABYLON || {};
 
         // Inertia
         if (needToMove) {
+            if (Math.abs(this.cameraDirection.x) < BABYLON.Engine.epsilon)
+                this.cameraDirection.x = 0;
+
+            if (Math.abs(this.cameraDirection.y) < BABYLON.Engine.epsilon)
+                this.cameraDirection.y = 0;
+
+            if (Math.abs(this.cameraDirection.z) < BABYLON.Engine.epsilon)
+                this.cameraDirection.z = 0;
+        
             this.cameraDirection.scaleInPlace(this.inertia);
         }
         if (needToRotate) {
+            if (Math.abs(this.cameraRotation.x) < BABYLON.Engine.epsilon)
+                this.cameraRotation.x = 0;
+
+            if (Math.abs(this.cameraRotation.y) < BABYLON.Engine.epsilon)
+                this.cameraRotation.y = 0;
+        
             this.cameraRotation.scaleInPlace(this.inertia);
         }
     };