pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.45k stars 290 forks source link

Add webp support #143

Open harisraharjo opened 2 years ago

harisraharjo commented 2 years ago

It looks like currently gltfjsx doesn't support webp even though @gltf-transform/extensions does support it. Any plan to add webp support?

Here is the global usage of webp according to caniuse

drcmda commented 2 years ago

could you explain? gltfjsx shouldnt have anything to do with webp and images in general. it's not gltfjsx that loads a model, it's THREE.GLTFLoader

donmccurdy commented 2 years ago

@harisraharjo are you hoping that gltfjsx will convert images in glTF files to WebP? Or are you using models that already have WebP textures and running into problems?

If the former, see https://github.com/donmccurdy/glTF-Transform/pull/506. @gltf-transform/extensions supports processing files containing WebP extensions, but support for converting existing textures to WebP is currently blocked by an upstream issue in @squoosh/lib.

harisraharjo commented 2 years ago

Sorry for the late reply. In my case I tried to convert (by hand) a gltf model from using jpg & png to webp with a fallback by following this from KhronosGroup. After that I use gltfjsx to convert it to jsx. The conversion went smoothly but I also get this Missing optional extension, "EXT_texture_webp". Is it possible that this is because of this file (line 7) ? Maybe It should also import TextureWebP because gltf-transform exports TextureWebP and KHRONOS_EXTENSIONS separately (line 44)

donmccurdy commented 2 years ago

Importing ALL_EXTENSIONS instead of just KHRONOS_EXTENSIONS would be reasonable for this project. Or just adding TextureWebP separately.

I should note that gltf-transform does not currently support 'fallback' textures — e.g. only one version of the material's base color texture will be included. If you need support for older browsers (IE11, Safari in MacOS ≤10, https://caniuse.com/webp) then it may be necessary to do hand edits after gltf-transform processing, or output multiple versions of the entire glTF file.