using System;
using GLTF.Extensions;
using GLTF.Math;
using Newtonsoft.Json;

namespace GLTF.Schema
{
	/// <summary>
	/// A set of parameter values that are used to define the metallic-roughness
	/// material model from Physically-Based Rendering (PBR) methodology.
	/// </summary>
	public class MaterialExtensions : GLTFProperty
	{


		/// <summary>
		/// The base color texture.
		/// This texture contains RGB(A) components in sRGB color space.
		/// The first three components (RGB) specify the base color of the material.
		/// If the fourth component (A) is present, it represents the opacity of the
		/// material. Otherwise, an opacity of 1.0 is assumed.
		/// </summary>
		public KHR_materials_unlit KHR_materials_unlit;

		// public MaterialExtensions()
		// {
		// }

		public MaterialExtensions(MaterialExtensions materialExtensions) : base(materialExtensions)
		{
			KHR_materials_unlit = new KHR_materials_unlit();
		}

		// public PbrMetallicRoughness(PbrMetallicRoughness pbrMetallicRoughness, GLTFRoot gltfRoot) : base(pbrMetallicRoughness)
		// {

		

		// public static PbrMetallicRoughness Deserialize(GLTFRoot root, JsonReader reader)
		// {
		// 	var metallicRoughness = new PbrMetallicRoughness();

		// 	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 = TextureInfo.Deserialize(root, reader);
		// 				break;
		// 			case "metallicFactor":
		// 				metallicRoughness.MetallicFactor = reader.ReadAsDouble().Value;
		// 				break;
		// 			case "roughnessFactor":
		// 				metallicRoughness.RoughnessFactor = reader.ReadAsDouble().Value;
		// 				break;
		// 			case "metallicRoughnessTexture":
		// 				metallicRoughness.MetallicRoughnessTexture = TextureInfo.Deserialize(root, reader);
		// 				break;
		// 			default:
		// 				metallicRoughness.DefaultPropertyDeserializer(root, reader);
		// 				break;
		// 		}
		// 	}

		// 	return metallicRoughness;
		// }

		public override void Serialize(JsonWriter writer)
		{
			writer.WriteStartObject();

			// writer.WritePropertyName("KHR_materials_unlit");
			writer.WritePropertyName("KHR_materials_unlit");
			writer.WriteStartObject();
			writer.WriteEndObject();
			// writer.

			// if (BaseColorFactor != Color.White)
			// {
			// 	writer.WritePropertyName("KHR_materials_unlit");
			// 	writer.WriteStartArray();
			// 	writer.WriteValue(BaseColorFactor.R);
			// 	writer.WriteValue(BaseColorFactor.G);
			// 	writer.WriteValue(BaseColorFactor.B);
			// 	writer.WriteValue(BaseColorFactor.A);
			// 	writer.WriteEndArray();
			// }

			// if (BaseColorTexture != null)
			// {
			// 	writer.WritePropertyName("baseColorTexture");
			// 	BaseColorTexture.Serialize(writer);
			// }

			// if (MetallicFactor != 1.0f)
			// {
			// 	writer.WritePropertyName("metallicFactor");
			// 	writer.WriteValue(MetallicFactor);
			// }

			// if (RoughnessFactor != 1.0f)
			// {
			// 	writer.WritePropertyName("roughnessFactor");
			// 	writer.WriteValue(RoughnessFactor);
			// }

			// if (MetallicRoughnessTexture != null)
			// {
			// 	writer.WritePropertyName("metallicRoughnessTexture");
			// 	MetallicRoughnessTexture.Serialize(writer);
			// }

			base.Serialize(writer);

			writer.WriteEndObject();
		}
	}
}
