Intensive calculations & progress bar

Hey together,

I have a question which is probably not entirely babylon related. However, I would like to know your opinion or maybe get some advice.

My situation is as following:

  1. I have an existing scene
  2. On some event I load 10.000 - 70.000 meshes into the scene (instanced)
  3. The position calculation is not too heavy: You can imagine the code is structured as following:

For each object
Step 1: Calculate mesh position & scaling
Step 2: Create instance & adjust scaling and position

Step 1 is rather less computation intensive (~ 1-2%)

Now as the process takes a bit I want to display some kind of progressbar.
(I was thinking about Babylong.GUI & Slider)

However, as you can imagine the thread is blocked and the progressbar not updated.

I wonder, how would you tackle this issue?

  • Should I devide the creation of the instances in some smaller packages and use promises to asyncly process the workload & update the progress on finalization?
  • Maybe web-workers? However I lack experience here (Existing scene etc…)
  • Something else?

What would you suggest?
Thx in advance for your advice!

hi. maybe this helps you unblock main thread Using offscreen canvas - Babylon.js Documentation

1 Like


thx. seems to be a brand new feature, lucky me ;).
Looks very promising. I could probably run the Progressbar on the second canvas and hide the first.
I have some concerns w.r.t. to 4.1. However I’ll give it a shot.