Version: 7.51.1 and git master
OS: any
Browser: any
Engine: any
Desc
In texture.serialize, if the texture contains _buffer as Uint8Array, commonly if loaded from a glb model, serializing texture will result in base64 url in image/png type.
But in gltf spec, texture can be in many types, including png, jpeg, webp, and possibily avif.
Texture has a prop named mime type that can be directly loaded from model, and since image formats supported by browser is limited, it can be detected from first few bytes of the buffer.
Texture roundtripping needs more work beyond the scope of this PR. So far, we donāt have a reliable way to preserve the original texture format-- Texture.mimeType is only a hint. While itās true that we could read the first few bytes of the image data to get the format, thereās some extra complexity to consider. For example, if we parsed the data at load time, weād incur extra computation for every loaded texture in preparation for something (an export) that may never happen. We also canāt parse the buffer at export time, as we donāt always have it.
Weād need to add EXT_textures_webp support to the glTF exporter to do it correctly, or the best way.
We already preserve imported webp images on export (except in Safari and maybe Node). However, because we donāt add the extension to the glTF, itās technically an invalid glTF. That said, Iām still able to load the invalid glTF in Babylon and Blender. They must be forgiving about image/webp mime types used without EXT_texture_webp.
Let me add this to the exporter, as itād be good to have while we work on KHR_texture_basisu encoding support.