// <auto-generated/>

//------------------------------------------------------------------------------------------------
//      This file has been programatically generated; DON´T EDIT!
//------------------------------------------------------------------------------------------------

#pragma warning disable SA1001
#pragma warning disable SA1027
#pragma warning disable SA1028
#pragma warning disable SA1121
#pragma warning disable SA1205
#pragma warning disable SA1309
#pragma warning disable SA1402
#pragma warning disable SA1505
#pragma warning disable SA1507
#pragma warning disable SA1508
#pragma warning disable SA1652

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Text.Json;

using JSONREADER = System.Text.Json.Utf8JsonReader;
using JSONWRITER = System.Text.Json.Utf8JsonWriter;
using FIELDINFO = SharpGLTF.Reflection.FieldInfo;


namespace SharpGLTF.Schema2
{
	using Collections;

	/// <summary>
	/// glTF extension that defines the parameters for the volume of a material.
	/// </summary>
	#if NET6_0_OR_GREATER
	[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)]
	#endif
	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("SharpGLTF.CodeGen", "1.0.0.0")]
	partial class MaterialVolume : ExtraProperties
	{
	
		#region reflection
	
		public new const string SCHEMANAME = "KHR_materials_volume";
		protected override string GetSchemaName() => SCHEMANAME;
	
		protected override IEnumerable<string> ReflectFieldsNames()
		{
			yield return "attenuationColor";
			yield return "attenuationDistance";
			yield return "thicknessFactor";
			yield return "thicknessTexture";
			foreach(var f in base.ReflectFieldsNames()) yield return f;
		}
		protected override bool TryReflectField(string name, out FIELDINFO value)
		{
			switch(name)
			{
				case "attenuationColor": value = FIELDINFO.From("attenuationColor",this, instance => instance._attenuationColor ?? Vector3.One); return true;
				case "attenuationDistance": value = FIELDINFO.From("attenuationDistance",this, instance => instance._attenuationDistance); return true;
				case "thicknessFactor": value = FIELDINFO.From("thicknessFactor",this, instance => instance._thicknessFactor ?? 0); return true;
				case "thicknessTexture": value = FIELDINFO.From("thicknessTexture",this, instance => instance._thicknessTexture); return true;
				default: return base.TryReflectField(name, out value);
			}
		}
	
		#endregion
	
		#region data
	
		private static readonly Vector3 _attenuationColorDefault = Vector3.One;
		private Vector3? _attenuationColor = _attenuationColorDefault;
		
		private const Double _attenuationDistanceExclusiveMinimum = 0;
		private Double? _attenuationDistance;
		
		private const Double _thicknessFactorDefault = 0;
		private const Double _thicknessFactorMinimum = 0;
		private Double? _thicknessFactor = _thicknessFactorDefault;
		
		private TextureInfo _thicknessTexture;
		
		#endregion
	
		#region serialization
	
		protected override void SerializeProperties(JSONWRITER writer)
		{
			base.SerializeProperties(writer);
			SerializeProperty(writer, "attenuationColor", _attenuationColor, _attenuationColorDefault);
			SerializeProperty(writer, "attenuationDistance", _attenuationDistance);
			SerializeProperty(writer, "thicknessFactor", _thicknessFactor, _thicknessFactorDefault);
			SerializePropertyObject(writer, "thicknessTexture", _thicknessTexture);
		}
	
		protected override void DeserializeProperty(string jsonPropertyName, ref JSONREADER reader)
		{
			switch (jsonPropertyName)
			{
				case "attenuationColor": DeserializePropertyValue<MaterialVolume, Vector3?>(ref reader, this, out _attenuationColor); break;
				case "attenuationDistance": DeserializePropertyValue<MaterialVolume, Double?>(ref reader, this, out _attenuationDistance); break;
				case "thicknessFactor": DeserializePropertyValue<MaterialVolume, Double?>(ref reader, this, out _thicknessFactor); break;
				case "thicknessTexture": DeserializePropertyValue<MaterialVolume, TextureInfo>(ref reader, this, out _thicknessTexture); break;
				default: base.DeserializeProperty(jsonPropertyName,ref reader); break;
			}
		}
	
		#endregion
	
	}

}
