json LightData::serialize()

in src/gltf/properties/LightData.cpp [25:47]


json LightData::serialize() const {
  json result{{"name", name}, {"color", toStdVec(color)}, {"intensity", intensity}};
  switch (type) {
    case Directional:
      result["type"] = "directional";
      break;
    case Point:
      result["type"] = "point";
      break;
    case Spot:
      result["type"] = "spot";
      json spotJson;
      if (innerConeAngle != 0) {
        spotJson["innerConeAngle"] = innerConeAngle;
      }
      if (outerConeAngle != M_PI_4) {
        spotJson["outerConeAngle"] = outerConeAngle;
      }
      result["spot"] = spotJson;
      break;
  }
  return result;
}