GLTFLoader: Forcing the format of a texture after execution of the texture loader.

Description of the problem

In our project, we have an Uber texture loader that is replacing JPG/PNG textures from a GLTF model by the corresponding compressed texture (DXT, ETC, PVRTC, ASTC) dynamically. It then calls either the KTX Loader for compressed textures or the Texture Loader if no compressed texture was found.

But if the original GLTF file contains a mimeType for the texture, the GLTF loader is replacing our compressed texture format to either RGB or RGBA just after even if the texture returned by the loader is a compressed one and it will result in an invalid texture.

GLTF file contains:

"images" : [
    "mimeType" : "image/jpeg",
    "name" : "test",
    "uri" : "test.jpg"

GLTF Loader source:

Is this behavior really needed ? because the Texture loader should take care of updating the texture format beforehand.

Texture Loader source:

Our workaround is to save the texture format in the Uber texture loader and re-apply it after execution of the GLTF loader.

We’re still not happy on how we manage the compressed textures for each platform so if you have suggestions I’ll be happy to read them.


Original commit: c8407b4

Three.js version
  • Dev
  • All of them
  • All of them
Hardware Requirements (graphics card, VR Device, …)


Author: Fantashit

1 thought on “GLTFLoader: Forcing the format of a texture after execution of the texture loader.

  1. This was fixed a while back, the changes to .format are only applied if the texture is not compressed.

Comments are closed.