Pārlūkot izejas kodu

Removing disposed meshes from light.excluded and included lists

David Catuhe 9 gadi atpakaļ
vecāks
revīzija
d2e8f2f7a4

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 19 - 19
dist/preview release/babylon.core.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1272 - 1272
dist/preview release/babylon.d.ts


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 25 - 25
dist/preview release/babylon.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 30 - 1
dist/preview release/babylon.max.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 24 - 24
dist/preview release/babylon.noworker.js


+ 16 - 0
src/Lights/babylon.light.js

@@ -111,6 +111,19 @@ var BABYLON;
             if (this.parent) {
                 serializationObject.parentId = this.parent.id;
             }
+            // Inclusion / exclusions
+            if (this.excludedMeshes.length > 0) {
+                serializationObject.excludedMeshesIds = [];
+                this.excludedMeshes.forEach(function (mesh) {
+                    serializationObject.excludedMeshesIds.push(mesh.id);
+                });
+            }
+            if (this.includedOnlyMeshes.length > 0) {
+                serializationObject.includedOnlyMeshesIds = [];
+                this.includedOnlyMeshes.forEach(function (mesh) {
+                    serializationObject.includedOnlyMeshesIds.push(mesh.id);
+                });
+            }
             // Animations  
             BABYLON.Animation.AppendSerializedAnimations(this, serializationObject);
             serializationObject.ranges = this.serializeAnimationRanges();
@@ -171,6 +184,9 @@ var BABYLON;
         ], Light.prototype, "includeOnlyWithLayerMask", void 0);
         __decorate([
             BABYLON.serialize()
+        ], Light.prototype, "excludeWithLayerMask", void 0);
+        __decorate([
+            BABYLON.serialize()
         ], Light.prototype, "radius", void 0);
         return Light;
     })(BABYLON.Node);

+ 17 - 0
src/Lights/babylon.light.ts

@@ -38,6 +38,8 @@
 
         public includedOnlyMeshes = new Array<AbstractMesh>();
         public excludedMeshes = new Array<AbstractMesh>();
+
+        @serialize()
         public excludeWithLayerMask = 0;
 
         // PBR Properties.
@@ -164,6 +166,21 @@
                 serializationObject.parentId = this.parent.id;
             }
 
+            // Inclusion / exclusions
+            if (this.excludedMeshes.length > 0) {
+                serializationObject.excludedMeshesIds = [];
+                this.excludedMeshes.forEach((mesh: AbstractMesh) => {
+                    serializationObject.excludedMeshesIds.push(mesh.id);
+                });
+            }
+
+            if (this.includedOnlyMeshes.length > 0) {
+                serializationObject.includedOnlyMeshesIds = [];
+                this.includedOnlyMeshes.forEach((mesh: AbstractMesh) => {
+                    serializationObject.includedOnlyMeshesIds.push(mesh.id);
+                });
+            }
+
             // Animations  
             Animation.AppendSerializedAnimations(this, serializationObject);
             serializationObject.ranges = this.serializeAnimationRanges();  

+ 13 - 0
src/Mesh/babylon.abstractMesh.js

@@ -909,6 +909,7 @@ var BABYLON;
             }
         };
         AbstractMesh.prototype.dispose = function (doNotRecurse) {
+            var _this = this;
             var index;
             // Action manager
             if (this.actionManager) {
@@ -930,6 +931,18 @@ var BABYLON;
                 other._intersectionsInProgress.splice(pos, 1);
             }
             this._intersectionsInProgress = [];
+            // Lights
+            var lights = this.getScene().lights;
+            lights.forEach(function (light) {
+                var meshIndex = light.includedOnlyMeshes.indexOf(_this);
+                if (meshIndex !== -1) {
+                    light.includedOnlyMeshes.splice(meshIndex, 1);
+                }
+                meshIndex = light.excludedMeshes.indexOf(_this);
+                if (meshIndex !== -1) {
+                    light.excludedMeshes.splice(meshIndex, 1);
+                }
+            });
             // Edges
             if (this._edgesRenderer) {
                 this._edgesRenderer.dispose();

+ 17 - 0
src/Mesh/babylon.abstractMesh.ts

@@ -1093,6 +1093,23 @@
 
             this._intersectionsInProgress = [];
 
+            // Lights
+            var lights = this.getScene().lights;
+
+            lights.forEach((light: Light) => {
+                var meshIndex = light.includedOnlyMeshes.indexOf(this);
+
+                if (meshIndex !== -1) {
+                    light.includedOnlyMeshes.splice(meshIndex, 1);
+                }
+
+                meshIndex = light.excludedMeshes.indexOf(this);
+
+                if (meshIndex !== -1) {
+                    light.excludedMeshes.splice(meshIndex, 1);
+                }
+            });
+
             // Edges
             if (this._edgesRenderer) {
                 this._edgesRenderer.dispose();