From 051f4be2f1278bf3c58f2054541c585a541a3d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Schmith=C3=BCsen?= Date: Tue, 9 Jul 2019 17:59:20 +0200 Subject: [PATCH] serialize lights --- tiny_gltf.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index e199348..30c2e55 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -5105,10 +5105,23 @@ static void SerializeGltfMesh(Mesh &mesh, json &o) { } } +static void SerializeSpotLight(SpotLight &spot, json &o) { + SerializeNumberProperty("innerConeAngle", spot.innerConeAngle, o); + SerializeNumberProperty("outerConeAngle", spot.outerConeAngle, o); + SerializeExtensionMap(spot.extensions, 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); SerializeNumberArrayProperty("color", light.color, o); SerializeStringProperty("type", light.type, o); + if (light.type == "spot") { + json spot; + SerializeSpotLight(light.spot, spot); + o["spot"] = spot; + } } static void SerializeGltfNode(Node &node, json &o) { @@ -5516,7 +5529,7 @@ bool TinyGLTF::WriteGltfSceneToFile(Model *model, const std::string &filename, ext_j = output["extensions"]; } - ext_j["KHR_lights_cmn"] = khr_lights_cmn; + ext_j["KHR_lights_punctual"] = khr_lights_cmn; output["extensions"] = ext_j; }