Tools.LoadImage() can't load KTX2 file

Hello! I want to load KTX2 texture file using Tools.LoadImage() but it keeps returning Error while trying to load image: error. I’ve made sure to include ‘image/ktx2’ for mimeType and I’ve tried loading from URL and arraybuffer, they all return the same error.

So my question is: Does the function not support loading KTX2 files? Here’s my code:

BABYLON.Tools.LoadImage(
        '...', // url to ktx2 texture file
        (image) => {
              console.log('image:', image)
        },
        (error) => {
              console.error(error)
        },
        null,
        'image/ktx2'
)

Welcome aboard!

Yes, LoadImage doesn’t support .ktx2 files because this method is using the browser to load the file, and browsers don’t support .ktx2 files.

If you want to use a .ktx2 file as a texture, you should pass the url to the Texture constructor instead.

1 Like

Thank you!