donmccurdy / glTF-Transform

glTF 2.0 SDK for JavaScript and TypeScript, on Web and Node.js.
https://gltf-transform.dev
MIT License
1.43k stars 150 forks source link

Issue with webp extension #1245

Closed Bhushan-Ctruh closed 10 months ago

Bhushan-Ctruh commented 10 months ago

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_texturewebp". 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);
donmccurdy commented 10 months ago

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.

Bhushan-Ctruh commented 10 months ago

Oh that worked, Thanks man! :)