Percentage progress loader for Speckle viewer API

Hi,
Is it possible to get the percentage of the data loaded in the viewer API? So that a preloader can be created showing how much of the model has loaded and is remaining.
Related code:
const loader = new SpeckleLoader(targetTree, resource, authToken);
await viewer.loadObject(loader, true);

Thank you.

2 Likes

Hi @dushyant

It’s possible yes! You can hook up to a LoaderEvent

const loader = new SpeckleLoader(targetTree, resource, authToken);
loader.on(LoaderEvent.LoadProgress, (arg: { progress: number; id: string }) => {
   // Handle it
})
await viewer.loadObject(loader, true);

I also recommend updating to the latest viewer version, where we’ve improved progress reporting a little bit

Cheers

2 Likes

Awesome! :slight_smile:
Thank you @alex !

2 Likes