How to control the thread count when dynamically loading many models in Babylon.js (similar to loading 3D tiles)

I’m not quite sure what the problem is.

What number of threads are you talking about?

If the problem is the “violation” message, maybe this can help: html - How to deal with the warning: violation requestanimationframe took etc? - Stack Overflow

In any case, I don’t think we can do much about it, as it seems it happens only a single time (probably for the first frame).

1 Like

Loading a large number of models at the same time can cause lag. I am using the same approach as Cesium. Is there a way to load only two to three models at a time and then load the next models in the queue after the previous ones have finished loading?

No, we don’t have a queue of models to load, because everything is done by a single thread: when you load a model, it is done synchronously in the main thread.

AFAIK, you can’t load a model in a separate worker thread and make it available to the main one. You can create the engine in a worker thread and have your main thread free for UI stuff for eg (see Offscreen Canvas | Babylon.js Documentation), but the loading of objects will still happen in the same thread than where the engine has been created.

You could do it all in async, did you see Will Eastcott’s deployment of it for playcanvas?
I was able to get a render for babylon js working using his logic flow that was pretty decent once I added a frustrum check.

I can send the project to your email

I wont have a chance to look at it.

but here is the project I used as a baseline for getting mine to work.