Jump to content

Expense of deleting meshes vs. creating new scene


Recommended Posts

Does anyone have any evidence (anecdotal even) on which method would be quickest?

Scenario A: Dispose of 200 static meshes and create 12 new ones.

Scenario B: Dispose of the whole scene and create a new scene with 13 static meshes. 

Scenario C: Not sure this is possible, but can you make babylon.js not render meshes? I could "turn off" the 200 static meshes so they do not interact with lights and player input. This would be the preferred method, I think, since it would minimize object creation, which in C is an expensive process.

I can test it, of course, but was wondering if anyone had any best practices on how to make that as seamless as possible. 

Thanks for any input.


EDIT: Looks like setEnabled() may make Scenario C possible! I will test it!





Edited by georage
i may have answered my own question
Link to comment
Share on other sites

Well, if you consider memory footprint, I would do A.  If there are meshes you do not have, you have to pay the creation cost no matter what.  If you never are going to need something anymore, disposing of meshes would save memory on both cpu & gpu.  Do not think disposing would more than 16.67 millis, (one 60 hz frame).

you could easily switch between A or C and test either way.




If you go the dispose route, make sure you do not store references to the meshes in your own code.

Link to comment
Share on other sites

Thanks, this seems to work quickly ... not sure about memory issues but can tweak later. I won't have more than 250 simple meshes in memory at a time either way, I don't think.

function disableAllMeshesExcept(star, scene){
        log(scene.meshes.length + " meshes detected");
        var countMesh = 0;
        for (var i = 0; i < scene.meshes.length; i++) {
            if(scene.meshes[i] != star){
        log(countMesh + " meshes disabled");



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.

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.


  • Recently Browsing   0 members

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