gltf-rs / gltf

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

Add support for KHR_mesh_quanitization #400

Open kvark opened 11 months ago

kvark commented 11 months ago

thread '' panicked at 'assertion failed: (left == right) left: 12, right: 6', C:\Users\kvark.cargo\registry\src\index.crates.io-6f17d22bba15001f\gltf-1.3.0\src\accessor\util.rs:348:17note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

This is happening on "reader.read_positions()".

Example file: Fostral-shape.zip

I suspect this is because gltfPack-0.20 outputs 16-bit integer vertex coordinates by default instead of 32-bit floating points.

alteous commented 11 months ago

Thanks for reporting. This model is using KHR_mesh_quantization which isn't handled by the reader utility.

The extension is marked as required in the example file, so the library ought report it as unsupported in some way. It begs the question: should the library reject any glTF that has unsupported extensions under extensionsRequired? In the next release there is an arbitrary extension API, so technically the burden would be passed onto the user.

A short term solution might be to fail creating the Reader for assets with extensions required matching *_mesh_*. Obviously, the long-term solution would be to add support for this extension.

alteous commented 6 months ago

https://github.com/gltf-rs/gltf/pull/418 will now report an error if the crate can't handle a particular extension, including this one, so I've rebranded this issue as a feature request to add support for this feature.

sotrh commented 4 months ago

Is there no way to bypass the error if I need to use quantization @alteous ?

EDIT: looked at the docs and discovered from_reader_without_validation() and from_slice_without_validation().

sotrh commented 4 months ago

I created a PR for this #428