gltf-rs / gltf

A crate for loading glTF 2.0
Apache License 2.0
534 stars 124 forks source link

Allow (partial) load of meshes with unsupported required extensions #431

Open Wumpf opened 3 months ago

Wumpf commented 3 months ago

Currently, if there's any extension listed in extensionsRequired that is not supported by this library, the loader immediately returns with an error. This makes sense given how this is speced:

An extension is considered required if a typical glTF loader would fail to load the asset in the absence of support for that extension.

That said, there's many situation where one would like to make a best effort and rather load the mesh with errors instead of failing to load anything at all.

We hit this in the Rerun viewer where after an update of gltf (didn't check for exact version yet), users no longer can load certain files: https://github.com/rerun-io/rerun/issues/7253 In this case KHR_texture_transform was put under required. Naturally, Rerun doesn't support texture transform either (can't load it through gltf after all) but it would still be desirable to load everything else that is unaffected by the extension.

After all, editing the mesh to put the extension out of required allows it to load perfectly fine, meaning that if want to make this work today we'd have to manually purge all required extensions from the list before passing it to gltf and then check what the library was able to load and what not in order to issue warnings accordingly.

emilk commented 2 months ago

From the changelog it looks like we just need to set the allow_empty_texture flag: https://github.com/gltf-rs/gltf/blob/main/CHANGELOG.md

EDIT: nope, the validation still runs and fail the load.