Jump to content

Mesh.dispose() Clarity


Pryme8
 Share

Recommended Posts

So to what extent does disposing the mesh, clean up the entities that may be initialized under it like a non shared material or the texture used by that material?

I know if there is a physicsImposter, you need to dipose of it before the mesh... but how much other stuff needs to be cleaned up?

Link to comment
Share on other sites

Calling mesh.dispose() will automatically dispose the children but not attached materials (unless you set the 2nd parameter to true):

https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.ts#L1811

The dispose will remove:

- Geometry

- observables

- instances

- actionmanagers

- physicsImpostor (no need to dispose it beforehand: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1542)

- submeshes

- selection octrees

Link to comment
Share on other sites

Ive come into the situation where the physicsImposter does not, is that because I sometimes name it body?

I figured the dispose recursively goes through the variables assigned to the mesh and checks for a dispose method.

Link to comment
Share on other sites

@Deltakosh

It's old habit from a few versions back. Are you saying that disposing of a single mesh also disposes of all attributes of the mesh including materials, textures, shaders, etc? We're not talking scene dispose. But if mesh dispose works this way, then what about shared attributes?

Thanks,

DB

Link to comment
Share on other sites

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...