瀏覽代碼

Fixed BABYLON.Camera
Changed 'r ? true :' by another way to rewrite it: 'r ||'
Fixed missing ( and {

Gwenaël Hagenmuller 11 年之前
父節點
當前提交
25003b79c0
共有 3 個文件被更改,包括 16 次插入6 次删除
  1. 13 3
      Babylon/Cameras/babylon.camera.js
  2. 1 1
      Babylon/Mesh/babylon.mesh.js
  3. 2 2
      Babylon/babylon.node.js

+ 13 - 3
Babylon/Cameras/babylon.camera.js

@@ -90,13 +90,16 @@ var BABYLON = BABYLON || {};
         this._cache.maxZ = this.maxZ;
 
         this._cache.fov = this.fov;
+
+        var engine = this._scene.getEngine();
+
         this._cache.aspectRatio = engine.getAspectRatio();
 
         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.renderWidth = engine.getRenderWidth();
         this._cache.renderHeight = engine.getRenderHeight();
     };
 
@@ -121,6 +124,9 @@ var BABYLON = BABYLON || {};
         if (!r)
             return false;
 
+
+        var engine = this._scene.getEngine();
+
         if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
             r = this._cache.fov === this.fov
                  && this._cache.aspectRatio === engine.getAspectRatio();
@@ -152,11 +158,11 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Camera.prototype.getWorldMatrix = function () {
-        var viewMatrix = this.getViewMatrix();
-
         if (!this._worldMatrix) {
             this._worldMatrix = BABYLON.Matrix.Identity();
         }
+        
+        var viewMatrix = this.getViewMatrix();
 
         viewMatrix.invertToRef(this._worldMatrix);
 
@@ -175,6 +181,10 @@ var BABYLON = BABYLON || {};
             || (!this.hasNewParent() && this.parent.isSynchronized())) {
             return this._computedViewMatrix;
         }
+
+        if (!this._worldMatrix) {
+            this._worldMatrix = BABYLON.Matrix.Identity();
+        }
         
         this._computedViewMatrix.invertToRef(this._worldMatrix);
 

+ 1 - 1
Babylon/Mesh/babylon.mesh.js

@@ -1349,7 +1349,7 @@ var BABYLON = BABYLON || {};
         return ground;
     };
     
-    BABYLON.Mesh.prototype._initCache = function (
+    BABYLON.Mesh.prototype._initCache = function () {
         this._cache.localMatrixUpdated = false;
         this._cache.position = BABYLON.Vector3.Zero();
         this._cache.scaling = BABYLON.Vector3.Zero();

+ 2 - 2
Babylon/babylon.node.js

@@ -50,9 +50,9 @@ var BABYLON = BABYLON || {};
     BABYLON.Node.prototype.isSynchronized = function (updateCache) {
         var r = this.hasNewParent();
 
-        r = r ? true : (this.parent && this.parent._needToSynchonizeChildren());
+        r = r || (this.parent && this.parent._needToSynchonizeChildren());
         
-        r = r ? true : !this._isSynchronized();
+        r = r || !this._isSynchronized();
         
         if(updateCache)
             this.updateCache(true);