Cancel SceneLoader.Load


I am loading gltf files using SceneLoader.Load in a canvas that is part of a SPA app. In my app it is possible to switch between scenes while they are loading, I would like to cancel the Load event for one of the Scenes when loading the new one. Would it be possible to cancel/abort the Load event with SceneLoader to avoid loading 2 files?

Thank you for your help.

I think it is possible in GLTF, asking a friend to confirm @bghgary ?

If you loading a glTF, you can cancel the loading by disposing the loader.

Here is an example: Cancel loading a glTF | Babylon.js Playground (


Thanks a lot, I’ll try this out.

1 Like

Sorry to bump this. But the docs do not mention a way to dispose the loader. How can I do this in a type-safe way?

OnPluginActivatedObservable is mentioned in the Docs - SceneLoader | Babylon.js Documentation

The same with “loader” from PG example - it has ISceneLoaderPlugin | Babylon.js Documentation interface.

So I believe it should be type-safe.

I think only the gltf loader has a dispose function so unfortunately you will either need to check the plugin name being gltf to cast as GLTFFileLoader or IDisposable.

You could also check if loader.dispose exists before calling it.