Load texture of glb file

Hi there
I have a glb file who exist in this location https://test-avatar-unzip.s3.us-east-2.amazonaws.com/model.glb
and this glb file contain a texture who have its skin and face style on this https://test-avatar-unzip.s3.us-east-2.amazonaws.com/model.jpg location
how I can pass this image to glb with Babylon
I try a lot but every time I have this problem

Uncaught (in promise) Error: /textures/0: Error while trying to load image: 60,33,68,79,67,84,89,80,69,32,10… - Fallback texture was used

this is my code for this part

 var raw_content = Tools.DecodeBase64(`${image}`);
        var blob = new Blob([raw_content]);
        var url = URL.createObjectURL(blob);
        var grass2 = new StandardMaterial("grass2", scene);
        grass2.ambientTexture = new Texture(url, scene);
        var cloth_on_the_model = SceneLoader.ImportMesh('',"","url of model.glb" ,
                  var object = newMeshes2['meshes'][0];
                  object.texture = grass2
                  shadowGenerator.addShadowCaster(object, true);
              cloth_on_the_model.material =grass2;

I set URLs of this two file for if you want to test it you have resource of this problem
and thanks for your attention

can you repro in the PG? This is complicated to figure out the issue with the code only (which seems fine at first glance)

actually its on react library and can’t run on PG becuase of that i share glb and its texture url to check with that url


Please check this doc to share your assets: Using External Assets In the Playground | Babylon.js Documentation (babylonjs.com)

I Base64 encoded the texture you provided and it seems to work for me: Import texture from base64 and apply to glb | Babylon.js Playground (babylonjs.com)

The error you’re getting is from the texture loading, which makes me think there’s an issue with the way you’re encoding your texture. I used Base64 Encode and Decode - Online with “split lines into 76 character wide chunks” enabled and it seems to work.

'don’t know if it’s important or if I’m wrong here, but here you’re assigning a material to a texture channel (and also a mesh doesn’t have a texture property)

1 Like