Dad72 Posted May 31, 2018 Share Posted May 31, 2018 I have some problem when I serialize a terrain. then the serialized data is not reloaded with ImportMesh. As soon as there is a texture on the ground, the serialization it passes bad. The only time it works is when a texture is not added. For exemple : With no material : If I take the case of a simple ground with CreateGround() it will work (Because no textures are added here) . But if I create now with CreateGroundFromHeightMap() it will not work (Here we add a texture) http://www.babylonjs-playground.com/#1SQFJP#16 With TerrainMaterial : If I create a terrain and use TerrainMaterial, this time neither CreateGround() and CreateGroundFromHeightMap() will not work for serialization for reloading with ImportMesh (Here we add textures with the materials) https://www.babylonjs-playground.com/#E6OZX#191 With MixMaterial : Same thing if I use MixMaterial instead CreateGround() and CreateGroundFromHeightMap() will not work for serialization for reloading with ImportMesh (Here also we add textures with the materials) https://www.babylonjs-playground.com/#E6OZX#190 Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted May 31, 2018 Share Posted May 31, 2018 Just wait for the ground to be ready before serializing it, else you serialize empty mesh: http://www.babylonjs-playground.com/#1SQFJP#17 Pinging @Luaacro for serialization issues with Terrain and mix materials Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 1, 2018 Share Posted June 1, 2018 It looks like the error comes from mesh serialization. When I serialize the entire scene and reload it works: https://www.babylonjs-playground.com/#E6OZX#193 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 1, 2018 Author Share Posted June 1, 2018 I wanted to serialize only the mesh and not the scene because the file is bigger. I record using PHP and I wanted to create a file with just the mesh because my editor create the basic scene with camera, light .... Why this does not serialize the mesh correctly, should it? Is there a bug in the mesh serializer? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 1, 2018 Author Share Posted June 1, 2018 Ok, I find why. we would say that the material that is relaunching in the json serializer is missing. If I do that, it works: let serialization = BABYLON.SceneSerializer.SerializeMesh(ground); serialization.materials = []; let str_serialized = JSON.stringify(serialization); I think that is missing in the mesh serializer https://www.babylonjs-playground.com/#E6OZX#196 Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 1, 2018 Share Posted June 1, 2018 @Deltakosh is that the wanted behavior ? Quote Link to comment Share on other sites More sharing options...
Guest Posted June 1, 2018 Share Posted June 1, 2018 Serializing a mesh should not serialize the materials, (I think) You can serialize the material as well if you want right? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 1, 2018 Author Share Posted June 1, 2018 But this will create a bug if the material is not serialized, because the name is referenced in the serialized file (in "materialId":"terrainMixMaterial"), but it does not exist of material which is search by the serializer by searching for terrainMixMaterial, so this creates a bug. because add serialise.materials = [] => all material is serialized. Maybe an option would help. so I think there is a bug because no material is serialized with the mesh. I think that when we serialize a mesh, the texture it contains must also. Why else a material should not be serialized with the mesh? We lose all the mesh that is incomplete. When we serialize a scene, we serialize all the materials as well. Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted June 1, 2018 Share Posted June 1, 2018 I'm fine with that @Luaacro do you want to give it a try? Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 2, 2018 Share Posted June 2, 2018 I will tomorrow Adding an option looks cool, with a default value to false. I have to see the existing code to see if I can have a better idea Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted June 4, 2018 Share Posted June 4, 2018 Fixed https://github.com/BabylonJS/Babylon.js/pull/4424 Dad72 1 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.