Error When Using CreateFromBase64String To Load TGA Image File

Hi everyone,
I plane to load texture from base64 data. I have a try to load them with CreateFromBase64String, but it always create a red-black texture. Does CreateFromBase64String support .tga type?

TGAs are not supported by browsers, so we can’t handle them (we use browser methods to load files).

You should try using PNG files instead, if your workflow allows.

I find tga.ts in babylonjs/core, could it provide any help?

I have a try to generate a blob url and load from it, it not work

This can work! :sparkling_heart:

Yes we should be able to load tga if I remember correctly (on my phone so I could be wrong)

1 Like

Ah, I didn’t remember we have a TGA loader!

1 Like

I made a fix to let you specify the extension to load:
Allow CreateFromBase64String and LoadFromDataString to specifiy exten… by deltakosh · Pull Request #14932 · BabylonJS/Babylon.js (

Once merged this PG will work:
How to set independent materials for each side of a cuboid | Babylon.js Playground (


I find that Loader will throw a error when GLB contains .tga file. Is it the same problem with CreateFromBase64String? :grin:

I think gltf does not support TGA as a texture file format.

cc @bghgary

It is seems that FBX2GLTF tools can package TGA file into glb, and I used to use model-viewer to load glb file with tga.

According to the spec, only .png and .jpg are supported as texture formats.

I could not find an extension that would support TGA:

Let’s wait for @bghgary input, who will know for sure if TGA support is standard in gltf.

TGA is not supported in glTF, sorry. It would be non-conformant to load TGA with glTF without an extension. Why use TGA?

I plan to achieve a model-viewer with Babylonjs which can view model-file like fbx,max,mb.
Old plan is converting them to fbx (autodesk api), next to glb (FBX2GLTF tools). In this way, I have to face glb with .gta image. New plan is port FBXLoader to Babylonjs that I can control the parse process and get more information from origin file (convert fbx to glb always lose many informations)