Gltf-blender-io: Exporter: Avoid to export invalid JSON format

Created on 3 Sep 2018  路  5Comments  路  Source: KhronosGroup/glTF-Blender-IO

AFAIK the * .gltf file should be in JSON format:
https://github.com/KhronosGroup/glTF/tree/master/specification/2.0
禄The format combines an easily parseable JSON scene description with one or more binary files representing geometry, animations, and other rich data. Binary data is stored in such a way that it can be loaded directly into GPU buffers without additional parsing or other manipulation.芦

The JSON specification doesn't allow NaN as a value or number: https://json.org/

Exporting values as NaN breaks reading the glft file with the standard JSON parsers.
I couldn't trigger such a case with the blender-exporter[2] myself, but others claim that it happens
https://github.com/godotengine/godot/issues/21668
and try to push workarounds for the JSON parsers in the importer software.

In the attachment, only the first test-cube is validated by the JSON parser as correct.
In the blender-importer [1], the second one stops with python TypeError: list indexes must be integers or slices, not float, the third one loads without an error, which is in my opinion a mistake.

test-NaN.zip

I have created an issue only here, but it affects both
[1] https://github.com/julienduroure/gltf2-blender-importer
[2] https://github.com/KhronosGroup/glTF-Blender-Exporter

bug enhancement exporter

Most helpful comment

All 5 comments

I added some checks in the importer, in commit 2c04f2b0d4286d4d61f26e598c158b2385b3523f

What are the next steps on this issue?
Seems to be solved for importer, but what about exporter? --> We have to check if gltf2_io common classes are allowed to set some value as NaN

Thanks for filing this @capnm, you are correct that Godot should not be adding any workarounds for NaNs. As you've already noticed, such values are disallowed by glTF spec, JSON spec, and the glTF Validator. Filing bug reports on any importers/exporters that produce or accept such values is appreciated.

I rename this bug, as it is only an exporter issue (importer part is solved)

Was this page helpful?
0 / 5 - 0 ratings