How to Gltf Texture

Please do not forget to add a link to a Playground to get a faster answer:

How to get Gltf Texture from glb model.

i am getting data://http://dummy.com/test.glb#img7 as Url.

how to read the texture image from glb model, i see in the inspector it is loading but in the Api i see the above url.

can you please let me is there any other method i have to use to get the image of the texture for glb model

As motioned in the template you left in your post, can you create a repro in the playground in order to help us help you ?

in the console it is print as “data:scenes/BoomBox/BoomBox_baseColor.png”

how can i read image the above url

I believe what you want is to get the texture, correct? You can do this very easily by opening the inspector.
Unfold the ‘textures’.
Click on the texture you want and under the thumbnail, click on ‘edit’.
In the preview window, to the far right, click on the ‘save’ icon to retrieve the texture.


But i need get this in code as base64 string , not through the inspector

I see. I don’t know what method there is (if any) to retrieve a texture embeded in gltf.
You would need to ask someone from the gltf team @bghgary

This isn’t specific to glTF. Once the asset is loaded, you have a Babylon texture. You can retrieve the contents of the texture by calling texture.readPixels and then use Tools.DumpDataAsync to get a Base64 string from the pixels.

3 Likes