glTF-Validator icon indicating copy to clipboard operation
glTF-Validator copied to clipboard

npm version gltf-validator is not able to detect glb with GLB_INVALID_MAGIC error

Open jiangjiangcau opened this issue 2 years ago • 1 comments

I followed the instruction in https://www.npmjs.com/package/gltf-validator to validate a GLB file. This file has invalid magic value, which can be detected by https://github.khronos.org/glTF-Validator/. But https://www.npmjs.com/package/gltf-validator cannot detect it. Does NPM version miss anything?

jiangjiangcau avatar Oct 21 '23 04:10 jiangjiangcau

There's a subtle difference in how the web (online) and npm frontends operate.

The web version checks the file extension and if it's .glb proceeds with GLB format checks.

The validateBytes function from the npm version does not know the file extension and tries to guess the file format based on the first byte. If that byte is g, the file is assumed to be GLB; if that byte is one of the valid leading JSON bytes, the file is assumed to be glTF JSON. If the first byte is unrecognized, validateBytes completes with an error instead of the validation report.

lexaknyazev avatar Jul 09 '24 15:07 lexaknyazev