Maxence Posted January 7, 2014 Share Posted January 7, 2014 Hi, I was looking on mesh.dispose() method and I noticed that when you dispose a parent without disposing its children, it removes the parent from the scene, but the children still has a reference to the parent.So i wonder if this reference is not memory expensive? I made a jsFiddle to illustrate my question. http://jsfiddle.net/MaxenceBrasselet/c34fS/2/ When you click on dispose button, it removes the mesh "Box2" from the scene, but if you look into the console, you will see that the mesh "Box" still has a reference to "Box2" in its parent value. Should we delete the parent reference of every child when we decide to dispose it? I decided to test deleting parent reference of every child, and I noticed that when you remove the parent reference, the mesh does not move (jsFiddle to illustrate: http://jsfiddle.net/MaxenceBrasselet/2e4kw/2/) whereas it should move because its position was relative to its parent, and we have removed it, so its position is now relative to the world. I found why it does not move. It's because in the "isSynchronized" method, the parent of the mesh is not in cache, so if you change it or remove it, it does not change anything about the object. I think the object must be updated when its parent changes in order to apply transform to its position, rotation and scaling, because it must keep its place in the scene. I forced it to move it by setting a new position (the cache is thus invalidated). Here's the link http://jsfiddle.net/MaxenceBrasselet/2e4kw/3/. Please read the logs in the console. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 7, 2014 Share Posted January 7, 2014 Hello I totally agree with you, this is a mistake I did. I will update the code to reflect the changes you mentioned Quote Link to comment Share on other sites More sharing options...
damian+merfoo=♥ Posted January 19, 2014 Share Posted January 19, 2014 Should be called .remove()! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 19, 2014 Share Posted January 19, 2014 Fixed with this version:https://github.com/BabylonJS/Babylon.js/releases/tag/v1.8.5 Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 19, 2014 Share Posted January 19, 2014 Sorry, I found a bug http://jsfiddle.net/gwenaelhagenmuller/5TBaC/.I explained it in the discussion of the commit. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 20, 2014 Share Posted January 20, 2014 Let's call it an expected behavior If we want to keep the mesh where it is right now, we have to decompose the matrix 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.