kolar Posted March 25, 2014 Share Posted March 25, 2014 Hi, I am making a game with dynamic environment loading, I want to remove meshes (also skeletons) from rendering list temporalily so the mesh won't be dowloaded and parsed when it will be added to scene again. Do I need to write my own asset manager? What is the best way (babylon way) to store parsed meshes/skeletons/textures in memory? I know I can use indexeddb but I worry that frequent mesh parsing might be performance hit. Any advice? Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 27, 2014 Share Posted March 27, 2014 Not sure to have understood well but you can remove a mesh from a scene by removing it from the meshes array of the scene and add it back when you want.var myMesh = new Mesh("myMesh", myScene);myScene.meshes.pop();myScene.meshes.push(myMesh); Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 27, 2014 Share Posted March 27, 2014 Welcome to the forum, Kolar! All lights, cameras, and mesh, used in babylon.js, are of class NODE. http://doc.babylonjs.com/page.php?p=24620 . That means that they inherit some properties and methods of NODE. [AnySceneItem].setEnabled(1 or 0) might be of some interest to you. I am just guessing, here. Large 'groups' of scene items can be parented to a single (maybe invisible) mesh. You could think of that mesh as a 'group controller'. Toggle that parent.setEnabled(), and all children... get toggled as well. In this way, you could enable/disable large chunks of scene... with a single setEnabled() call on an important parent or two. Lights and cameras can be parents, too. I do not know if any of this helps, but I thought you should know. DesignVibe 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted March 27, 2014 Share Posted March 27, 2014 Yes, 'enabled' can be used too but it's only if you remove/push from/to the same scene whereas what I suggested allow you to push to another scene. I update my previous post to reflect this:myOtherScene.meshes.push(myMesh);kolar, you have several options, it depends on what you want to do. Quote Link to comment Share on other sites More sharing options...
gryff Posted March 27, 2014 Share Posted March 27, 2014 Large 'groups' of scene items can be parented to a single (maybe invisible) mesh. You could think of that mesh as a 'group controller'. Toggle that parent.setEnabled(), and all children... get toggled as well. In this way, you could enable/disable large chunks of scene... with a single setEnabled() call on an important parent or two. @Wingnut: Can you set things like "checkCollisions" by using a 'group controller' for a number of meshes in this way? Will checkCollisions progate from parent to children? @gwenael - pushing and popping meshes - got to play with that ;-) cheers, gryff gwenael 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2014 Share Posted March 28, 2014 Gryff... that is a great question and an interesting idea, but I don't have an answer for you. I have not studied collisions at all, speak nothing of how parent-child relationships might propagate collision events. Others likely know, and if you do experiments in that, please tell us of your discoveries. thx. Quote Link to comment Share on other sites More sharing options...
kolar Posted March 29, 2014 Author Share Posted March 29, 2014 Thank you for the answer, it makes things more clear for me.How about removing skeletons? What happens to the skeleton when I remove mesh so there are no meshes affected by this skeleton. In other way, when I write:BABYLON.SceneLoader.ImportMesh(null, "path", "some_model_with_skeleton.babylon", scene, function (meshes, particleSystems, skeletons) { //skeletons[0] is attached only to meshes[0] scene.beginAnimation(skeletons[0], 0, 30, true, 1.0); scene.meshes.splice(scene.meshes.indexOf(meshes[0]), 1);});Is animation still performing (sending transformations to gpu itd)? Do I need to remove skeleton manually:scene.skeletons.splice(scene.skeletons.indexOf(skeletons[0]), 1);And what happens to the skeleteon when I use second solution:mesh.setEnabled(0); Quote Link to comment Share on other sites More sharing options...
gryff Posted March 29, 2014 Share Posted March 29, 2014 a great question and an interesting idea, but I don't have an answer for you. I have not studied collisions at all, speak nothing of how parent-child relationships might propagate collision events. Well, I created a little experiment - see the "Trigger Zones" thread for details. cheers, gryff 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.