Only serialize light.range when range > 0. Fixes #260

This commit is contained in:
Syoyo Fujita 2020-05-13 21:22:23 +09:00
parent ff0a2e9fb4
commit 3dad303bea

View File

@ -1115,9 +1115,9 @@ struct SpotLight {
struct Light { struct Light {
std::string name; std::string name;
std::vector<double> color; std::vector<double> color;
double intensity; double intensity{1.0};
std::string type; std::string type;
double range; double range{0.0}; // 0.0 = inifinite
SpotLight spot; SpotLight spot;
Light() : intensity(1.0), range(0.0) {} 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) { static void SerializeGltfLight(Light &light, json &o) {
if (!light.name.empty()) SerializeStringProperty("name", light.name, o); if (!light.name.empty()) SerializeStringProperty("name", light.name, o);
SerializeNumberProperty("intensity", light.intensity, 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); SerializeNumberArrayProperty("color", light.color, o);
SerializeStringProperty("type", light.type, o); SerializeStringProperty("type", light.type, o);
if (light.type == "spot") { if (light.type == "spot") {