ChrisR Posted September 9, 2015 Share Posted September 9, 2015 This is a followup from a previous post where i was trying to clone a mesh and serialize the scene. http://www.html5gamedevs.com/topic/17024-cloning-an-imported-mesh-serialize-then-open-scene/ It turned out that when i clone and serialize a mesh they seem to attach themselves somehow to each other. So here i clone a mesh, and move just the clone: http://www.babylonjs-playground.com/#1O8OKN Works great! the clone moves seperate to the mesh. Now i serialize the scene and save it to a file. When i load that scene, i can't move just the clone by itself anymore. They appear to be attached. http://www.babylonjs-playground.com/#JQE2O The two meshes on top of each other, this can be confirmed in the debug layer. Does anyone have any suggestions on how to fix this? how to perhaps separate them? or even what is going on so i can try to understand it? Currently all i can see is that both cloned meshes have the same ID. But they both have the same ID when i first clone it and it works great. But after i load it not so lucky. Any ideas? Quote Link to comment Share on other sites More sharing options...
ChrisR Posted September 9, 2015 Author Share Posted September 9, 2015 Getting closer. It appears to be a serialization issue. When it reloads the meshes, all the meshes from the original object have the clone object equivilant as their parent. It is not like this right before serialization. So the issue appears to be in the babylon serializer for clones. I'll report back if i find anything. If anyone has insight to that which can help me please weigh in. Thanks. Quote Link to comment Share on other sites More sharing options...
ChrisR Posted September 9, 2015 Author Share Posted September 9, 2015 Ok, it actually came down to how Babylon clones a Mesh. It copies over the ID of the mesh from the old to the new. Then when it serializes and reloads, it causes the loader to misinterpret the proper parent. I fixed this by adding: if (source) { ... this.id = name + "." + source.id; ...}To babylon.mesh.ts constructor. Now every cloned mesh also gets a cloned unique id, not just a cloned unique name. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 9, 2015 Share Posted September 9, 2015 well done..I'm gonna fix it 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.