We did spend some time trying out different ideas for this but none of them panned out, so I think it just needs more investigation, ideally from someone who deeply understands how packaged assets work in Android/iOS/RN. It’s frustrating that this is such a pain since it is obviously basic functionality that folks using Babylon React Native would expect.
If you just want a quick workaround to test a scene, you could do the following:
- Convert your glb to a base64 string. I like to use PowerShell for this:
[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes("/path/to/your/model.glb"))
- Paste the base64 string into a
model.json
file in your project that looks something like this (whereZ2xURgIAAAA...AA==
is a placeholder for the base64 string you got from step 1):
{
"data": "Z2xURgIAAAA...AA=="
}
- Load the model from the base 64 string like this:
import * as model from "model.json";
...
SceneLoader.ImportMeshAsync("", "", `data:base64,${model.data}`, scene);
This is not an efficient way of storing/loading models, but for testing purposes or for small models/assets it should be ok.