瀏覽代碼

Add boundingInfo to meshes without geometries

Gwenaël Hagenmuller 11 年之前
父節點
當前提交
74a7ac8cf7
共有 1 個文件被更改,包括 11 次插入10 次删除
  1. 11 10
      Babylon/Mesh/babylon.mesh.js

+ 11 - 10
Babylon/Mesh/babylon.mesh.js

@@ -294,20 +294,21 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Mesh.prototype._updateBoundingInfo = function () {
-        if (this._boundingInfo) {
-            this._scaleFactor = Math.max(this.scaling.x, this.scaling.y);
-            this._scaleFactor = Math.max(this._scaleFactor, this.scaling.z);
+        
+        this._boundingInfo = this._boundingInfo || new BABYLON.BoundingInfo(this._absolutePosition, this._absolutePosition);
+        
+        this._scaleFactor = Math.max(this.scaling.x, this.scaling.y);
+        this._scaleFactor = Math.max(this._scaleFactor, this.scaling.z);
 
-            if (this.parent && this.parent._scaleFactor)
-                this._scaleFactor = this._scaleFactor * this.parent._scaleFactor;
+        if (this.parent && this.parent._scaleFactor)
+            this._scaleFactor = this._scaleFactor * this.parent._scaleFactor;
 
-            this._boundingInfo._update(this._worldMatrix, this._scaleFactor);
+        this._boundingInfo._update(this._worldMatrix, this._scaleFactor);
 
-            for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
-                var subMesh = this.subMeshes[subIndex];
+        for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
+            var subMesh = this.subMeshes[subIndex];
 
-                subMesh.updateBoundingInfo(this._worldMatrix, this._scaleFactor);
-            }
+            subMesh.updateBoundingInfo(this._worldMatrix, this._scaleFactor);
         }
     };