Jump to content

Dispose


Maxence
 Share

Recommended Posts

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.

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...