CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.94k stars 3.49k forks source link

valid glTF fails to load in CesiumJS #11961

Closed mramato closed 6 months ago

mramato commented 6 months ago

house.glb.txt is a draco encoded glTF model that loads fine in all viewers I tried except for CesiumJS. It validates cleanly with no errors.

When loaded into CesiumJS, it reports:

RuntimeError: Failed to load model: ../../SampleData/models/house.glb
Failed to load glTF
One of options.bufferViewId and options.draco must be defined.
javagl commented 6 months ago

Probably a duplicate of https://github.com/CesiumGS/cesium/issues/10284 : Sparse accessors are simply not supported.

(This is also indicated by the ❌ in the "Cesium.js 116" column of the "Simple Sparse Accessor" row of the table in https://github.com/cx20/gltf-test : This is currently rendered without the sparse substitution...)

The example here adds Draco compression, and the crash is caused by the _BATCHID attribute, which is sparse and not covered by draco, because it only contains 0s anyhow. So there are a few things coming together that cause the lack of sparse accessor support to wreak havoc in this case. Maybe the crash could easily be avoided even without full sparse accessor support (and only cause a warning or so...)...

mramato commented 6 months ago

@javagl I agree that the way CesiumJS is failing here is not very useful and a clear error message or warning about lack of sparse accessors would be the least we could do. But it definitely bugs me that there is part of the glTF standard we seem to not support, especially since tools like gltf-transform's optimize function produces sparse accessors where applicable.

@ggetz @lilleyse What is the level of effort to support them?

ggetz commented 6 months ago

Closing in favor of #10284 to keep discussion in one place...