public static GLTFMaterial Deserialize(GLTFRoot root, JsonReader reader) { var material = new GLTFMaterial(); while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case "pbrMetallicRoughness": material.PbrMetallicRoughness = GLTFPBRMetallicRoughness.Deserialize(root, reader); break; case "normalTexture": material.NormalTexture = GLTFNormalTextureInfo.Deserialize(root, reader); break; case "occlusionTexture": material.OcclusionTexture = GLTFOcclusionTextureInfo.Deserialize(root, reader); break; case "emissiveTexture": material.EmissiveTexture = GLTFTextureInfo.Deserialize(root, reader); break; case "emissiveFactor": material.EmissiveFactor = reader.ReadAsRGBColor(); break; case "alphaMode": material.AlphaMode = reader.ReadStringEnum <GLTFAlphaMode>(); break; case "alphaCutoff": material.AlphaCutoff = reader.ReadAsDouble().Value; break; case "doubleSided": material.DoubleSided = reader.ReadAsBoolean().Value; break; default: material.DefaultPropertyDeserializer(root, reader); break; } } return(material); }
public static GLTFPBRMetallicRoughness Deserialize(GLTFRoot root, JsonReader reader) { var metallicRoughness = new GLTFPBRMetallicRoughness(); if (reader.Read() && reader.TokenType != JsonToken.StartObject) { throw new Exception("Asset must be an object."); } while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case "baseColorFactor": metallicRoughness.BaseColorFactor = reader.ReadAsRGBAColor(); break; case "baseColorTexture": metallicRoughness.BaseColorTexture = GLTFTextureInfo.Deserialize(root, reader); break; case "metallicFactor": metallicRoughness.MetallicFactor = reader.ReadAsDouble().Value; break; case "roughnessFactor": metallicRoughness.RoughnessFactor = reader.ReadAsDouble().Value; break; case "metallicRoughnessTexture": metallicRoughness.MetallicRoughnessTexture = GLTFTextureInfo.Deserialize(root, reader); break; default: metallicRoughness.DefaultPropertyDeserializer(root, reader); break; } } return(metallicRoughness); }