How to import a local .glb file in BabylonReactNative?

Could someone provide an example of how to import local files? There isn’t much documentation on the BabylonjsReactNative project yet.


1 Like

Welcome aboard!

Adding @bghgary.

Sorry for the lack of documentation. The easiest way to load a local file is to use the app: uri scheme. Underneath, this will use platform APIs to access resources in the app package.

Android: AAssetManager
Apple: [[NSBundle mainBundle] pathForResource:url.path ofType:nil]
UWP: ApplicationModel::Package::Current().InstalledLocation().GetFileAsync

You can use this uri scheme with any of the Babylon.js APIs that take urls (e.g. SceneLoader.Append to load a glb).

Thanks @bghgary. Sorry I’m not quite following, any documentation I can find on React Native’s app: uri scheme seems to be related to deep linking into the app from the web or other apps. Can you share an example of how this would work?

Oops, sorry, I gave you instructions for Babylon Native. :grimacing: Babylon React Native doesn’t work any different than normal React Native for resources. Maybe @ryantrem can help with this?

Loading glbs locally is not well supported yet. We need more work here. importing a .glb file fails if only local path is provided and not served through HTTP · Issue #165 · BabylonJS/BabylonReactNative · GitHub