public static GLTFCamera Deserialize(GLTFRoot root, JsonReader reader) { var camera = new GLTFCamera(); while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case "orthographic": camera.Orthographic = CameraOrthographic.Deserialize(root, reader); break; case "perspective": camera.Perspective = CameraPerspective.Deserialize(root, reader); break; default: camera.DefaultPropertyDeserializer(root, reader); break; } } return(camera); }
public static GLTFRoot Deserialize(JsonReader reader) { var root = new GLTFRoot(); if (reader.Read() && reader.TokenType != JsonToken.StartObject) { throw new Exception("glTF JSON must be an object"); } while (reader.Read() && reader.TokenType == JsonToken.PropertyName) { var curProp = reader.Value.ToString(); switch (curProp) { case "extensionsUsed": root.ExtensionsUsed = reader.ReadStringList(); break; case "extensionsRequired": root.ExtensionsRequired = reader.ReadStringList(); break; case "accessors": root.Accessors = reader.ReadList(() => Accessor.Deserialize(root, reader)); break; case "animations": root.Animations = reader.ReadList(() => GLTFAnimation.Deserialize(root, reader)); break; case "asset": root.Asset = Asset.Deserialize(root, reader); break; case "buffers": root.Buffers = reader.ReadList(() => Buffer.Deserialize(root, reader)); break; case "bufferViews": root.BufferViews = reader.ReadList(() => BufferView.Deserialize(root, reader)); break; case "cameras": root.Cameras = reader.ReadList(() => GLTFCamera.Deserialize(root, reader)); break; case "images": root.Images = reader.ReadList(() => Image.Deserialize(root, reader)); break; case "materials": root.Materials = reader.ReadList(() => Material.Deserialize(root, reader)); break; case "meshes": root.Meshes = reader.ReadList(() => Mesh.Deserialize(root, reader)); break; case "nodes": root.Nodes = reader.ReadList(() => Node.Deserialize(root, reader)); break; case "samplers": root.Samplers = reader.ReadList(() => Sampler.Deserialize(root, reader)); break; case "scene": root.Scene = SceneId.Deserialize(root, reader); break; case "scenes": root.Scenes = reader.ReadList(() => GLTF.Scene.Deserialize(root, reader)); break; case "skins": root.Skins = reader.ReadList(() => Skin.Deserialize(root, reader)); break; case "textures": root.Textures = reader.ReadList(() => Texture.Deserialize(root, reader)); break; default: root.DefaultPropertyDeserializer(root, reader); break; } } return(root); }