瀏覽代碼

Fixing issues with debuglayer and multiple cameras

David Catuhe 10 年之前
父節點
當前提交
7edd9a0ddb

+ 1 - 1
Babylon/Animations/babylon.animation.js

@@ -32,7 +32,7 @@ var BABYLON;
                 dataType = Animation.ANIMATIONTYPE_COLOR3;
             }
             if (dataType == undefined) {
-                return;
+                return null;
             }
             var animation = new Animation(name, tartgetProperty, framePerSecond, dataType, loopMode);
             var keys = [];

+ 1 - 1
Babylon/Animations/babylon.animation.ts

@@ -29,7 +29,7 @@
             }
 
             if (dataType == undefined) {
-                return;
+                return null;
             }
 
             var animation = new Animation(name, tartgetProperty, framePerSecond, dataType, loopMode);

+ 7 - 0
Babylon/Cameras/babylon.camera.js

@@ -31,6 +31,7 @@ var BABYLON;
             this._projectionMatrix = new BABYLON.Matrix();
             this._postProcesses = new Array();
             this._postProcessesTakenIndices = [];
+            this._activeMeshes = new BABYLON.SmartArray(256);
             scene.cameras.push(this);
             if (!scene.activeCamera) {
                 scene.activeCamera = this;
@@ -64,6 +65,12 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Camera.prototype.getActiveMeshes = function () {
+            return this._activeMeshes;
+        };
+        Camera.prototype.isActiveMesh = function (mesh) {
+            return (this._activeMeshes.indexOf(mesh) !== -1);
+        };
         //Cache
         Camera.prototype._initCache = function () {
             _super.prototype._initCache.call(this);

+ 10 - 0
Babylon/Cameras/babylon.camera.ts

@@ -46,6 +46,8 @@
         public _postProcesses = new Array<PostProcess>();
         public _postProcessesTakenIndices = [];
 
+        public _activeMeshes = new SmartArray<Mesh>(256);
+
         constructor(name: string, public position: Vector3, scene: Scene) {
             super(name, scene);
 
@@ -56,6 +58,14 @@
             }
         }
 
+        public getActiveMeshes(): SmartArray<Mesh> {
+            return this._activeMeshes;
+        }
+
+        public isActiveMesh(mesh: Mesh): boolean {
+            return (this._activeMeshes.indexOf(mesh) !== -1);
+        }
+
         //Cache
         public _initCache() {
             super._initCache();

+ 1 - 1
Babylon/Debug/babylon.debugLayer.js

@@ -89,7 +89,7 @@ var BABYLON;
                     var viewport = _this._camera.viewport;
                     var globalViewport = viewport.toGlobal(engine);
                     // Meshes
-                    var meshes = _this._scene.getActiveMeshes();
+                    var meshes = _this._camera.getActiveMeshes();
                     for (var index = 0; index < meshes.length; index++) {
                         var mesh = meshes.data[index];
                         var position = mesh.getBoundingInfo().boundingSphere.center;

文件差異過大導致無法顯示
+ 1 - 1
Babylon/Debug/babylon.debugLayer.js.map


+ 1 - 1
Babylon/Debug/babylon.debugLayer.ts

@@ -142,7 +142,7 @@
                     var globalViewport = viewport.toGlobal(engine);
 
                     // Meshes
-                    var meshes = this._scene.getActiveMeshes();
+                    var meshes = this._camera.getActiveMeshes();
                     for (var index = 0; index < meshes.length; index++) {
                         var mesh = meshes.data[index];
 

+ 2 - 0
Babylon/babylon.scene.js

@@ -785,6 +785,7 @@ var BABYLON;
             }
         };
         Scene.prototype._evaluateActiveMeshes = function () {
+            this.activeCamera._activeMeshes.reset();
             this._activeMeshes.reset();
             this._renderingManager.reset();
             this._processedMaterials.reset();
@@ -831,6 +832,7 @@ var BABYLON;
                 mesh._preActivate();
                 if (mesh.isEnabled() && mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && mesh.isInFrustum(this._frustumPlanes)) {
                     this._activeMeshes.push(mesh);
+                    this.activeCamera._activeMeshes.push(mesh);
                     mesh._activate(this._renderId);
                     this._activeMesh(meshLOD);
                 }

+ 2 - 0
Babylon/babylon.scene.ts

@@ -1020,6 +1020,7 @@
         }
 
         private _evaluateActiveMeshes(): void {
+            this.activeCamera._activeMeshes.reset();
             this._activeMeshes.reset();
             this._renderingManager.reset();
             this._processedMaterials.reset();
@@ -1077,6 +1078,7 @@
 
                 if (mesh.isEnabled() && mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && mesh.isInFrustum(this._frustumPlanes)) {
                     this._activeMeshes.push(mesh);
+                    this.activeCamera._activeMeshes.push(mesh);
                     mesh._activate(this._renderId);
 
                     this._activeMesh(meshLOD);

文件差異過大導致無法顯示
+ 12 - 3
babylon.2.1-alpha.debug.js


文件差異過大導致無法顯示
+ 8 - 8
babylon.2.1-alpha.js