Example #1
0
        public Camera(Camera camera, GLTFRoot gltfRoot) : base(camera, gltfRoot)
        {
            if (camera == null)
            {
                return;
            }

            if (camera.Orthographic != null)
            {
                Orthographic = new CameraOrthographic(camera.Orthographic);
            }

            if (camera.Perspective != null)
            {
                Perspective = new CameraPerspective(camera.Perspective);
            }

            Type = camera.Type;
        }
Example #2
0
        public static CameraOrthographic Deserialize(GLTFRoot root, JsonReader reader)
        {
            var cameraOrthographic = new CameraOrthographic();

            if (reader.Read() && reader.TokenType != JsonToken.StartObject)
            {
                throw new Exception("Orthographic camera must be an object.");
            }

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var curProp = reader.Value.ToString();

                switch (curProp)
                {
                case "xmag":
                    cameraOrthographic.XMag = reader.ReadAsDouble().Value;
                    break;

                case "ymag":
                    cameraOrthographic.YMag = reader.ReadAsDouble().Value;
                    break;

                case "zfar":
                    cameraOrthographic.ZFar = reader.ReadAsDouble().Value;
                    break;

                case "znear":
                    cameraOrthographic.ZNear = reader.ReadAsDouble().Value;
                    break;

                default:
                    cameraOrthographic.DefaultPropertyDeserializer(root, reader);
                    break;
                }
            }

            return(cameraOrthographic);
        }