MarianG Posted February 16, 2018 Share Posted February 16, 2018 Hi. I have two scene. In the first scene I configure the object from babylon basic elements and csg, I serialize it and upload it to server. All good In the second scene I import the serialized object from first scene. All good again. But in the first scene I set some flags to the object and after I serialize it, they gone, ... no problem I add them manual. like that. var myser = BABYLON.SceneSerializer.SerializeMesh(component, false, true); var jsonData = JSON.stringify($.extend({}, myser, {"setings":settings})); And it works again but when I use SceneLoader.ImportMesh I get only the informations from "myser", and this is somewhat expected. But my question is, how can I hack the ImportMesh function to access "setings" property too? Or can I add the flags from 'seting' to my original mesh before to serialize, and it don;t lose them when I serialize it? Thank you guys Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 16, 2018 Share Posted February 16, 2018 Hiya MG... sorry for the slow replies. I think you can use node.metadata as a "suitcase" that will serialize/de-serialize just fine. Would that work? You can put "stuff" inside any mesh.metadata, camera.metadata, or light.metadata. So maybe, before you serialize scene1... do... var bigFatObject = anything; (maybe bigFatObject.installExtraSettings() is a function on that obj) var myInvisibleDatabase = new BABYLON.Mesh("blank", scene); myInvisibleDatabase.metadata = bigFatObject; When scene is imported, you should be able to run a pre-installed function... myInvisibleDatabase.metadata.installExtraSettings(). You are better at JSON stuff than I, but... I believe all node.metadata values are "carried-along" with all serializations/imports. Perhaps that will work for you. Holler if you have problems. I hope I am on-subject. MarianG 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted February 16, 2018 Share Posted February 16, 2018 Yes, mesh.metadata is a good solution. I use it and it works very well. MarianG, Arte and GameMonetize 2 1 Quote Link to comment Share on other sites More sharing options...
MarianG Posted February 17, 2018 Author Share Posted February 17, 2018 I did not know about metadata. Thank you for sugestions. I'll make a try, and I'll be back with news. Quote Link to comment Share on other sites More sharing options...
MarianG Posted February 17, 2018 Author Share Posted February 17, 2018 I can confirm, metadata was the trick. It is exactly what I want. Many thanks! Wingnut and GameMonetize 2 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.