syoyo / tinygltf

Header only C++11 tiny glTF 2.0 library
MIT License
1.94k stars 395 forks source link

Be tolerant when encountering emissiveFactor with array length 4 #445

Closed nyalldawson closed 10 months ago

nyalldawson commented 10 months ago

Raise a warning when encountering emissiveFactor with array length of 4 and truncate to the first 3 elements, instead of aborting the model loading entirely.

syoyo commented 10 months ago

The spec says emissiveFactor is number[3], so I think we should report it as error, not warning.

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-material

What is gltf-validator's result to emissiveFactor with number[4]?

nyalldawson commented 10 months ago

How about if I add an optional "flags" argument to model loading, with a "permissive" flag which enables workarounds like this?

syoyo commented 10 months ago

Adding a flag to control the parsing behavior would be a nice idea. For example...

TinyGLTF::SetParseStrictness(enum)

nyalldawson commented 10 months ago

@syoyo how's that now?

syoyo commented 10 months ago

@syoyo how's that now?

Thanks! Let me give some time to review it.

syoyo commented 10 months ago

Merged!