瀏覽代碼

Use of Number.MAX_VALUE instead of Infinity to be consistent with other parts of the code
Improved BABYLON.Camera.prototype._isSynchronizedProjectionMatrix

Julien 11 年之前
父節點
當前提交
bb38d8666d
共有 3 個文件被更改,包括 19 次插入19 次删除
  1. 1 1
      Babylon/Cameras/babylon.arcRotateCamera.js
  2. 16 16
      Babylon/Cameras/babylon.camera.js
  3. 2 2
      Babylon/Cameras/babylon.freeCamera.js

+ 1 - 1
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -46,7 +46,7 @@ var BABYLON = BABYLON || {};
     
     // Cache
     BABYLON.ArcRotateCamera.prototype._initCache = function () {
-        this._cache.target = new BABYLON.Vector3(-Infinity, -Infinity,-Infinity);
+        this._cache.target = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
         this._cache.alpha = undefined;
         this._cache.beta = undefined;
         this._cache.radius = undefined;

+ 16 - 16
Babylon/Cameras/babylon.camera.js

@@ -60,8 +60,8 @@ var BABYLON = BABYLON || {};
     
     //Cache
     BABYLON.Camera.prototype._initCache = function () {
-        this._cache.position = new BABYLON.Vector3(-Infinity, -Infinity,-Infinity);
-        this._cache.upVector = new BABYLON.Vector3(-Infinity, -Infinity,-Infinity);
+        this._cache.position = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+        this._cache.upVector = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
 
         this._cache.mode = undefined;
         this._cache.minZ = undefined;
@@ -117,22 +117,22 @@ var BABYLON = BABYLON || {};
         var r = this._cache.mode === this.mode
              && this._cache.minZ === this.minZ
              && this._cache.maxZ === this.maxZ;
+             
+        if (!r)
+            return false;
 
-        if (r) {
-            if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
-                r = r & this._cache.fov === this.fov
-                     && this._cache.aspectRatio === engine.getAspectRatio();
-            }
-            else {
-                r = r & this._cache.orthoLeft === this.orthoLeft
-                     && this._cache.orthoRight === this.orthoRight
-                     && this._cache.orthoBottom === this.orthoBottom
-                     && this._cache.orthoTop === this.orthoTop
-                     && this._cache.renderWidth === engine.getRenderWidth()
-                     && this._cache.renderHeight === engine.getRenderHeight();
-            }
+        if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
+            r = this._cache.fov === this.fov
+                 && this._cache.aspectRatio === engine.getAspectRatio();
+        }
+        else {
+            r = this._cache.orthoLeft === this.orthoLeft
+                 && this._cache.orthoRight === this.orthoRight
+                 && this._cache.orthoBottom === this.orthoBottom
+                 && this._cache.orthoTop === this.orthoTop
+                 && this._cache.renderWidth === engine.getRenderWidth()
+                 && this._cache.renderHeight === engine.getRenderHeight();
         }
-
         return r;
     };
 

+ 2 - 2
Babylon/Cameras/babylon.freeCamera.js

@@ -58,8 +58,8 @@ var BABYLON = BABYLON || {};
 
     // Cache
     BABYLON.FreeCamera.prototype._initCache = function () {
-        this._cache.lockedTarget = new BABYLON.Vector3(-Infinity, -Infinity,-Infinity);
-        this._cache.rotation = new BABYLON.Vector3(-Infinity, -Infinity,-Infinity);
+        this._cache.lockedTarget = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+        this._cache.rotation = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
     };
 
     BABYLON.FreeCamera.prototype._updateCache = function (ignoreParentClass) {