From 3dad303bea479effc8034d5486df0f7288ac6183 Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Wed, 13 May 2020 21:22:23 +0900 Subject: [PATCH] Only serialize light.range when `range` > 0. Fixes #260 --- tiny_gltf.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 7a4e6b5..088cbed 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -1115,9 +1115,9 @@ struct SpotLight { struct Light { std::string name; std::vector color; - double intensity; + double intensity{1.0}; std::string type; - double range; + double range{0.0}; // 0.0 = inifinite SpotLight spot; Light() : intensity(1.0), range(0.0) {} @@ -6970,7 +6970,9 @@ static void SerializeSpotLight(SpotLight &spot, json &o) { static void SerializeGltfLight(Light &light, json &o) { if (!light.name.empty()) SerializeStringProperty("name", light.name, o); SerializeNumberProperty("intensity", light.intensity, o); - SerializeNumberProperty("range", light.range, o); + if (light.range > 0.0) { + SerializeNumberProperty("range", light.range, o); + } SerializeNumberArrayProperty("color", light.color, o); SerializeStringProperty("type", light.type, o); if (light.type == "spot") {