I can get the default plugin used to load from .babylon files by:
const defaultLoaderPlugin = SceneLoader.GetDefaultPlugin();
GetDefaultPlugin() returns an
plugin property is one of these:
However, even though the default loader plugin for .babylon files offers synchronous as well as asynchronous versions of
GetDefaultPlugin().plugin I only succeed in getting the synchronous versions.
What I want is an
ISceneLoaderPluginAsync, that would give me the asynchronous versions.
Background: I need this for extending the functionality of the default loading behaviour of
LoadAssetContainerAsync. I am registering my own
ISceneLoaderPluginAsync as the new loader-plugin for .babylon files, which runs my custom behaviour, after which it registers the default plugin again, in order to import geometry the default way.
This isn’t really my area, but looking at the code, it seems the babylonFileLoader only has sync versions. Where do you see async versions?
Hey @bghgary, I am talking about
SceneLoader.LoadAssetContainerAsync(). I can use both to load assets from a .babylon file, however,
SceneLoader.GetDefaultPlugin() returns something that only contains the synchronous method.
I am dealing with a situation where I want to extend the behaviour of a
SceneLoader.LoadAssetContainerAsync() call by running my own code before loading assets from a .babylon file. To do so, I am registering my own .babylon file loader, which calls
SceneLoader.LoadAssetContainerAsync() after running some extra code manipulating the incoming .babylon JSON. This works for the synchronous loading methods, however, I am unable to get access to their asynchronous versions.
SceneLoader.LoadAssetContainer are both “asynchronous”. The former returns a
promise and the latter uses callbacks. Whether the underlying loader is actually asynchronous depends on the loader. The BabylonFileLoader is always synchronous. There is no asynchronous version. The only part that will be asynchronous is downloading the file itself which you can use
Tools.LoadFileAsync to do if necessary, but if you are registering your own loader, you don’t need to do this part. Hope this helps.