donmccurdy/glTF-Transform

Issue with webp extension

Bhushan-Ctruh opened this issue · 2 comments

I have pretty basic setup where we use gltf-transform on client side to convert glb to gltf, which works fine for most cases but breaks for webp textures. So I am using the webp extension as shown here but it still gives me error saying Missing required extension, "EXT_texture_webp". Not sure if I am doing somthing wrong or its a bug.

This is how I am using in my code base.

const doc = await io.read(blob);

doc.createExtension(EXTTextureWebP).setRequired(true)

const { json, resources } = await io.writeJSON(doc);

Hi @Bhushan-Ctruh! When loading a document that contains extensions, you'll need to register the extension with the I/O class, before reading the file, as shown here:

https://gltf-transform.dev/extensions#installation

The document.createExtension function is useful only when adding an extension to a glTF file that previously didn't use it.

Oh that worked, Thanks man! :)