I need to do a different kind of asset loading for a react native application. What I propose is adding extensibility to BabylonJS to allow developers to add their own or augment existing asset loaders.
In current state, I would need to hoist the FileTools static convenience methods. What I would like to do is add extension (open closed) to allow developers to substitute. It seems at least for where DOM Image is used to load assets that Scene is available everywhere (except for 2D Image) and we could make scene an optional constructor param perhaps. So, my proposal is to add to SceneOptions an optional IAssetLoader to override asset loading.
I haven’t fully investigated, but I think IAssetLoader could basically follow FileTools method signatures, unless you are ready to switch to Promises (all the native code uses async/await, so I need to wrap as sync). I’ve seen how videos and sounds are loaded and that will require some extra thinking. I did some tests on the weekend getting images loaded to textures from local app disk (ie: bundled assets/CameraRoll) using react-native utilities.
I realize we have overrides to load “data:…” and I can work around and add custom code. I want to add this though not for a custom application, but for a library - otherwise I could just hard-code things and use existing static methods like “Texture.LoadFromDataString”, whereas I would like to use
new Texture(require('./localAsset/file.jpg'), ...) etc.
So, just want to start a discussion to see if this would be a welcome addition before working on a PR and also interested to learn more how BabylonJS Native project intends to allow Textures/Sounds/Videos to load from native filesystem/camera/etc. in case I have missed out the proper way to integrate native files with BabylonJS.