georage Posted February 7, 2017 Share Posted February 7, 2017 (edited) 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! https://doc.babylonjs.com/classes/2.4/node Edited February 7, 2017 by georage i may have answered my own question Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 7, 2017 Share Posted February 7, 2017 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. mesh.dispose() or mesh.setEnabled(false) If you go the dispose route, make sure you do not store references to the meshes in your own code. Quote Link to comment Share on other sites More sharing options...
georage Posted February 7, 2017 Author Share Posted February 7, 2017 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(scene.meshes[i].sName); scene.meshes[i].setEnabled(false); countMesh++; } } log(countMesh + " meshes disabled"); } GameMonetize 1 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.