Jump to content

Scene Optimization (Mesh Selection)


Recommended Posts


I have a pretty complex scene built and I am having very heavy lag issues. Even though I have a lot of meshes, they are all instances of default ones... so I don't think there's any reason I should be getting only ~10 FPS. Could anyone provide me with any sort of clue as to why my performance is so low?

By the way, each of those cylinders are composed of many layers of cylinders. There's usually 3 cylinders (the middle one, the border, and the outline) and under them could be at least 3 others stacked (the ones that look like shadows). Aside from that, each little "group" that you see in the screenshot has a "mapMesh" object which the cylinders are parented to. All those mapMeshes are parented to a worldMesh. For the GUI text and images, each letter/image is an instance of a previously generated text/image. Each letter is parented to a wordMesh, which is then parented to a labelMesh, which is then parented to the mapMesh or the cylinder in the case of the ones on top of it.

The background with a gridMaterial has size 300 x 300 and gridRatio of 4. There's also a linear fog which starts at the end of the camera (usually 50 units apart from cylinders in the y axis) and ends at 50 units after that and has a density of 0.01.

After this scene is fully generated, there isn't much coding running at all... no animations or anything, it's pretty static. However, I cannot freeze world matrices because I might need to move the cylinders.

I appreciate any help, really stuck on how to improve performance here and not degrade the quality of my scene.


Screen Shot 2018-03-01 at 1.24.36 PM.png

Screen Shot 2018-03-01 at 1.23.54 PM.png

Link to comment
Share on other sites

Hi E14!  Umm... start by turning off the fog.  Any improvements?  Change lighting to a single hemisphericLight.  Any changes? 

Next, remove the icons/numbers from tops of cylinders.  Check speeds.  Remove other/all labels.  Check again.

Your vertices count seems sane, but your TOTAL meshes, materials, and textures... looks heavy.  (But I'm no expert.)

Your label-making system... for the text... seems...  heavy, boggy, gruesome.  :)  Perhaps too much parenting.  Too complex.  Too much "letter" and "word" wrangling.

When you turn off labels, does the FPS look better?  I think you need to use Babylon GUI for your labeling.

Narrow it down... find the bog log.  Finding it is fairly easy.  Fixing it... that might be tougher.  :)

BabylonJS GUI system, using its mesh-tracking system... might be a better route (for labels).  Use JS to "generate" the label as much as possible.  Perhaps, using imageButtons.  Have you sniffed-around in our GUI system?  Perhaps it can reduce your file loads a bit, or a lot. 

Just some ideas.  Others will surely comment soon.  BTW... I think data visualization, especially "drill-able"... is a very cool use of BJS.  I love it.  I suspect your vertical-stacked cylinders will be drillable.  Click on a stack, you get a new cam view showing the stack, new labels, and waiting for user to click-to-drill even further.  (speculation)  :)

Link to comment
Share on other sites

Hello Wingnut, thanks for replying.

First of all, nice speculation haha. They are drillable, I've already got that going.

What did you mean by using JS to "generate" the labels? I just instantiate them using the GUI and then create instances of that mesh.

Also, if I didn't use this label system and only used BABYLON's GUI to generate each word/text, initialization time for this scene would take over 20 seconds... So, not sure imageButtons will do much for me as they will be individual textures and take longer to generate.

I was able to get ~30 fps by removing all labels. That still seems low to me, is there no other way to improve the scene? Vertice count still high. I will try to improve the label system.


Link to comment
Share on other sites

By the way, I forgot to mention, the scene is draggable on the x-z plane of course. Do you guys think its feasible at all to delete meshes outside viewport and make them appear when they come in the viewport? Or is that something already implemented in BABYLON?

Link to comment
Share on other sites

We need to understand what is causing the lag.

So using f12 profiler can help here


also try to flag each mesh with mesh.alwaysSelectAsActiveMesh = true. This will avoid the frustum clipping step which can be expensive with so many meshes


Also if previous idea works, just flag the scene with scene.freezeActiveMeshes() as it will remove the mesh selection phase giving you even more free CPU

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