React native: dynamic textute from the locale file not show

Hi @ryantrem @bghgary
I am making an app with babylon.js react native on android.
The GLTF model is loaded. After that I want to load the texture of certain mesh e.g. images from a locale file.
I already tried with file:/// and app:// but the texture is not shown:

    var baseUrl = "app:///models/";

    SceneLoader.ImportMeshAsync(null, baseUrl, "GalleryGLB-08.glb", scene).then(result => {

        let pic13 = scene.getMeshByName("pic13_primitive1");
        
        var picTexture = new Texture("app:///data/user/0/com.artspacesvr/cache/ImagePicker/b6f2a0b4-e622-4506-835f-cf0e2e45ed41.jpg", scene);
        pic13.material.diffuseTexture = picTexture;
    })

Adding @ryantrem

React native handles assets differently (they are bundled) and these protocols won’t work.

I believe we still don’t have a very good solution for this, but here is a thread with some suggestions.

1 Like

Hi @bghgary
that was not my question. GLTF import works,
I just can’t change texture afterwards. So it does not work either:

        var textureGround = new DynamicTexture("dynamic texture", {width:1000, height:200}, scene);
        
        var font = "bold 44px monospace";
        textureGround.drawText("my text", 75, 135, font, "green", "white", true, true);
        pic13.material.diffuseTexture = textureGround;

If you are loading a glTF, then the material is a PBRMaterial which doesn’t have a diffuseTexture property. Maybe you mean to set the albedoTexture?

Hi,
oh, it’s true. Thank you very much.

1 Like