How to make a real-time progress bar?

I’m trying to make a progress bar,but it get stuck after I called ‘scene.add(object)’.
This can be done very soon if my model has small size,but for a big one,it will take 10~20 seconds.
How can I get the exact percent during this period?

1 Like

for loading you use loadingmanagers, but once you’re adding geometry it will use the single execution thread that you have, the web isn’t a multi-thread environment unless you do work in a web-worker. but if something takes that long, if your model spends 10-20 seconds to parse then the problem it with your model tbh.

1 Like

Would be interesting to understand how to monitor generated geometry (ie a high res extrusion) and display a progress bar as its made.

I still didn’t make progress,but thank you all the same.

I’ve tried to modify the code but failed to make it work for me.:frowning:

again, if your model is parsing 20 seconds there is nothing whatsoever that you can do, other than sit back and wait until your tab unfreezes. the web runs on a single thread, that’s the way it is. in that case the culprit is the model. a model on the web should have 1-2-3mb no more, if you dump an unoptimized 100mb monster into the poor browser than this will happen. there are tons of optimizations you can apply: texture-atlas, remesh, deleting duplicates, draco, meshopt. you can shrink 100mb models into a few kilobytes that way.

if you’re working with gltf, open your console for instance and type:

npx gltf-pipeline -i model.gltf -o model.glb --draco.compressionLevel=10