Browse Source

Added node.doNotSerialize

David Catuhe 8 years ago
parent
commit
4665edc742

File diff suppressed because it is too large
+ 3 - 3
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 1580 - 1579
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 8 - 8
dist/preview release/babylon.js


+ 11 - 4
dist/preview release/babylon.max.js

@@ -9041,6 +9041,7 @@ var BABYLON;
         function Node(name, scene) {
             this.state = "";
             this.metadata = null;
+            this.doNotSerialize = false;
             this.animations = new Array();
             this._ranges = {};
             this._childrenFlag = -1;
@@ -42383,13 +42384,17 @@ var BABYLON;
             var light;
             for (index = 0; index < scene.lights.length; index++) {
                 light = scene.lights[index];
-                serializationObject.lights.push(light.serialize());
+                if (!light.doNotSerialize) {
+                    serializationObject.lights.push(light.serialize());
+                }
             }
             // Cameras
             serializationObject.cameras = [];
             for (index = 0; index < scene.cameras.length; index++) {
                 var camera = scene.cameras[index];
-                serializationObject.cameras.push(camera.serialize());
+                if (!camera.doNotSerialize) {
+                    serializationObject.cameras.push(camera.serialize());
+                }
             }
             if (scene.activeCamera) {
                 serializationObject.activeCameraID = scene.activeCamera.id;
@@ -42439,8 +42444,10 @@ var BABYLON;
                 var abstractMesh = scene.meshes[index];
                 if (abstractMesh instanceof BABYLON.Mesh) {
                     var mesh = abstractMesh;
-                    if (mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NONE) {
-                        serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                    if (!mesh.doNotSerialize) {
+                        if (mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NONE) {
+                            serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                        }
                     }
                 }
             }

File diff suppressed because it is too large
+ 8 - 8
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -10,6 +10,7 @@
 - New BoneLookController [Demo](http://www.babylonjs-playground.com/#1B1PUZ#13) - ([abow](https://github.com/abow))
 
 ### Updates
+- Added `node.doNotSerialize` to prevent specific nodes to be serialized by `SceneSerializer` ([deltakosh](https://github.com/deltakosh))
 - Added `scene.multiPick` and `scene.multiPickWithRay` to return an array of pickedMesh objects ([deltakosh](https://github.com/deltakosh))
 - Added `Effect.GetVertexShaderSource()` and `Effect.GetFragmentShaderSource()` ([deltakosh](https://github.com/deltakosh))
 - New `Texture.LoadFromDataString()` to help loading base64 encoded textures ([deltakosh](https://github.com/deltakosh))

+ 10 - 4
src/Tools/babylon.sceneSerializer.js

@@ -222,13 +222,17 @@ var BABYLON;
             var light;
             for (index = 0; index < scene.lights.length; index++) {
                 light = scene.lights[index];
-                serializationObject.lights.push(light.serialize());
+                if (!light.doNotSerialize) {
+                    serializationObject.lights.push(light.serialize());
+                }
             }
             // Cameras
             serializationObject.cameras = [];
             for (index = 0; index < scene.cameras.length; index++) {
                 var camera = scene.cameras[index];
-                serializationObject.cameras.push(camera.serialize());
+                if (!camera.doNotSerialize) {
+                    serializationObject.cameras.push(camera.serialize());
+                }
             }
             if (scene.activeCamera) {
                 serializationObject.activeCameraID = scene.activeCamera.id;
@@ -278,8 +282,10 @@ var BABYLON;
                 var abstractMesh = scene.meshes[index];
                 if (abstractMesh instanceof BABYLON.Mesh) {
                     var mesh = abstractMesh;
-                    if (mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NONE) {
-                        serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                    if (!mesh.doNotSerialize) {
+                        if (mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_NONE) {
+                            serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                        }
                     }
                 }
             }

+ 12 - 4
src/Tools/babylon.sceneSerializer.ts

@@ -253,14 +253,20 @@
             var light: Light;
             for (index = 0; index < scene.lights.length; index++) {
                 light = scene.lights[index];
-                serializationObject.lights.push(light.serialize());
+
+                if (!light.doNotSerialize) {
+                    serializationObject.lights.push(light.serialize());
+                }
             }
 
             // Cameras
             serializationObject.cameras = [];
             for (index = 0; index < scene.cameras.length; index++) {
                 var camera = scene.cameras[index];
-                serializationObject.cameras.push(camera.serialize());
+
+                if (!camera.doNotSerialize) {
+                    serializationObject.cameras.push(camera.serialize());
+                }
             }
 
             if (scene.activeCamera) {
@@ -321,8 +327,10 @@
 
                 if (abstractMesh instanceof Mesh) {
                     var mesh = abstractMesh;
-                    if (mesh.delayLoadState === Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === Engine.DELAYLOADSTATE_NONE) {
-                        serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                    if (!mesh.doNotSerialize) {
+                        if (mesh.delayLoadState === Engine.DELAYLOADSTATE_LOADED || mesh.delayLoadState === Engine.DELAYLOADSTATE_NONE) {
+                            serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
+                        }
                     }
                 }
             }

+ 1 - 0
src/babylon.node.js

@@ -18,6 +18,7 @@ var BABYLON;
         function Node(name, scene) {
             this.state = "";
             this.metadata = null;
+            this.doNotSerialize = false;
             this.animations = new Array();
             this._ranges = {};
             this._childrenFlag = -1;

+ 3 - 1
src/babylon.node.ts

@@ -17,7 +17,9 @@
         public state = "";
 
         @serialize()
-        public metadata:any = null;
+        public metadata: any = null;
+
+        public doNotSerialize = false;
 
         public animations = new Array<Animation>();
         private _ranges: { [name: string]: AnimationRange; } = {};