Dad72 Posted November 15, 2016 Share Posted November 15, 2016 Hello, I would like to serialize the scene but exclude terrain generated by heightmap. My goal would be to generate a file for the ground and another for the rest of the scene. I thought if it was possible to add an option to: Quote BABYLON.SceneSerializer Serialize(scene, excludeMesh); // With arry for excludeMesh And to do better, by adding an array to excludeMesh, one could even exclude several objects which would be better. What do you think about the Deltakosh idea? Thank you Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 15, 2016 Share Posted November 15, 2016 I have an idea. Please look at https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.sceneSerializer.js#L20 We can make that IF statement... return FALSE... I think... var tmpsto = BABYLON.Geometry.Primitives.Ground; BABYLON.Geometry.Primitives.Ground = 0; // do serialize here BABYLON.Geometry.Primitives.Ground = tmpsto; In theory, this should cause the serializer to ignore grounds. Not sure, though. Kind of crazy idea. You could also add property to Babylon.Node... perhaps Node.SerializationRoute. Then, re-code BJS serializer (or use custom). Similar-to steerable chute on the back of a Ready-Mix cement truck. For each node serialization, if node.serializationRoute = "pile2" then output to pile #2. Else output to pile #1. Also weird. Perhaps... BJS serializer could have customOutputRouter add-on. Similar to particleSystem.customUpdateFunction. User could easily write a custom output router for the serializer. *shrug* Just some goofy Wingnut ideas. Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 15, 2016 Author Share Posted November 15, 2016 This could be an idea, I will try, but I would love to know what Deltakosh thinks of the idea of excluding objects from the scene serializer. May be that I can attempt to create a PR for this if DK does not have time to do so. I did this by taking up your idea Wingnut: var tmpsto = BABYLON.Geometry.Primitives.Ground; BABYLON.Geometry.Primitives.Ground = 0; var serializedScene = BABYLON.SceneSerializer.Serialize(global.scene); BABYLON.Geometry.Primitives.Ground = tmpsto; var serializedGround = BABYLON.SceneSerializer.SerializeMesh(global.terrain); var str_scene = JSON.stringify(serializedScene); var str_ground = JSON.stringify(serializedGround); Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 15, 2016 Share Posted November 15, 2016 ExcludedMeshes would be somewhat weak. ExcludedNodes might be better. Include/Exclude lights and cameras, too. Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 15, 2016 Author Share Posted November 15, 2016 Yes indeed. I would need to exclude a grid as well: BABYLON.MeshBuilder.CreateLineSystem But I do not see how to do it with the same idea. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 15, 2016 Share Posted November 15, 2016 LinesMesh might be done in line 33... https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.sceneSerializer.js#L33 You could add some LinesMesh to a scene, and do some tests. I have another idea. linesMesh._geometry.serializeVerticeData = function() { return; } That should kill it dead. heh Notice I recently edited this. I removed parentheses after serializeVerticeData Dad72 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted November 15, 2016 Share Posted November 15, 2016 You would probably want to take into account child meshes too. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 17, 2016 Share Posted November 17, 2016 On 2016-11-15 at 2:53 PM, Dad72 said: Hello, I would like to serialize the scene but exclude terrain generated by heightmap. My goal would be to generate a file for the ground and another for the rest of the scene. I thought if it was possible to add an option to: And to do better, by adding an array to excludeMesh, one could even exclude several objects which would be better. What do you think about the Deltakosh idea? Thank you I have another idea for this to. I believe that you are talking about exluding things from within your editor @Dad72 ? Why we not have: BABYLON.SceneSerializer Serialize(scene, excludePrefix); Example. BABYLON.SceneSerializer Serialize(scene, "_"); Every thing that starts with an underscore will be ignored by the serializer(IF excludePrefix is set). If there is an id of _myEditorMesh, then this mesh will be exluded from the serialization(IF excludePrefix is set). Since everything has an id, this would be the easyest thing to implement i think. What you all think about that? EDIT: excludePrefix could be an array to maybe? Example: If you created an editor.... You use some meshes and materials as defaults in your editor..... You as a developer sets the editors meshes id's to eg: _myEditorMeshes1 and _myEditorMeshes2 You as a developer sets the editors materials id's to eg: _myEditorMaterials1 and _myEditorMaterials2 In your editor a user creates meshes and materials (BUT you restict the use of the prefix).(User can not create meshes with an id that starts with _myEditorMeshes, and the user can not create materials with an id that starts with _myEditorMaterials). eg:BABYLON.SceneSerializer Serialize(scene, "_myEditorMeshes,_myEditorMaterials"); Now....when serialized... all things are serialized, but not the editors meshes or materials.(if excludePrefix is set) If excludePrefix is NOT set, then everything is serialized. max123 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 17, 2016 Author Share Posted November 17, 2016 Hello GigiHz, You idea seems good. It is a can the idea that I made. Think you do it? @Deltakosh What do you think of the above idea? Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 18, 2016 Share Posted November 18, 2016 Hi @Dad72. Hmmmmm......i not get you. " It is a can the idea that I made "??? Think i can do what? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 18, 2016 Author Share Posted November 18, 2016 Make a PR with your idea. Sorry, if my English is not very good sometimes, I use a translator that is not always very good. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 18, 2016 Share Posted November 18, 2016 @Dad72 You think that my idea is better than your's? Let's first see what @Deltakosh think about both of our idea's. Anyway....if we do this, then we need to discuss further. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 18, 2016 Share Posted November 18, 2016 I would prefer adding a Node.doNotSerialize property Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 18, 2016 Author Share Posted November 18, 2016 It is even better in my opinion. Thanks DK Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 19, 2016 Share Posted November 19, 2016 So you understand what DeltaKosh mean @Dad72? Could you give me an example Dad72? Because i do not completely get what DeltaKosh mean. And.....Who will do this implementation? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 19, 2016 Author Share Posted November 19, 2016 Simple, in fact it will suffice to do for example: mesh.doNotSerialize = true; and when serializing, the object or node will not serialize. Is that your DK idea, if I'm not mistaken? Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 19, 2016 Share Posted November 19, 2016 @Dad72 mesh.doNotSerialize = true; That will only exlude 1 mesh? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 19, 2016 Author Share Posted November 19, 2016 Yes, it is enough to exclude all the objects that you want then. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 19, 2016 Share Posted November 19, 2016 I don't get it. From your original post here you wanted to be able to exclude only 1 mesh or to have to option to exclude many meshes? I don't see the point in implementing functionality for excluding only 1 mesh. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 19, 2016 Share Posted November 19, 2016 Let me explain how i have to do when i serialize a scene from my editor as the serialisation works right now. 1.Before i serialize my scene, i have to remove all my meshes, materials and editor camera that my editor is using from the scene. 2. Then i do the serialization. 3. I have to recreate my meshes,materials and editor camera that my editor is using. Note: The meshes in my editor are pseudo meshes for showing where light's and cameras are in the scene. And the materials are materials for giving those meshes a different look. Conclusion: If we get an implementation of a functionality to the serilazer, then people with editors don't have to do these steps (1 to 3). Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2016 Share Posted November 21, 2016 In this case, before serializing your scene, you just need to go through all your pseudo meshes and do myMesh.doNotSerialize = true and that's it No need for delete/recreate Dad72 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2016 Share Posted November 21, 2016 https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.sceneSerializer.ts#L330 aWeirdo and Dad72 2 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 21, 2016 Share Posted November 21, 2016 @Deltakosh I see that you allready started to implement this yes. For cameras, lights and meshes. What about materials, instances and textures? I think it would be good to have the option to not serialize materials, instances or textures to. (Maybe multimaterials to?). doNotSerialize is a property of a mesh,light,camera? Same as eg: camera.fov = 0.8 camera.doNotSerialize = true; I think your solution is a great idea, and @dad72 will be happy to about this. Dad72 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2016 Share Posted November 21, 2016 material and textures are tied to mesh. So if the mesh is not serialized then the textures and material attached to it won't be serialized either. (Yes doNotSerialize is a property :)) Dad72 1 Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted November 21, 2016 Share Posted November 21, 2016 And instances of a mesh will not be serialized either? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.