dsman Posted May 20, 2015 Share Posted May 20, 2015 So in my scene I will have : 1. dynamically generated meshes of type Plane2. meshes will be in large number (200-300) 3. meshes will have same texture 4. position of meshes could vary, but size will be same Which feature of babylon should I use here to optimze speed in my scene in such case ? Quote Link to comment Share on other sites More sharing options...
fenomas Posted May 21, 2015 Share Posted May 21, 2015 Sounds like a job for Sprites, if you are okay with a couple of limitations (sprites don't cast or receive shadows, and they don't depth-composite with transparent objects or particles).With that said, for only a few hundred meshes I'd bet performance will be very good even with no optimization. Quote Link to comment Share on other sites More sharing options...
jerome Posted May 21, 2015 Share Posted May 21, 2015 Instances will do the job also : http://babylondoc.azurewebsites.net/page.php?p=22571var instance = mesh.createInstance("instanceName"); dsman and RaananW 2 Quote Link to comment Share on other sites More sharing options...
Temechon Posted May 21, 2015 Share Posted May 21, 2015 And most importantly, sprite cannot be picked ! Quote Link to comment Share on other sites More sharing options...
dsman Posted May 21, 2015 Author Share Posted May 21, 2015 Not picked, won't receive shadow will not do the job. And yes performance is affected greatly affected even with 200+ plane mesh. Plane mesh doesn't have many vertices. Just 4 I guess. Still it FPS is reduced to 2/3. May be because I have mirror in scene. So I think instance is way to go. Quote Link to comment Share on other sites More sharing options...
dsman Posted May 22, 2015 Author Share Posted May 22, 2015 Another question on same line. If I have instantiated mesh picked up, how do I change its texture , affectively changing texture of all mesh instantiated from same root mesh ? It seems I can't access ".material" property of instantiated mesh. Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 22, 2015 Share Posted May 22, 2015 Try changing the material of the object used to create those instances. But this will change all instances as well...Maybe try finding a different way to highlight the selected mesh. Quote Link to comment Share on other sites More sharing options...
dsman Posted May 22, 2015 Author Share Posted May 22, 2015 Actually is fine if it changes texture of all instantiated mesh. And that is in fact how instance functions. So that's not a problem. It's only that I have an instantiated mesh with me (picked by mouse click) and not the original mesh from which it was instantiated (along with dozens other) . So question is how do I find mesh from which the given mesh was instantiated. Is there any standard way ? Or I have to add custom properties like "myParent" to instantiated mesh object on fly like: var instancemesh = origmesh.createInstance("");instancemesh.myParent = origmesh ;And then changing original mesh's texture when instantiated mesh is picked: pickedMesh = scene.getMeshByName(pickResult.pickedMesh.name); pickedMesh.myParent.material.DiffuseTexture = new BABYLON.Texture('texture.jpg', scene);Is this the only way? Though, this might work. I am not fan of adding properties on the fly as long as I can avoid . Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 22, 2015 Share Posted May 22, 2015 You could give the material a proper name and get it from the scene using getMaterialByName (or id). Then you can change the material, which ultimately will change the material of the instances. 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.