Jump to content

Disposing materials


Blax
 Share

Recommended Posts

Hi!

 

Please help me (yes, again :))!

 

http://www.babylonjs-playground.com/#1A8B4B

1. have StandardMaterial, binded on mesh;

2. delete this material:  material.dispose()

3. scene.materials not contains this material more, its OK,

BUT ....

4. If we get "material" property from mesh we get link on deleted material.

 

How it works?

 

Example:

First we deleted anything materials (we not know how meshes binded on disposed material).

Second we need know - deleted material on this mesh or not, but how, if we get "material" we get normal StandardMaterial.

 

Check every time contains scene.materials this material or not is horrable, but how make this correct?

 

Link to comment
Share on other sites

That's actually rather interesting.

 

If you dispose a material that is currently being used, it is not being fully disposed. You can only dispose it after you set the mesh's material to null.

Maybe the dispose function should also search all meshes using the material and set their material to null.

 

Here - http://www.babylonjs-playground.com/#1A8B4B#2

Look at both alerts. JavaScript sometimes puzzles me. I feel like something that is done is wrong, but i can't pinpoint it...

 

That's even more interesting than I thought :-) The first call removes it from the scene.materials, but isn't completely deleted (As i wrote before). But for some reason, the second call removed the default material from the scene's materials array. Odd... Debugging further. I slowly start to sound like Wingnut... :-)

Edited by RaananW
Link to comment
Share on other sites

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