[emissiveFactor] fix inconsistency with baseColorFactor where default values were set only for baseColorFactor and not emissiveFactor
diff --git a/tiny_gltf.h b/tiny_gltf.h
index 26e72b3..7622b6d 100644
--- a/tiny_gltf.h
+++ b/tiny_gltf.h
@@ -3743,8 +3743,22 @@
static bool ParseMaterial(Material *material, std::string *err, const json &o) {
ParseStringProperty(&material->name, err, o, "name", /* required */ false);
- ParseNumberArrayProperty(&material->emissiveFactor, err, o, "emissiveFactor",
- /* required */ false);
+ if(ParseNumberArrayProperty(&material->emissiveFactor, err, o, "emissiveFactor",
+ /* required */ false)) {
+ if (material->emissiveFactor.size() != 3) {
+ if (err) {
+ (*err) +=
+ "Array length of `emissiveFactor` parameter in "
+ "material must be 3, but got " +
+ std::to_string(material->emissiveFactor.size()) + "\n";
+ }
+ return false;
+ }
+ }
+ else {
+ // fill with default values
+ material->emissiveFactor = {1.0, 1.0, 1.0};
+ }
ParseStringProperty(&material->alphaMode, err, o, "alphaMode",
/* required */ false);