public override IExtension Deserialize(GLTFRoot root, JProperty extensionToken) { if (extensionToken != null) { JToken lightsToken = extensionToken.Value[PNAME_LIGHTS]; if (lightsToken != null) { var extension = new KHR_LightsPunctualExtension(); JArray lightsArray = lightsToken as JArray; foreach (var lightToken in lightsArray.Children()) { extension.Lights.Add(PunctualLight.Deserialize(root, lightToken)); } return(extension); } JToken nodelightToken = extensionToken.Value[PNAME_LIGHT]; if (nodelightToken != null) { PunctualLightId lightId = PunctualLightId.Deserialize(root, nodelightToken.CreateReader()); return(new KHR_LightsPunctualNodeExtension(lightId, root)); } } return(null); }
public PunctualLight(PunctualLight light, GLTFRoot gltfRoot) : base(light, gltfRoot) { Type = light.Type; Color = light.Color; Intensity = light.Intensity; Range = light.Range; Spot = light.Spot; }
public static PunctualLight Deserialize(GLTFRoot root, JsonReader reader) { var light = new PunctualLight(); if (reader.Read() && reader.TokenType != JsonToken.StartObject) { throw new Exception("Light must be an object."); } while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case PNAME_TYPE: light.Type = reader.ReadStringEnum <LightType>(); break; case PNAME_COLOR: light.Color = reader.ReadAsRGBColor(); break; case PNAME_INTENSITY: light.Intensity = reader.ReadAsDouble().Value; break; case PNAME_RANGE: light.Range = reader.ReadAsDouble().Value; break; case PNAME_SPOT: light.Spot = Spot.Deserialize(reader); break; default: light.DefaultPropertyDeserializer(root, reader); break; } } return(light); }