Jump to content

Optimizing scene with large number of dynamic mesh having similar texture but different position


dsman
 Share

Recommended Posts

So in my scene I will have :

 

1. dynamically generated meshes of type Plane

2. 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 ? 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.  

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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 .

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.

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