GLTF loading from assets on android

Hi,
I would like to upload the gltf model from assets on android with react native & babylonjs-native:

    engine.enableOfflineSupport = true;
    // var baseUrl = "https://models.babylonjs.com/pirateFort/";
    var baseUrl = "file://assets/models/";

    SceneLoader.ImportMeshAsync(null, baseUrl, "pirateFort.glb", scene).then(result => {
        result.meshes[0].position.x = 0.01;
    });

Error meaasage is:

 WARN  Possible Unhandled Promise Rejection (id: 11):
TypeError: undefined is not an object (evaluating 'window.location.href')

Thanks

1 Like

Iā€™m not sure I understand what you trying to do. Are you trying to load from a local file? This is not likely to work due to browser security policy.

1 Like

Sorry, i try to load from local asset file on android with babylonjs-native
relates to Babylonjs native and asset loading

this soludtion also does not work on android:

var baseUrl = "file:///../assets/models/";
var baseUrl = "file:../assets/models/";

Ahh, Babylon Native. If you want to load from Assets, use the app:/// protocol. This will redirect to loading Android assets with AAssetManager.

it works, Thanks

1 Like