Decompiled source of AtlyssGLTF v0.2.0

plugins/Marioalexsan.AtlyssGLTF.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using GLTFast;
using GLTFast.Export;
using GLTFast.Loading;
using GLTFast.Logging;
using GLTFast.Materials;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Burst;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.unity.cloud.gltfast")]
[assembly: IgnoresAccessChecksTo("Mirror")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Marioalexsan.AtlyssGLTF")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+96f53e8a4c82f77e653e0b355daed60af30a20a5")]
[assembly: AssemblyProduct("AtlyssGLTF")]
[assembly: AssemblyTitle("Marioalexsan.AtlyssGLTF")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Marioalexsan.AtlyssGLTF
{
	[HarmonyPatch(typeof(ChatBehaviour), "Send_ChatMessage")]
	internal static class ChatCommands
	{
		private static bool Prefix(string _message, ChatBehaviour __instance)
		{
			if (string.IsNullOrEmpty(_message))
			{
				return true;
			}
			string[] array = _message.Split(" ", StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0 || array[0] != "/gltf")
			{
				return true;
			}
			if (array.Length < 2)
			{
				HostConsole._current.Init_NetworkStatusMessage("Usage: /gltf <command> <params...>");
				return false;
			}
			switch (array[1])
			{
			case "force_readable_meshes":
				if (array.Length != 2)
				{
					HostConsole._current.Init_NetworkStatusMessage("Usage: /gltf force_readable_meshes");
					return false;
				}
				AtlyssGLTF.ForceReadableMeshes = !AtlyssGLTF.ForceReadableMeshes;
				HostConsole._current.Init_NetworkStatusMessage("Forced readable meshes is now " + (AtlyssGLTF.ForceReadableMeshes ? "on" : "off") + ".");
				return false;
			case "import":
				if (array.Length != 4)
				{
					HostConsole._current.Init_NetworkStatusMessage("Usage: /gltf import <obj_name> <path>");
					return false;
				}
				AtlyssGLTF.GLTFImportQueue.Enqueue((array[2], Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)AtlyssGLTF.Plugin).Info.Location), array[3])));
				return false;
			case "export":
				if (array.Length != 4)
				{
					HostConsole._current.Init_NetworkStatusMessage("Usage: /gltf export <obj_name> <path>");
					return false;
				}
				AtlyssGLTF.GLTFExportQueue.Enqueue((array[2], Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)AtlyssGLTF.Plugin).Info.Location), array[3])));
				return false;
			default:
				HostConsole._current.Init_NetworkStatusMessage("That command does not exist.");
				return false;
			}
		}
	}
	[BepInPlugin("Marioalexsan.AtlyssGLTF", "AtlyssGLTF", "0.2.0")]
	public class AtlyssGLTF : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static AtlyssGLTF Plugin { get; private set; }

		public static AssetBundle Bundle { get; private set; }

		public static Shader PBRMetallicRoughness { get; private set; }

		public static Shader PBRSpecularGlossiness { get; private set; }

		public static Shader Unlit { get; private set; }

		public static Shader ExportColor { get; private set; }

		public static Shader ExportMaskmap { get; private set; }

		public static Shader ExportMetalGloss { get; private set; }

		public static Shader ExportNormal { get; private set; }

		public static Shader ExportOcclusion { get; private set; }

		public static Shader ExportSmoothness { get; private set; }

		public static bool ForceReadableMeshes { get; internal set; } = false;


		internal static ManualLogSource Logger { get; private set; }

		internal static Queue<(string ObjectName, string Path)> GLTFImportQueue { get; } = new Queue<(string, string)>();


		internal static Queue<(string ObjectName, string Path)> GLTFExportQueue { get; } = new Queue<(string, string)>();


		public ImportSettings ImportMecanim { get; } = new ImportSettings
		{
			AnimationMethod = (AnimationMethod)2
		};


		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Plugin = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("AtlyssGLTF");
			_harmony.PatchAll();
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "gltf");
			Bundle = AssetBundle.LoadFromFile(text);
			if (Object.op_Implicit((Object)(object)Bundle))
			{
				PBRMetallicRoughness = LoadShader("assets/atlyss/shader/gltf/built-in/gltfpbrmetallicroughness.shader");
				PBRSpecularGlossiness = LoadShader("assets/atlyss/shader/gltf/built-in/gltfpbrspecularglossiness.shader");
				Unlit = LoadShader("assets/atlyss/shader/gltf/built-in/gltfunlit.shader");
				ExportColor = LoadShader("assets/atlyss/shader/gltf/export/gltfexportcolor.shader");
				ExportMaskmap = LoadShader("assets/atlyss/shader/gltf/export/gltfexportmaskmap.shader");
				ExportMetalGloss = LoadShader("assets/atlyss/shader/gltf/export/gltfexportmetalgloss.shader");
				ExportNormal = LoadShader("assets/atlyss/shader/gltf/export/gltfexportnormal.shader");
				ExportOcclusion = LoadShader("assets/atlyss/shader/gltf/export/gltfexportocclusion.shader");
				ExportSmoothness = LoadShader("assets/atlyss/shader/gltf/export/gltfexportsmoothness.shader");
				Logger.LogInfo((object)"Asset bundle items:");
				string[] allAssetNames = Bundle.GetAllAssetNames();
				foreach (string text2 in allAssetNames)
				{
					Logger.LogInfo((object)(" - " + text2));
				}
			}
			else
			{
				Logger.LogWarning((object)("Unable to load glTF shader bundle from " + text + "."));
			}
			Logger.LogInfo((object)"Initialized!");
			static Shader LoadShader(string path)
			{
				Shader val = Bundle.LoadAsset<Shader>(path);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Logger.LogWarning((object)("glTF shader load failed: " + path + "."));
				}
				return val;
			}
		}

		public async Task Update()
		{
			if (GLTFImportQueue.Count > 0)
			{
				(string, string) tuple = GLTFImportQueue.Dequeue();
				await ImportGLTFScene(tuple.Item1, tuple.Item2);
			}
			if (GLTFExportQueue.Count > 0)
			{
				(string, string) tuple2 = GLTFExportQueue.Dequeue();
				await ExportGLTFScene(tuple2.Item1, tuple2.Item2);
			}
		}

		private async Task<GameObject> ImportGLTFScene(string objectName, string path)
		{
			_ = 1;
			try
			{
				GltfImport gltf = new GltfImport((IDownloadProvider)null, (IDeferAgent)null, (IMaterialGenerator)null, (ICodeLogger)null);
				await ((GltfImportBase)gltf).Load(new Uri(path), new ImportSettings
				{
					AnimationMethod = (AnimationMethod)2
				}, default(CancellationToken));
				GameObject gameObject = new GameObject(objectName);
				await ((GltfImportBase)gltf).InstantiateMainSceneAsync(gameObject.transform, default(CancellationToken));
				HostConsole._current.Init_NetworkStatusMessage("Imported glTF.");
				return gameObject;
			}
			catch (Exception ex)
			{
				HostConsole._current.Init_NetworkStatusMessage("Import failed! Check the console.");
				Logger.LogError((object)ex);
				return null;
			}
		}

		private async Task ExportGLTFScene(string objectName, string path)
		{
			try
			{
				GameObject val = GameObject.Find(objectName);
				if (!Object.op_Implicit((Object)(object)val))
				{
					HostConsole._current.Init_NetworkStatusMessage("Object not found.");
					return;
				}
				GameObjectExport val2 = new GameObjectExport(new ExportSettings
				{
					Deterministic = true,
					Format = (GltfFormat)1
				}, (GameObjectExportSettings)null, (IMaterialExport)null, (IDeferAgent)null, (ICodeLogger)null);
				val2.AddScene((GameObject[])(object)new GameObject[1] { val }, (string)null);
				if (!(await val2.SaveToFileAndDispose(path, default(CancellationToken))))
				{
					HostConsole._current.Init_NetworkStatusMessage("Something went wrong while exporting the glTF!");
				}
				HostConsole._current.Init_NetworkStatusMessage("Exported glTF!");
			}
			catch (Exception ex)
			{
				HostConsole._current.Init_NetworkStatusMessage("Export failed! Check the console.");
				Logger.LogError((object)ex);
			}
		}
	}
	internal static class ModInfo
	{
		public const string GUID = "Marioalexsan.AtlyssGLTF";

		public const string NAME = "AtlyssGLTF";

		public const string VERSION = "0.2.0";
	}
}
namespace Marioalexsan.AtlyssGLTF.HarmonyPatches
{
	internal static class BurstManager
	{
		public static void Initialize()
		{
		}
	}
	[HarmonyPatch(typeof(BurstCompiler), "Compile", new Type[]
	{
		typeof(object),
		typeof(bool)
	})]
	internal static class BurstRemove
	{
		private unsafe static bool Prefix(object delegateObj, out void* __result)
		{
			if (delegateObj.GetType().Assembly == typeof(GltfAsset).Assembly)
			{
				__result = (void*)Marshal.GetFunctionPointerForDelegate(delegateObj);
				return false;
			}
			__result = null;
			return true;
		}
	}
	[HarmonyPatch(typeof(GltfWriter), "AddMesh")]
	internal static class GltfWriter_AddMesh
	{
		private static void Prefix(ref Mesh uMesh, ref VertexAttributeUsage attributeUsage)
		{
			if (!uMesh.isReadable)
			{
				uMesh = MakeReadableMeshCopy(uMesh);
			}
		}

		public static Mesh MakeReadableMeshCopy(Mesh nonReadableMesh)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = new Mesh();
			((Object)val).name = ((Object)nonReadableMesh).name + "_copy";
			val.indexFormat = nonReadableMesh.indexFormat;
			CopyVertexBuffers(val, nonReadableMesh);
			val.subMeshCount = nonReadableMesh.subMeshCount;
			GraphicsBuffer indexBuffer = nonReadableMesh.GetIndexBuffer();
			int num = indexBuffer.stride * indexBuffer.count;
			byte[] array = new byte[num];
			indexBuffer.GetData((Array)array);
			val.SetIndexBufferParams(indexBuffer.count, nonReadableMesh.indexFormat);
			val.SetIndexBufferData<byte>(array, 0, 0, num, (MeshUpdateFlags)0);
			indexBuffer.Release();
			uint num2 = 0u;
			for (int i = 0; i < val.subMeshCount; i++)
			{
				uint indexCount = nonReadableMesh.GetIndexCount(i);
				val.SetSubMesh(i, new SubMeshDescriptor((int)num2, (int)indexCount, (MeshTopology)0), (MeshUpdateFlags)0);
				num2 += indexCount;
			}
			CopyBlendShapes(val, nonReadableMesh);
			val.RecalculateNormals();
			val.RecalculateBounds();
			val.boneWeights = nonReadableMesh.boneWeights;
			val.bindposes = nonReadableMesh.bindposes;
			return val;
		}

		private static void CopyBlendShapes(Mesh targetMesh, Mesh sourceMesh)
		{
			try
			{
				for (int i = 0; i < sourceMesh.blendShapeCount; i++)
				{
					string blendShapeName = sourceMesh.GetBlendShapeName(i);
					int blendShapeFrameCount = sourceMesh.GetBlendShapeFrameCount(i);
					for (int j = 0; j < blendShapeFrameCount; j++)
					{
						float blendShapeFrameWeight = sourceMesh.GetBlendShapeFrameWeight(i, j);
						Vector3[] array = (Vector3[])(object)new Vector3[sourceMesh.vertexCount];
						Vector3[] array2 = (Vector3[])(object)new Vector3[sourceMesh.vertexCount];
						Vector3[] array3 = (Vector3[])(object)new Vector3[sourceMesh.vertexCount];
						sourceMesh.GetBlendShapeFrameVertices(i, j, array, array2, array3);
						targetMesh.AddBlendShapeFrame(blendShapeName, blendShapeFrameWeight, array, array2, array3);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
		}

		private static void CopyVertexBuffers(Mesh targetMesh, Mesh sourceMesh)
		{
			for (int i = 0; i < sourceMesh.vertexBufferCount; i++)
			{
				GraphicsBuffer vertexBuffer = sourceMesh.GetVertexBuffer(i);
				int num = vertexBuffer.stride * vertexBuffer.count;
				byte[] array = new byte[num];
				vertexBuffer.GetData((Array)array);
				targetMesh.SetVertexBufferParams(sourceMesh.vertexCount, sourceMesh.GetVertexAttributes());
				targetMesh.SetVertexBufferData<byte>(array, 0, 0, num, i, (MeshUpdateFlags)0);
				vertexBuffer.Release();
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class ReadableMesh
	{
		private static bool Prefix(ref bool __result)
		{
			if (!AtlyssGLTF.ForceReadableMeshes)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(ImageExport), "LoadBlitMaterial")]
	internal static class ImageExport_LoadBlitMaterial
	{
		private static bool Prefix(ref string shaderName, ref Material __result)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			Shader val = (Shader)(shaderName switch
			{
				"glTFExportColor" => AtlyssGLTF.ExportColor, 
				"glTFExportNormal" => AtlyssGLTF.ExportNormal, 
				"glTFExportMetalGloss" => AtlyssGLTF.ExportMetalGloss, 
				"glTFExportOcclusion" => AtlyssGLTF.ExportOcclusion, 
				"glTFExportSmoothness" => AtlyssGLTF.ExportSmoothness, 
				_ => null, 
			});
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			__result = new Material(val);
			return false;
		}
	}
	[HarmonyPatch(typeof(BuiltInMaterialGenerator), "FinderShaderMetallicRoughness")]
	internal static class FinderShaderMetallicRoughnessPatch
	{
		private static bool Prefix(BuiltInMaterialGenerator __instance, ref Shader __result)
		{
			__result = AtlyssGLTF.PBRMetallicRoughness;
			return false;
		}
	}
	[HarmonyPatch(typeof(BuiltInMaterialGenerator), "FinderShaderSpecularGlossiness")]
	internal static class FinderShaderSpecularGlossinessPatch
	{
		private static bool Prefix(BuiltInMaterialGenerator __instance, ref Shader __result)
		{
			__result = AtlyssGLTF.PBRSpecularGlossiness;
			return false;
		}
	}
	[HarmonyPatch(typeof(BuiltInMaterialGenerator), "FinderShaderUnlit")]
	internal static class FinderShaderUnlitPatch
	{
		private static bool Prefix(BuiltInMaterialGenerator __instance, ref Shader __result)
		{
			__result = AtlyssGLTF.Unlit;
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/com.unity.cloud.gltfast.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AOT;
using Draco;
using Draco.Encode;
using GLTFast.Addons;
using GLTFast.FakeSchema;
using GLTFast.Jobs;
using GLTFast.Loading;
using GLTFast.Logging;
using GLTFast.Materials;
using GLTFast.Newtonsoft.Schema;
using GLTFast.Schema;
using GLTFast.Vertex;
using KtxUnity;
using Meshoptimizer;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Unity.Burst;
using Unity.Burst.CompilerServices;
using Unity.Burst.Intrinsics;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using Unity.Jobs.LowLevel.Unsafe;
using Unity.Mathematics;
using Unity.Properties;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
using UnityEngine.Scripting.APIUpdating;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Unity.Burst.Tests")]
[assembly: InternalsVisibleTo("Unity.Collections.BurstCompatibilityTestCodeGen")]
[assembly: InternalsVisibleTo("Unity.Collections.Tests")]
[assembly: InternalsVisibleTo("Unity.Collections.CodeGen")]
[assembly: InternalsVisibleTo("Unity.Collections.Editor")]
[assembly: InternalsVisibleTo("Unity.Collections.PerformanceTests")]
[assembly: InternalsVisibleTo("Unity.Entities")]
[assembly: InternalsVisibleTo("Unity.Entities.CodeGen")]
[assembly: InternalsVisibleTo("Unity.Entities.Tests")]
[assembly: InternalsVisibleTo("Unity.Entities.Editor")]
[assembly: InternalsVisibleTo("Unity.Entities.Editor.Tests")]
[assembly: InternalsVisibleTo("Unity.Entities.Graphics")]
[assembly: InternalsVisibleTo("Unity.Entities.Hybrid")]
[assembly: InternalsVisibleTo("Unity.Runtime")]
[assembly: InternalsVisibleTo("Unity.Runtime.Tests")]
[assembly: InternalsVisibleTo("Unity.Runtime.IO.Tests")]
[assembly: InternalsVisibleTo("Unity.Runtime.UnityInstance")]
[assembly: InternalsVisibleTo("Unity.Scenes")]
[assembly: InternalsVisibleTo("Unity.Scenes.Editor")]
[assembly: InternalsVisibleTo("Samples.GridPath.Tests")]
[assembly: InternalsVisibleTo("Unity.Entities.PerformanceTests")]
[assembly: InternalsVisibleTo("Draco.Editor")]
[assembly: InternalsVisibleTo("Draco.Encode")]
[assembly: InternalsVisibleTo("Unity.Meshopt.Decompress.Tests")]
[assembly: InternalsVisibleTo("Ktx.Editor")]
[assembly: InternalsVisibleTo("Ktx.Tests")]
[assembly: InternalsVisibleTo("glTF-test-framework.Tests")]
[assembly: InternalsVisibleTo("glTFast.Editor.Tests")]
[assembly: InternalsVisibleTo("glTFast.Editor")]
[assembly: InternalsVisibleTo("glTFast.Export")]
[assembly: InternalsVisibleTo("glTFast.Tests")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.unity.cloud.gltfast")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+96f53e8a4c82f77e653e0b355daed60af30a20a5")]
[assembly: AssemblyProduct("com.unity.cloud.gltfast")]
[assembly: AssemblyTitle("com.unity.cloud.gltfast")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsUnmanagedAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GLTFast
{
	[Flags]
	internal enum AccessorUsage
	{
		Unknown = 0,
		Ignore = 1,
		Index = 2,
		IndexFlipped = 4,
		Position = 8,
		Normal = 0x10,
		Tangent = 0x20,
		UV = 0x40,
		Color = 0x80,
		InverseBindMatrix = 0x100,
		AnimationTimes = 0x200,
		Translation = 0x400,
		Rotation = 0x800,
		Scale = 0x1000,
		Weight = 0x2000,
		RequiredForInstantiation = 0x4000
	}
	public enum AnimationMethod
	{
		None,
		Legacy,
		Mecanim
	}
	internal static class AnimationUtils
	{
		private const float k_TimeEpsilon = 1E-05f;

		public static void AddTranslationCurves(AnimationClip clip, string animationPath, NativeArray<float> times, NativeArray<Vector3> translations, InterpolationType interpolationType)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<float3> values = translations.Reinterpret<float3>();
			AddVec3Curves(clip, animationPath, "localPosition.", times, values, interpolationType);
		}

		public static void AddScaleCurves(AnimationClip clip, string animationPath, NativeArray<float> times, NativeArray<Vector3> translations, InterpolationType interpolationType)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<float3> values = translations.Reinterpret<float3>();
			AddVec3Curves(clip, animationPath, "localScale.", times, values, interpolationType);
		}

		public static void AddRotationCurves(AnimationClip clip, string animationPath, NativeArray<float> times, NativeArray<Quaternion> quaternions, InterpolationType interpolationType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			AnimationCurve val = new AnimationCurve();
			AnimationCurve val2 = new AnimationCurve();
			AnimationCurve val3 = new AnimationCurve();
			AnimationCurve val4 = new AnimationCurve();
			NativeArray<quaternion> val5 = quaternions.Reinterpret<quaternion>();
			switch (interpolationType)
			{
			case InterpolationType.Step:
			{
				for (int k = 0; k < times.Length; k++)
				{
					float num5 = times[k];
					quaternion val14 = val5[k];
					val.AddKey(new Keyframe(num5, val14.value.x, float.PositiveInfinity, 0f));
					val2.AddKey(new Keyframe(num5, val14.value.y, float.PositiveInfinity, 0f));
					val3.AddKey(new Keyframe(num5, val14.value.z, float.PositiveInfinity, 0f));
					val4.AddKey(new Keyframe(num5, val14.value.w, float.PositiveInfinity, 0f));
				}
				break;
			}
			case InterpolationType.CubicSpline:
			{
				for (int j = 0; j < times.Length; j++)
				{
					float num4 = times[j];
					quaternion val11 = val5[j * 3];
					quaternion val12 = val5[j * 3 + 1];
					quaternion val13 = val5[j * 3 + 2];
					val.AddKey(new Keyframe(num4, val12.value.x, val11.value.x, val13.value.x, 0.5f, 0.5f));
					val2.AddKey(new Keyframe(num4, val12.value.y, val11.value.y, val13.value.y, 0.5f, 0.5f));
					val3.AddKey(new Keyframe(num4, val12.value.z, val11.value.z, val13.value.z, 0.5f, 0.5f));
					val4.AddKey(new Keyframe(num4, val12.value.w, val11.value.w, val13.value.w, 0.5f, 0.5f));
				}
				break;
			}
			default:
			{
				float num = times[0];
				quaternion val6 = val5[0];
				quaternion val7 = default(quaternion);
				((quaternion)(ref val7))..ctor(new float4(0f));
				quaternion val10 = default(quaternion);
				for (int i = 1; i < times.Length; i++)
				{
					float num2 = times[i];
					quaternion val8 = val5[i];
					if (!(num >= num2))
					{
						if (math.dot(val6, val8) < 0f)
						{
							val8.value = -val8.value;
						}
						float num3 = num2 - num;
						float4 val9 = val8.value - val6.value;
						if (num3 < 1E-05f)
						{
							val10.value.x = (((val9.x < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
							val10.value.y = (((val9.y < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
							val10.value.z = (((val9.z < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
							val10.value.w = (((val9.w < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
						}
						else
						{
							val10 = quaternion.op_Implicit(val9 / num3);
						}
						val.AddKey(new Keyframe(num, val6.value.x, val7.value.x, val10.value.x));
						val2.AddKey(new Keyframe(num, val6.value.y, val7.value.y, val10.value.y));
						val3.AddKey(new Keyframe(num, val6.value.z, val7.value.z, val10.value.z));
						val4.AddKey(new Keyframe(num, val6.value.w, val7.value.w, val10.value.w));
						val7 = val10;
						num = num2;
						val6 = val8;
					}
				}
				val.AddKey(new Keyframe(num, val6.value.x, val7.value.x, 0f));
				val2.AddKey(new Keyframe(num, val6.value.y, val7.value.y, 0f));
				val3.AddKey(new Keyframe(num, val6.value.z, val7.value.z, 0f));
				val4.AddKey(new Keyframe(num, val6.value.w, val7.value.w, 0f));
				break;
			}
			}
			clip.SetCurve(animationPath, typeof(Transform), "localRotation.x", val);
			clip.SetCurve(animationPath, typeof(Transform), "localRotation.y", val2);
			clip.SetCurve(animationPath, typeof(Transform), "localRotation.z", val3);
			clip.SetCurve(animationPath, typeof(Transform), "localRotation.w", val4);
		}

		public static string CreateAnimationPath(int nodeIndex, string[] nodeNames, int[] parentIndex)
		{
			StringBuilder stringBuilder = new StringBuilder();
			do
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Insert(0, '/');
				}
				stringBuilder.Insert(0, nodeNames[nodeIndex]);
				nodeIndex = parentIndex[nodeIndex];
			}
			while (nodeIndex >= 0);
			return stringBuilder.ToString();
		}

		public static void AddMorphTargetWeightCurves(AnimationClip clip, string animationPath, NativeArray<float> times, NativeArray<float> values, InterpolationType interpolationType, string[] morphTargetNames = null)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			int num;
			if (morphTargetNames == null)
			{
				num = values.Length / times.Length;
				if (interpolationType == InterpolationType.CubicSpline)
				{
					num /= 3;
				}
			}
			else
			{
				num = morphTargetNames.Length;
			}
			for (int i = 0; i < num; i++)
			{
				string propertyPrefix = ((morphTargetNames == null) ? i.ToString() : morphTargetNames[i]);
				AddScalarCurve(clip, animationPath, propertyPrefix, i, num, times, values, interpolationType);
			}
		}

		private static void AddVec3Curves(AnimationClip clip, string animationPath, string propertyPrefix, NativeArray<float> times, NativeArray<float3> values, InterpolationType interpolationType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			AnimationCurve val = new AnimationCurve();
			AnimationCurve val2 = new AnimationCurve();
			AnimationCurve val3 = new AnimationCurve();
			switch (interpolationType)
			{
			case InterpolationType.Step:
			{
				for (int k = 0; k < times.Length; k++)
				{
					float num5 = times[k];
					float3 val12 = values[k];
					val.AddKey(new Keyframe(num5, val12.x, float.PositiveInfinity, 0f));
					val2.AddKey(new Keyframe(num5, val12.y, float.PositiveInfinity, 0f));
					val3.AddKey(new Keyframe(num5, val12.z, float.PositiveInfinity, 0f));
				}
				break;
			}
			case InterpolationType.CubicSpline:
			{
				for (int j = 0; j < times.Length; j++)
				{
					float num4 = times[j];
					float3 val9 = values[j * 3];
					float3 val10 = values[j * 3 + 1];
					float3 val11 = values[j * 3 + 2];
					val.AddKey(new Keyframe(num4, val10.x, val9.x, val11.x, 0.5f, 0.5f));
					val2.AddKey(new Keyframe(num4, val10.y, val9.y, val11.y, 0.5f, 0.5f));
					val3.AddKey(new Keyframe(num4, val10.z, val9.z, val11.z, 0.5f, 0.5f));
				}
				break;
			}
			default:
			{
				float num = times[0];
				float3 val4 = values[0];
				float3 val5 = default(float3);
				((float3)(ref val5))..ctor(0f);
				float3 val8 = default(float3);
				for (int i = 1; i < times.Length; i++)
				{
					float num2 = times[i];
					float3 val6 = values[i];
					if (!(num >= num2))
					{
						float num3 = num2 - num;
						float3 val7 = val6 - val4;
						if (num3 < 1E-05f)
						{
							val8.x = (((val7.x < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
							val8.y = (((val7.y < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
							val8.z = (((val7.z < 0f) ^ (num3 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity);
						}
						else
						{
							val8 = val7 / num3;
						}
						val.AddKey(new Keyframe(num, val4.x, val5.x, val8.x));
						val2.AddKey(new Keyframe(num, val4.y, val5.y, val8.y));
						val3.AddKey(new Keyframe(num, val4.z, val5.z, val8.z));
						val5 = val8;
						num = num2;
						val4 = val6;
					}
				}
				val.AddKey(new Keyframe(num, val4.x, val5.x, 0f));
				val2.AddKey(new Keyframe(num, val4.y, val5.y, 0f));
				val3.AddKey(new Keyframe(num, val4.z, val5.z, 0f));
				break;
			}
			}
			clip.SetCurve(animationPath, typeof(Transform), propertyPrefix + "x", val);
			clip.SetCurve(animationPath, typeof(Transform), propertyPrefix + "y", val2);
			clip.SetCurve(animationPath, typeof(Transform), propertyPrefix + "z", val3);
		}

		private static void AddScalarCurve(AnimationClip clip, string animationPath, string propertyPrefix, int curveIndex, int valueStride, NativeArray<float> times, NativeArray<float> values, InterpolationType interpolationType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			AnimationCurve val = new AnimationCurve();
			switch (interpolationType)
			{
			case InterpolationType.Step:
			{
				for (int k = 0; k < times.Length; k++)
				{
					float num15 = times[k];
					int num16 = k * valueStride + curveIndex;
					float num17 = values[num16];
					val.AddKey(new Keyframe(num15, num17, float.PositiveInfinity, 0f));
				}
				break;
			}
			case InterpolationType.CubicSpline:
			{
				for (int j = 0; j < times.Length; j++)
				{
					float num10 = times[j];
					int num11 = j * valueStride + curveIndex;
					float num12 = values[num11 * 3];
					float num13 = values[num11 * 3 + 1];
					float num14 = values[num11 * 3 + 2];
					val.AddKey(new Keyframe(num10, num13, num12, num14, 0.5f, 0.5f));
				}
				break;
			}
			default:
			{
				float num = times[0];
				float num2 = values[curveIndex];
				float num3 = 0f;
				for (int i = 1; i < times.Length; i++)
				{
					float num4 = times[i];
					int num5 = i * valueStride + curveIndex;
					float num6 = values[num5];
					if (!(num >= num4))
					{
						float num7 = num4 - num;
						float num8 = num6 - num2;
						float num9 = ((!(num7 < 1E-05f)) ? (num8 / num7) : (((num8 < 0f) ^ (num7 < 0f)) ? float.NegativeInfinity : float.PositiveInfinity));
						val.AddKey(new Keyframe(num, num2, num3, num9));
						num3 = num9;
						num = num4;
						num2 = num6;
					}
				}
				val.AddKey(new Keyframe(num, num2, num3, 0f));
				break;
			}
			}
			clip.SetCurve(animationPath, typeof(SkinnedMeshRenderer), "blendShape." + propertyPrefix, val);
		}
	}
	[Flags]
	public enum ComponentType
	{
		None = 0,
		Mesh = 2,
		Animation = 4,
		Camera = 8,
		Light = 0x10,
		All = -1
	}
	[RequireComponent(typeof(IDeferAgent))]
	[DefaultExecutionOrder(-1)]
	internal class DefaultDeferAgent : MonoBehaviour
	{
		private void OnEnable()
		{
			IDeferAgent component = ((Component)this).GetComponent<IDeferAgent>();
			if (component != null)
			{
				GltfImportBase.SetDefaultDeferAgent(component);
			}
		}

		private void OnDisable()
		{
			IDeferAgent component = ((Component)this).GetComponent<IDeferAgent>();
			if (component != null)
			{
				GltfImportBase.UnsetDefaultDeferAgent(component);
			}
		}
	}
	public class DontDestroyOnLoad : MonoBehaviour
	{
		private void Awake()
		{
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}
	}
	internal class DracoMeshGenerator : MeshGeneratorBase
	{
		private Bounds? m_Bounds;

		private readonly bool m_NeedsNormals;

		private readonly bool m_NeedsTangents;

		public DracoMeshGenerator(IReadOnlyList<MeshPrimitiveBase> primitives, SubMeshAssignment[] subMeshAssignments, string[] morphTargetNames, string meshName, GltfImportBase gltfImport)
			: base(meshName)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			MorphTarget[] targets = primitives[0].targets;
			bool flag = targets != null && targets.Length != 0;
			int num = 0;
			int[] array = (flag ? new int[primitives.Count + 1] : null);
			for (int i = 0; i < primitives.Count; i++)
			{
				MeshPrimitiveBase meshPrimitiveBase = primitives[i];
				AccessorBase accessor = ((IGltfBuffers)gltfImport).GetAccessor(meshPrimitiveBase.attributes.POSITION);
				if (flag)
				{
					array[i] = num;
				}
				num += accessor.count;
				Bounds? val = accessor.TryGetBounds();
				if (val.HasValue)
				{
					m_Bounds = val.Value;
				}
				else
				{
					gltfImport.Logger?.Error(LogCode.MeshBoundsMissing, meshPrimitiveBase.attributes.POSITION.ToString());
				}
				if (meshPrimitiveBase.material < 0)
				{
					m_NeedsNormals = true;
					continue;
				}
				MaterialBase sourceMaterial = gltfImport.GetSourceMaterial(meshPrimitiveBase.material);
				m_NeedsNormals |= sourceMaterial.RequiresNormals;
				m_NeedsTangents |= sourceMaterial.RequiresTangents;
			}
			if (flag)
			{
				InitializeMorphTargets(primitives, morphTargetNames, array, num, targets, gltfImport);
			}
			m_CreationTask = Decode(primitives, gltfImport);
		}

		private void InitializeMorphTargets(IReadOnlyList<MeshPrimitiveBase> primitives, string[] morphTargetNames, int[] vertexIntervals, int vertexCount, MorphTarget[] morphTargets, GltfImportBase gltfImport)
		{
			vertexIntervals[^1] = vertexCount;
			m_MorphTargetsGenerator = new MorphTargetsGenerator(vertexCount, 1, morphTargets.Length, morphTargetNames, morphTargets[0].NORMAL >= 0, morphTargets[0].TANGENT >= 0, gltfImport);
			for (int i = 0; i < primitives.Count; i++)
			{
				MeshPrimitiveBase meshPrimitiveBase = primitives[i];
				for (int j = 0; j < meshPrimitiveBase.targets.Length; j++)
				{
					MorphTarget morphTarget = meshPrimitiveBase.targets[j];
					m_MorphTargetsGenerator.AddMorphTarget(0, j, morphTarget);
				}
			}
		}

		private async Task<Mesh> Decode(IReadOnlyList<MeshPrimitiveBase> primitives, IGltfBuffers buffers)
		{
			Mesh mesh = null;
			foreach (MeshPrimitiveBase primitive in primitives)
			{
				MeshPrimitiveDracoExtension kHR_draco_mesh_compression = primitive.Extensions.KHR_draco_mesh_compression;
				int byteStride;
				NativeSlice<byte> bufferView = buffers.GetBufferView(kHR_draco_mesh_compression.bufferView, out byteStride);
				mesh = await StartDecode(bufferView, kHR_draco_mesh_compression.attributes);
			}
			if (mesh == null)
			{
				return null;
			}
			if (m_Bounds.HasValue)
			{
				mesh.bounds = m_Bounds.Value;
				for (int i = 0; i < mesh.subMeshCount; i++)
				{
					SubMeshDescriptor subMesh = mesh.GetSubMesh(i);
					((SubMeshDescriptor)(ref subMesh)).bounds = m_Bounds.Value;
					mesh.SetSubMesh(i, subMesh, (MeshUpdateFlags)15);
				}
			}
			else
			{
				mesh.RecalculateBounds();
			}
			if (m_MorphTargetsGenerator != null)
			{
				await m_MorphTargetsGenerator.ApplyOnMeshAndDispose(mesh);
			}
			((Object)mesh).name = m_MeshName;
			return mesh;
		}

		private async Task<Mesh> StartDecode(NativeSlice<byte> data, Attributes dracoAttributes)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			DecodeSettings decodeSettings = DecodeSettings.ConvertSpace;
			if (m_NeedsTangents)
			{
				decodeSettings |= DecodeSettings.RequireNormalsAndTangents;
			}
			else if (m_NeedsNormals)
			{
				decodeSettings |= DecodeSettings.RequireNormals;
			}
			if (m_MorphTargetsGenerator != null)
			{
				decodeSettings |= DecodeSettings.ForceUnityVertexLayout;
			}
			return await DracoDecoder.DecodeMesh(data, decodeSettings, GenerateAttributeIdMap(dracoAttributes));
		}

		private static Dictionary<VertexAttribute, int> GenerateAttributeIdMap(Attributes attributes)
		{
			Dictionary<VertexAttribute, int> dictionary = new Dictionary<VertexAttribute, int>();
			if (attributes.POSITION >= 0)
			{
				dictionary[(VertexAttribute)0] = attributes.POSITION;
			}
			if (attributes.NORMAL >= 0)
			{
				dictionary[(VertexAttribute)1] = attributes.NORMAL;
			}
			if (attributes.TANGENT >= 0)
			{
				dictionary[(VertexAttribute)2] = attributes.TANGENT;
			}
			if (attributes.COLOR_0 >= 0)
			{
				dictionary[(VertexAttribute)3] = attributes.COLOR_0;
			}
			if (attributes.TEXCOORD_0 >= 0)
			{
				dictionary[(VertexAttribute)4] = attributes.TEXCOORD_0;
			}
			if (attributes.TEXCOORD_1 >= 0)
			{
				dictionary[(VertexAttribute)5] = attributes.TEXCOORD_1;
			}
			if (attributes.TEXCOORD_2 >= 0)
			{
				dictionary[(VertexAttribute)6] = attributes.TEXCOORD_2;
			}
			if (attributes.TEXCOORD_3 >= 0)
			{
				dictionary[(VertexAttribute)7] = attributes.TEXCOORD_3;
			}
			if (attributes.TEXCOORD_4 >= 0)
			{
				dictionary[(VertexAttribute)8] = attributes.TEXCOORD_4;
			}
			if (attributes.TEXCOORD_5 >= 0)
			{
				dictionary[(VertexAttribute)9] = attributes.TEXCOORD_5;
			}
			if (attributes.TEXCOORD_6 >= 0)
			{
				dictionary[(VertexAttribute)10] = attributes.TEXCOORD_6;
			}
			if (attributes.TEXCOORD_7 >= 0)
			{
				dictionary[(VertexAttribute)11] = attributes.TEXCOORD_7;
			}
			if (attributes.WEIGHTS_0 >= 0)
			{
				dictionary[(VertexAttribute)12] = attributes.WEIGHTS_0;
			}
			if (attributes.JOINTS_0 >= 0)
			{
				dictionary[(VertexAttribute)13] = attributes.JOINTS_0;
			}
			return dictionary;
		}
	}
	public enum Extension
	{
		DracoMeshCompression,
		LightsPunctual,
		MaterialsPbrSpecularGlossiness,
		MaterialsTransmission,
		MaterialsUnlit,
		MeshGPUInstancing,
		MeshQuantization,
		TextureBasisUniversal,
		TextureTransform,
		MaterialsClearcoat,
		MaterialsVariants,
		MeshoptCompression,
		MaterialsIor,
		MaterialsSheen,
		MaterialsSpecular
	}
	public static class ExtensionName
	{
		public const string DracoMeshCompression = "KHR_draco_mesh_compression";

		public const string MaterialsPbrSpecularGlossiness = "KHR_materials_pbrSpecularGlossiness";

		public const string MaterialsTransmission = "KHR_materials_transmission";

		public const string MaterialsUnlit = "KHR_materials_unlit";

		public const string MeshGPUInstancing = "EXT_mesh_gpu_instancing";

		public const string MeshoptCompression = "EXT_meshopt_compression";

		public const string MeshQuantization = "KHR_mesh_quantization";

		public const string TextureBasisUniversal = "KHR_texture_basisu";

		public const string TextureTransform = "KHR_texture_transform";

		public const string LightsPunctual = "KHR_lights_punctual";

		public const string MaterialsClearcoat = "KHR_materials_clearcoat";

		public const string MaterialsIor = "KHR_materials_ior";

		public const string MaterialsSheen = "KHR_materials_sheen";

		public const string MaterialsSpecular = "KHR_materials_specular";

		public const string MaterialsVariants = "KHR_materials_variants";

		public static string GetName(this Extension extension)
		{
			return extension switch
			{
				Extension.DracoMeshCompression => "KHR_draco_mesh_compression", 
				Extension.LightsPunctual => "KHR_lights_punctual", 
				Extension.MaterialsPbrSpecularGlossiness => "KHR_materials_pbrSpecularGlossiness", 
				Extension.MaterialsTransmission => "KHR_materials_transmission", 
				Extension.MaterialsUnlit => "KHR_materials_unlit", 
				Extension.MeshGPUInstancing => "EXT_mesh_gpu_instancing", 
				Extension.MeshQuantization => "KHR_mesh_quantization", 
				Extension.TextureBasisUniversal => "KHR_texture_basisu", 
				Extension.TextureTransform => "KHR_texture_transform", 
				Extension.MaterialsClearcoat => "KHR_materials_clearcoat", 
				Extension.MaterialsVariants => "KHR_materials_variants", 
				Extension.MeshoptCompression => "EXT_meshopt_compression", 
				Extension.MaterialsIor => "KHR_materials_ior", 
				Extension.MaterialsSpecular => "KHR_materials_specular", 
				Extension.MaterialsSheen => "KHR_materials_sheen", 
				_ => null, 
			};
		}
	}
	internal class FlatArray<T>
	{
		[CompilerGenerated]
		private sealed class <Values>d__12 : IEnumerable<T>, IEnumerable, IEnumerator<T>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private T <>2__current;

			private int <>l__initialThreadId;

			public FlatArray<T> <>4__this;

			private int primaryIndex;

			public int <>3__primaryIndex;

			private int <end>5__2;

			private int <i>5__3;

			T IEnumerator<T>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Values>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				FlatArray<T> flatArray = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					flatArray.GetIndexRange(primaryIndex, out var start, out <end>5__2);
					<i>5__3 = start;
					break;
				}
				case 1:
					<>1__state = -1;
					<i>5__3++;
					break;
				}
				if (<i>5__3 < <end>5__2)
				{
					<>2__current = flatArray.m_Array[<i>5__3];
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<T> IEnumerable<T>.GetEnumerator()
			{
				<Values>d__12 <Values>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<Values>d__ = this;
				}
				else
				{
					<Values>d__ = new <Values>d__12(0)
					{
						<>4__this = <>4__this
					};
				}
				<Values>d__.primaryIndex = <>3__primaryIndex;
				return <Values>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<T>)this).GetEnumerator();
			}
		}

		private readonly T[] m_Array;

		private readonly int[] m_Indices;

		public int Length => m_Array.Length;

		public T this[int key] => m_Array[key];

		public FlatArray(int[] indices)
		{
			m_Indices = indices;
			int num = indices[^1];
			m_Array = new T[num];
		}

		public int GetLength(int primaryIndex)
		{
			int num = m_Indices[primaryIndex];
			return m_Indices[primaryIndex + 1] - num;
		}

		public T GetValue(int primaryIndex, int secondaryIndex)
		{
			int index = GetIndex(primaryIndex, secondaryIndex);
			return m_Array[index];
		}

		public void SetValue(int primaryIndex, int secondaryIndex, T value)
		{
			int index = GetIndex(primaryIndex, secondaryIndex);
			m_Array[index] = value;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private int GetIndex(int primaryIndex, int secondaryIndex)
		{
			int num = m_Indices[primaryIndex];
			_ = m_Indices[primaryIndex + 1];
			return num + secondaryIndex;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private void GetIndexRange(int primaryIndex, out int start, out int end)
		{
			start = m_Indices[primaryIndex];
			end = m_Indices[primaryIndex + 1];
		}

		[IteratorStateMachine(typeof(FlatArray<>.<Values>d__12))]
		public IEnumerable<T> Values(int primaryIndex)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Values>d__12(-2)
			{
				<>4__this = this,
				<>3__primaryIndex = primaryIndex
			};
		}
	}
	public class GameObjectBoundsInstantiator : GameObjectInstantiator
	{
		private Dictionary<uint, Bounds> m_NodeBounds;

		public GameObjectBoundsInstantiator(IGltfReadable gltf, Transform parent, ICodeLogger logger = null, InstantiationSettings settings = null)
			: base(gltf, parent, logger, settings)
		{
		}

		public override void BeginScene(string name, uint[] rootNodeIndices)
		{
			base.BeginScene(name, rootNodeIndices);
			m_NodeBounds = new Dictionary<uint, Bounds>();
		}

		public override void AddPrimitive(uint nodeIndex, string meshName, MeshResult meshResult, uint[] joints = null, uint? rootJoint = null, float[] morphTargetWeights = null, int meshNumeration = 0)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			base.AddPrimitive(nodeIndex, meshName, meshResult, joints, rootJoint, morphTargetWeights, meshNumeration);
			if (m_NodeBounds != null)
			{
				Bounds transformedBounds = GetTransformedBounds(meshResult.mesh.bounds, m_Parent.worldToLocalMatrix * m_Nodes[nodeIndex].transform.localToWorldMatrix);
				if (m_NodeBounds.TryGetValue(nodeIndex, out var value))
				{
					((Bounds)(ref transformedBounds)).Encapsulate(value);
					m_NodeBounds[nodeIndex] = transformedBounds;
				}
				else
				{
					m_NodeBounds[nodeIndex] = transformedBounds;
				}
			}
		}

		public Bounds? CalculateBounds()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (m_NodeBounds == null)
			{
				return null;
			}
			bool flag = false;
			Bounds value = default(Bounds);
			foreach (Bounds value2 in m_NodeBounds.Values)
			{
				if (flag)
				{
					((Bounds)(ref value)).Encapsulate(value2);
					continue;
				}
				value = value2;
				flag = true;
			}
			if (!flag)
			{
				return null;
			}
			return value;
		}

		private static Bounds GetTransformedBounds(Bounds b, Matrix4x4 transform)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			Vector3 extents = ((Bounds)(ref b)).extents;
			for (int i = 0; i < 8; i++)
			{
				Vector3 center = ((Bounds)(ref b)).center;
				center.x += (((i & 1) == 0) ? extents.x : (0f - extents.x));
				center.y += (((i & 2) == 0) ? extents.y : (0f - extents.y));
				center.z += (((i & 4) == 0) ? extents.z : (0f - extents.z));
				array[i] = center;
			}
			return GeometryUtility.CalculateBounds(array, transform);
		}
	}
	public class GameObjectInstantiator : IInstantiator
	{
		public delegate void NodeCreatedDelegate(uint nodeIndex, GameObject gameObject);

		public delegate void MeshAddedDelegate(GameObject gameObject, uint nodeIndex, string meshName, MeshResult meshResult, uint[] joints = null, uint? rootJoint = null, float[] morphTargetWeights = null, int meshNumeration = 0);

		protected InstantiationSettings m_Settings;

		protected ICodeLogger m_Logger;

		protected IGltfReadable m_Gltf;

		protected Transform m_Parent;

		protected Dictionary<uint, GameObject> m_Nodes;

		private List<IMaterialsVariantsSlotInstance> m_InstanceSlots;

		public Transform SceneTransform { get; protected set; }

		public GameObjectSceneInstance SceneInstance { get; protected set; }

		public event NodeCreatedDelegate NodeCreated;

		public event MeshAddedDelegate MeshAdded;

		public event Action EndSceneCompleted;

		public GameObjectInstantiator(IGltfReadable gltf, Transform parent, ICodeLogger logger = null, InstantiationSettings settings = null)
		{
			m_Gltf = gltf;
			m_Parent = parent;
			m_Logger = logger;
			m_Settings = settings ?? new InstantiationSettings();
		}

		public virtual void BeginScene(string name, uint[] rootNodeIndices)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			m_Nodes = new Dictionary<uint, GameObject>();
			SceneInstance = new GameObjectSceneInstance();
			GameObject val;
			if (m_Settings.SceneObjectCreation == SceneObjectCreation.Never || (m_Settings.SceneObjectCreation == SceneObjectCreation.WhenMultipleRootNodes && rootNodeIndices.Length == 1))
			{
				val = ((Component)m_Parent).gameObject;
			}
			else
			{
				val = new GameObject(name ?? "Scene");
				val.transform.SetParent(m_Parent, false);
				val.layer = m_Settings.Layer;
			}
			SceneTransform = val.transform;
		}

		public void AddAnimation(AnimationClip[] animationClips)
		{
			if ((m_Settings.Mask & ComponentType.Animation) == 0 || animationClips == null)
			{
				return;
			}
			if (animationClips.Length != 0 && animationClips[0].legacy)
			{
				Animation val = ((Component)SceneTransform).gameObject.AddComponent<Animation>();
				for (int i = 0; i < animationClips.Length; i++)
				{
					AnimationClip val2 = animationClips[i];
					val.AddClip(val2, ((Object)val2).name);
					if (i < 1)
					{
						val.clip = val2;
					}
				}
				SceneInstance.SetLegacyAnimation(val);
			}
			else
			{
				((Component)SceneTransform).gameObject.AddComponent<Animator>();
			}
		}

		public void CreateNode(uint nodeIndex, uint? parentIndex, Vector3 position, Quaternion rotation, Vector3 scale)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject();
			val.SetActive(parentIndex.HasValue);
			val.transform.localScale = scale;
			val.transform.localPosition = position;
			val.transform.localRotation = rotation;
			val.layer = m_Settings.Layer;
			m_Nodes[nodeIndex] = val;
			val.transform.SetParent(parentIndex.HasValue ? m_Nodes[parentIndex.Value].transform : SceneTransform, false);
			this.NodeCreated?.Invoke(nodeIndex, val);
		}

		public virtual void SetNodeName(uint nodeIndex, string name)
		{
			((Object)m_Nodes[nodeIndex]).name = name ?? $"Node-{nodeIndex}";
		}

		public virtual void AddPrimitive(uint nodeIndex, string meshName, MeshResult meshResult, uint[] joints = null, uint? rootJoint = null, float[] morphTargetWeights = null, int meshNumeration = 0)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if ((m_Settings.Mask & ComponentType.Mesh) == 0)
			{
				return;
			}
			GameObject val;
			if (meshNumeration == 0)
			{
				val = m_Nodes[nodeIndex];
			}
			else
			{
				val = new GameObject(meshName);
				val.transform.SetParent(m_Nodes[nodeIndex].transform, false);
				val.layer = m_Settings.Layer;
			}
			bool flag = meshResult.mesh.blendShapeCount > 0;
			Renderer val2;
			if (joints == null && !flag)
			{
				val.AddComponent<MeshFilter>().mesh = meshResult.mesh;
				val2 = (Renderer)(object)val.AddComponent<MeshRenderer>();
			}
			else
			{
				SkinnedMeshRenderer val3 = val.AddComponent<SkinnedMeshRenderer>();
				val3.updateWhenOffscreen = m_Settings.SkinUpdateWhenOffscreen;
				if (joints != null)
				{
					Transform[] array = (Transform[])(object)new Transform[joints.Length];
					for (int i = 0; i < array.Length; i++)
					{
						uint key = joints[i];
						array[i] = m_Nodes[key].transform;
					}
					val3.bones = array;
					if (rootJoint.HasValue)
					{
						val3.rootBone = m_Nodes[rootJoint.Value].transform;
					}
				}
				val3.sharedMesh = meshResult.mesh;
				if (morphTargetWeights != null)
				{
					for (int j = 0; j < morphTargetWeights.Length; j++)
					{
						float num = morphTargetWeights[j];
						val3.SetBlendShapeWeight(j, num);
					}
				}
				val2 = (Renderer)(object)val3;
			}
			Material[] array2 = (Material[])(object)new Material[meshResult.materialIndices.Length];
			for (int k = 0; k < array2.Length; k++)
			{
				Material val4 = m_Gltf.GetMaterial(meshResult.materialIndices[k]) ?? m_Gltf.GetDefaultMaterial();
				array2[k] = val4;
			}
			val2.sharedMaterials = array2;
			IMaterialsVariantsSlot[] materialsVariantsSlots = m_Gltf.GetMaterialsVariantsSlots(meshResult.meshIndex, meshNumeration);
			if (materialsVariantsSlots != null && materialsVariantsSlots.Length != 0)
			{
				if (m_InstanceSlots == null)
				{
					m_InstanceSlots = new List<IMaterialsVariantsSlotInstance>();
				}
				MaterialsVariantsSlotInstances materialsVariantsSlotInstances = new MaterialsVariantsSlotInstances(val2, materialsVariantsSlots);
				m_InstanceSlots.Add(materialsVariantsSlotInstances);
			}
			this.MeshAdded?.Invoke(val, nodeIndex, meshName, meshResult, joints, rootJoint, morphTargetWeights, meshNumeration);
		}

		public virtual void AddPrimitiveInstanced(uint nodeIndex, string meshName, MeshResult meshResult, uint instanceCount, NativeArray<Vector3>? positions, NativeArray<Quaternion>? rotations, NativeArray<Vector3>? scales, int meshNumeration = 0)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			if ((m_Settings.Mask & ComponentType.Mesh) == 0)
			{
				return;
			}
			Material[] array = (Material[])(object)new Material[meshResult.materialIndices.Length];
			for (int i = 0; i < array.Length; i++)
			{
				Material val = m_Gltf.GetMaterial(meshResult.materialIndices[i]) ?? m_Gltf.GetDefaultMaterial();
				val.enableInstancing = true;
				array[i] = val;
			}
			IMaterialsVariantsSlot[] materialsVariantsSlots = m_Gltf.GetMaterialsVariantsSlots(meshResult.meshIndex, meshNumeration);
			bool flag = materialsVariantsSlots != null && materialsVariantsSlots.Length != 0;
			Renderer[] array2 = (Renderer[])(object)(flag ? new Renderer[instanceCount] : null);
			for (int j = 0; j < instanceCount; j++)
			{
				GameObject val2 = new GameObject($"{meshName}_i{j}")
				{
					layer = m_Settings.Layer
				};
				Transform transform = val2.transform;
				transform.SetParent(m_Nodes[nodeIndex].transform, false);
				transform.localPosition = positions?[j] ?? Vector3.zero;
				transform.localRotation = rotations?[j] ?? Quaternion.identity;
				transform.localScale = scales?[j] ?? Vector3.one;
				val2.AddComponent<MeshFilter>().mesh = meshResult.mesh;
				Renderer val3 = (Renderer)(object)val2.AddComponent<MeshRenderer>();
				val3.sharedMaterials = array;
				if (flag)
				{
					array2[j] = val3;
				}
			}
			if (flag)
			{
				if (m_InstanceSlots == null)
				{
					m_InstanceSlots = new List<IMaterialsVariantsSlotInstance>();
				}
				MultiMaterialsVariantsSlotInstances multiMaterialsVariantsSlotInstances = new MultiMaterialsVariantsSlotInstances(array2, materialsVariantsSlots);
				m_InstanceSlots.Add(multiMaterialsVariantsSlotInstances);
			}
		}

		public virtual void AddCamera(uint nodeIndex, uint cameraIndex)
		{
			if ((m_Settings.Mask & ComponentType.Camera) != 0)
			{
				CameraBase sourceCamera = m_Gltf.GetSourceCamera(cameraIndex);
				switch (sourceCamera.GetCameraType())
				{
				case CameraBase.Type.Orthographic:
				{
					GLTFast.Schema.CameraOrthographic orthographic = sourceCamera.Orthographic;
					AddCameraOrthographic(nodeIndex, orthographic.znear, (orthographic.zfar >= 0f) ? new float?(orthographic.zfar) : null, orthographic.xmag, orthographic.ymag, sourceCamera.name);
					break;
				}
				case CameraBase.Type.Perspective:
				{
					GLTFast.Schema.CameraPerspective perspective = sourceCamera.Perspective;
					AddCameraPerspective(nodeIndex, perspective.yfov, perspective.znear, perspective.zfar, (perspective.aspectRatio > 0f) ? new float?(perspective.aspectRatio) : null, sourceCamera.name);
					break;
				}
				}
			}
		}

		private void AddCameraPerspective(uint nodeIndex, float verticalFieldOfView, float nearClipPlane, float farClipPlane, float? aspectRatio, string cameraName)
		{
			float localScale;
			Camera obj = CreateCamera(nodeIndex, cameraName, out localScale);
			obj.orthographic = false;
			obj.fieldOfView = verticalFieldOfView * 57.29578f;
			obj.nearClipPlane = nearClipPlane * localScale;
			obj.farClipPlane = farClipPlane * localScale;
		}

		private void AddCameraOrthographic(uint nodeIndex, float nearClipPlane, float? farClipPlane, float horizontal, float vertical, string cameraName)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			float localScale;
			Camera obj = CreateCamera(nodeIndex, cameraName, out localScale);
			float valueOrDefault = farClipPlane.GetValueOrDefault(float.MaxValue);
			obj.orthographic = true;
			obj.nearClipPlane = nearClipPlane * localScale;
			obj.farClipPlane = valueOrDefault * localScale;
			obj.orthographicSize = vertical;
			obj.projectionMatrix = Matrix4x4.Ortho(0f - horizontal, horizontal, 0f - vertical, vertical, nearClipPlane, valueOrDefault);
		}

		private Camera CreateCamera(uint nodeIndex, string cameraName, out float localScale)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = m_Nodes[nodeIndex];
			GameObject val2 = new GameObject(string.IsNullOrEmpty(cameraName) ? $"Camera-{nodeIndex}" : (((Object)val).name + "-Camera"))
			{
				layer = m_Settings.Layer
			};
			Transform transform = val2.transform;
			Transform transform2 = val.transform;
			transform.SetParent(transform2, false);
			Quaternion localRotation = Quaternion.Euler(0f, 180f, 0f);
			transform.localRotation = localRotation;
			Camera val3 = val2.AddComponent<Camera>();
			((Behaviour)val3).enabled = false;
			SceneInstance.AddCamera(val3);
			Matrix4x4 localToWorldMatrix = transform2.localToWorldMatrix;
			Vector3 lossyScale = ((Matrix4x4)(ref localToWorldMatrix)).lossyScale;
			localScale = (lossyScale.x + lossyScale.y + lossyScale.y) / 3f;
			return val3;
		}

		public void AddLightPunctual(uint nodeIndex, uint lightIndex)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			if ((m_Settings.Mask & ComponentType.Light) != 0)
			{
				GameObject val = m_Nodes[nodeIndex];
				LightPunctual sourceLightPunctual = m_Gltf.GetSourceLightPunctual(lightIndex);
				if (sourceLightPunctual.GetLightType() != LightPunctual.Type.Point)
				{
					GameObject val2 = new GameObject(((Object)val).name + "_Orientation");
					val2.transform.SetParent(val.transform, false);
					val2.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
					val = val2;
				}
				Light val3 = val.AddComponent<Light>();
				sourceLightPunctual.ToUnityLight(val3, m_Settings.LightIntensityFactor);
				SceneInstance.AddLight(val3);
			}
		}

		public virtual void EndScene(uint[] rootNodeIndices)
		{
			if (m_InstanceSlots != null)
			{
				MaterialsVariantsControl materialsVariantsControl = new MaterialsVariantsControl(m_Gltf, m_InstanceSlots);
				SceneInstance.SetMaterialsVariantsControl(materialsVariantsControl);
			}
			if (rootNodeIndices != null)
			{
				foreach (uint key in rootNodeIndices)
				{
					m_Nodes[key].SetActive(true);
				}
			}
			this.EndSceneCompleted?.Invoke();
		}
	}
	public class GameObjectSceneInstance
	{
		private List<Camera> m_Cameras;

		private List<Light> m_Lights;

		public IReadOnlyList<Camera> Cameras => m_Cameras;

		public IReadOnlyList<Light> Lights => m_Lights;

		public MaterialsVariantsControl MaterialsVariantsControl { get; private set; }

		public Animation LegacyAnimation { get; private set; }

		internal void AddCamera(Camera camera)
		{
			if (m_Cameras == null)
			{
				m_Cameras = new List<Camera>();
			}
			m_Cameras.Add(camera);
		}

		internal void AddLight(Light light)
		{
			if (m_Lights == null)
			{
				m_Lights = new List<Light>();
			}
			m_Lights.Add(light);
		}

		internal void SetMaterialsVariantsControl(MaterialsVariantsControl control)
		{
			MaterialsVariantsControl = control;
		}

		internal void SetLegacyAnimation(Animation animation)
		{
			LegacyAnimation = animation;
		}
	}
	internal readonly struct GlbBinChunk
	{
		public int Start { get; }

		public uint Length { get; }

		public GlbBinChunk(int start, uint length)
		{
			Start = start;
			Length = length;
		}
	}
	public class GltfAsset : GltfAssetBase
	{
		[SerializeField]
		[Tooltip("URL to load the glTF from. Loading local file paths works by prefixing them with \"file://\"")]
		private string url;

		[SerializeField]
		[Tooltip("Automatically load at start.")]
		private bool loadOnStartup = true;

		[SerializeField]
		[Tooltip("Override scene to load (-1 loads glTFs default scene)")]
		private int sceneId = -1;

		[SerializeField]
		[Tooltip("If true, the first animation clip starts playing right after instantiation")]
		private bool playAutomatically = true;

		[SerializeField]
		[Tooltip("If checked, url is treated as relative StreamingAssets path.")]
		private bool streamingAsset;

		[SerializeField]
		private InstantiationSettings instantiationSettings;

		public string Url
		{
			get
			{
				return url;
			}
			set
			{
				url = value;
			}
		}

		public bool LoadOnStartup
		{
			get
			{
				return loadOnStartup;
			}
			set
			{
				loadOnStartup = value;
			}
		}

		protected int SceneId => sceneId;

		public bool PlayAutomatically => playAutomatically;

		public bool StreamingAsset
		{
			get
			{
				return streamingAsset;
			}
			set
			{
				streamingAsset = value;
			}
		}

		public InstantiationSettings InstantiationSettings
		{
			get
			{
				return instantiationSettings;
			}
			set
			{
				instantiationSettings = value;
			}
		}

		public GameObjectSceneInstance SceneInstance { get; protected set; }

		public string FullUrl
		{
			get
			{
				if (!streamingAsset)
				{
					return url;
				}
				return Path.Combine(Application.streamingAssetsPath, url);
			}
		}

		protected virtual async void Start()
		{
			if (loadOnStartup && !string.IsNullOrEmpty(url))
			{
				await Load(FullUrl);
			}
		}

		public override async Task<bool> Load(string gltfUrl, IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
		{
			logger = logger ?? new ConsoleLogger();
			bool flag = await base.Load(gltfUrl, downloadProvider, deferAgent, materialGenerator, logger);
			if (flag)
			{
				if (deferAgent != null)
				{
					await deferAgent.BreakPoint();
				}
				flag = ((sceneId < 0) ? (await Instantiate(logger)) : (await InstantiateScene(sceneId, logger)));
			}
			return flag;
		}

		protected override IInstantiator GetDefaultInstantiator(ICodeLogger logger)
		{
			return new GameObjectInstantiator(base.Importer, ((Component)this).transform, logger, instantiationSettings);
		}

		protected override void PostInstantiation(IInstantiator instantiator, bool success)
		{
			SceneInstance = (instantiator as GameObjectInstantiator)?.SceneInstance;
			if (SceneInstance != null && playAutomatically && (Object)(object)SceneInstance.LegacyAnimation != (Object)null)
			{
				SceneInstance.LegacyAnimation.Play();
			}
			base.PostInstantiation(instantiator, success);
		}

		public override void ClearScenes()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in ((Component)this).transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			if ((Object)(object)SceneInstance?.LegacyAnimation != (Object)null)
			{
				Object.Destroy((Object)(object)SceneInstance.LegacyAnimation);
			}
			SceneInstance = null;
		}
	}
	public abstract class GltfAssetBase : MonoBehaviour
	{
		[SerializeField]
		private ImportSettings importSettings;

		public ImportSettings ImportSettings
		{
			get
			{
				return importSettings;
			}
			set
			{
				importSettings = value;
			}
		}

		public GltfImport Importer { get; protected set; }

		public bool IsDone
		{
			get
			{
				if (Importer != null)
				{
					return Importer.LoadingDone;
				}
				return false;
			}
		}

		public int? CurrentSceneId { get; protected set; }

		public int SceneCount => Importer?.SceneCount ?? 0;

		public string[] SceneNames
		{
			get
			{
				if (Importer != null && Importer.SceneCount > 0)
				{
					string[] array = new string[Importer.SceneCount];
					for (int i = 0; i < array.Length; i++)
					{
						array[i] = Importer.GetSceneName(i);
					}
					return array;
				}
				return null;
			}
		}

		public virtual async Task<bool> Load(string gltfUrl, IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
		{
			Importer = new GltfImport(downloadProvider, deferAgent, materialGenerator, logger);
			return await Importer.Load(gltfUrl, importSettings);
		}

		public async Task<bool> Instantiate(ICodeLogger logger = null)
		{
			if (Importer == null)
			{
				return false;
			}
			IInstantiator instantiator = GetDefaultInstantiator(logger);
			bool flag = await Importer.InstantiateMainSceneAsync(instantiator);
			PostInstantiation(instantiator, flag);
			return flag;
		}

		public virtual async Task<bool> InstantiateScene(int sceneIndex, ICodeLogger logger = null)
		{
			if (Importer == null)
			{
				return false;
			}
			IInstantiator instantiator = GetDefaultInstantiator(logger);
			bool flag = await Importer.InstantiateSceneAsync(instantiator, sceneIndex);
			PostInstantiation(instantiator, flag);
			return flag;
		}

		protected async Task<bool> InstantiateScene(int sceneIndex, GameObjectInstantiator instantiator)
		{
			if (Importer == null)
			{
				return false;
			}
			bool flag = await Importer.InstantiateSceneAsync((IInstantiator)instantiator, sceneIndex, default(CancellationToken));
			PostInstantiation(instantiator, flag);
			return flag;
		}

		public abstract void ClearScenes();

		public Material GetMaterial(int index = 0)
		{
			return Importer?.GetMaterial(index);
		}

		protected abstract IInstantiator GetDefaultInstantiator(ICodeLogger logger);

		protected virtual void PostInstantiation(IInstantiator instantiator, bool success)
		{
			CurrentSceneId = (success ? Importer.DefaultSceneIndex : null);
		}

		public void Dispose()
		{
			if (Importer != null)
			{
				Importer.Dispose();
				Importer = null;
			}
		}

		protected virtual void OnDestroy()
		{
			Dispose();
		}
	}
	public class GltfBoundsAsset : GltfAsset
	{
		[SerializeField]
		[Tooltip("If true, a box collider encapsulating the glTF asset is created")]
		private bool createBoxCollider = true;

		public bool CreateBoxCollider
		{
			get
			{
				return createBoxCollider;
			}
			set
			{
				createBoxCollider = value;
			}
		}

		public Bounds Bounds { get; private set; }

		public override async Task<bool> Load(string gltfUrl, IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
		{
			base.Importer = new GltfImport(downloadProvider, deferAgent, materialGenerator, logger);
			bool flag = await base.Importer.Load(gltfUrl);
			if (flag)
			{
				GameObjectBoundsInstantiator instantiator = (GameObjectBoundsInstantiator)GetDefaultInstantiator(logger);
				if (base.SceneId >= 0)
				{
					flag = await base.Importer.InstantiateSceneAsync((IInstantiator)instantiator, base.SceneId, default(CancellationToken));
					base.CurrentSceneId = (flag ? new int?(base.SceneId) : null);
				}
				else
				{
					flag = await base.Importer.InstantiateMainSceneAsync((IInstantiator)instantiator, default(CancellationToken));
					base.CurrentSceneId = base.Importer.DefaultSceneIndex;
				}
				base.SceneInstance = instantiator.SceneInstance;
				if (flag)
				{
					SetBounds(instantiator);
				}
			}
			return flag;
		}

		public override async Task<bool> InstantiateScene(int sceneIndex, ICodeLogger logger = null)
		{
			GameObjectBoundsInstantiator instantiator = (GameObjectBoundsInstantiator)GetDefaultInstantiator(logger);
			bool flag = await InstantiateScene(sceneIndex, instantiator);
			base.CurrentSceneId = (flag ? new int?(sceneIndex) : null);
			base.SceneInstance = instantiator.SceneInstance;
			if (flag)
			{
				SetBounds(instantiator);
			}
			return flag;
		}

		protected override IInstantiator GetDefaultInstantiator(ICodeLogger logger)
		{
			return new GameObjectBoundsInstantiator(base.Importer, ((Component)this).transform, logger, base.InstantiationSettings);
		}

		private void SetBounds(GameObjectBoundsInstantiator instantiator)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Bounds? val = ((instantiator.SceneInstance != null) ? instantiator.CalculateBounds() : null);
			if (val.HasValue)
			{
				Bounds = val.Value;
				if (createBoxCollider)
				{
					BoxCollider obj = ((Component)this).gameObject.AddComponent<BoxCollider>();
					Bounds bounds = Bounds;
					obj.center = ((Bounds)(ref bounds)).center;
					bounds = Bounds;
					obj.size = ((Bounds)(ref bounds)).size;
				}
			}
		}
	}
	internal enum ImageFormat
	{
		Unknown,
		PNG,
		Jpeg,
		Ktx
	}
	internal enum ChunkFormat : uint
	{
		Json = 1313821514u,
		Binary = 5130562u
	}
	public static class GltfGlobals
	{
		public const string GlbExt = ".glb";

		public const string GltfExt = ".gltf";

		public const string GltfPackageName = "com.unity.cloud.gltfast";

		public const uint GltfBinaryMagic = 1179937895u;

		public static bool IsGltfBinary(byte[] data)
		{
			return BitConverter.ToUInt32(data, 0) == 1179937895;
		}
	}
	public class GltfImport : GltfImportBase<GLTFast.Schema.Root>
	{
		private static GltfJsonUtilityParser s_Parser;

		public GltfImport(IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
			: base(downloadProvider, deferAgent, materialGenerator, logger)
		{
		}

		protected override RootBase ParseJson(string json)
		{
			if (s_Parser == null)
			{
				s_Parser = new GltfJsonUtilityParser();
			}
			return s_Parser.ParseJson(json);
		}
	}
	public abstract class GltfImportBase<TRoot> : GltfImportBase, IGltfReadable<TRoot>, IGltfReadable, IMaterialProvider, IMaterialsVariantsProvider where TRoot : RootBase
	{
		private TRoot m_Root;

		protected override RootBase Root
		{
			get
			{
				return m_Root;
			}
			set
			{
				m_Root = (TRoot)value;
			}
		}

		public GltfImportBase(IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
			: base(downloadProvider, deferAgent, materialGenerator, logger)
		{
		}

		public TRoot GetSourceRoot()
		{
			return m_Root;
		}
	}
	public abstract class GltfImportBase : IGltfReadable, IMaterialProvider, IMaterialsVariantsProvider, IGltfBuffers, IDisposable
	{
		private struct KtxTranscodeTaskWrapper
		{
			public int index;

			public TextureResult result;
		}

		[CompilerGenerated]
		private sealed class <GetMeshes>d__106 : IEnumerable<Mesh>, IEnumerable, IEnumerator<Mesh>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private Mesh <>2__current;

			private int <>l__initialThreadId;

			public GltfImportBase <>4__this;

			private int meshIndex;

			public int <>3__meshIndex;

			private IEnumerator<MeshAssignment> <>7__wrap1;

			Mesh IEnumerator<Mesh>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetMeshes>d__106(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					int num = <>1__state;
					GltfImportBase gltfImportBase = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>7__wrap1 = gltfImportBase.m_MeshAssignments.Values(meshIndex).GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						break;
					}
					if (<>7__wrap1.MoveNext())
					{
						<>2__current = <>7__wrap1.Current.mesh;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>7__wrap1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap1 != null)
				{
					<>7__wrap1.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<Mesh> IEnumerable<Mesh>.GetEnumerator()
			{
				<GetMeshes>d__106 <GetMeshes>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<GetMeshes>d__ = this;
				}
				else
				{
					<GetMeshes>d__ = new <GetMeshes>d__106(0)
					{
						<>4__this = <>4__this
					};
				}
				<GetMeshes>d__.meshIndex = <>3__meshIndex;
				return <GetMeshes>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<Mesh>)this).GetEnumerator();
			}
		}

		internal const int DefaultBatchCount = 512;

		private const int k_JsonParseSpeed = 80000000;

		private const int k_Base64DecodeSpeed = 150000000;

		private const string k_PrimitiveName = "Primitive";

		private static readonly HashSet<string> k_SupportedExtensions = new HashSet<string>
		{
			"KHR_draco_mesh_compression", "KHR_texture_basisu", "EXT_meshopt_compression", "KHR_materials_pbrSpecularGlossiness", "KHR_materials_unlit", "KHR_materials_variants", "KHR_texture_transform", "KHR_mesh_quantization", "KHR_materials_transmission", "EXT_mesh_gpu_instancing",
			"KHR_lights_punctual", "KHR_materials_clearcoat"
		};

		private static IDeferAgent s_DefaultDeferAgent;

		private static MeshComparer s_MeshComparer = new MeshComparer();

		private IDownloadProvider m_DownloadProvider;

		private IMaterialGenerator m_MaterialGenerator;

		private Dictionary<Type, ImportAddonInstance> m_ImportInstances;

		private ImportSettings m_Settings;

		private byte[][] m_Buffers;

		private GCHandle?[] m_BufferHandles;

		private NativeArray<byte>[] m_NativeBuffers;

		private GlbBinChunk[] m_BinChunks;

		private Dictionary<int, Task<IDownload>> m_DownloadTasks;

		private Dictionary<int, Task<IDownload>> m_KtxDownloadTasks;

		private Dictionary<int, TextureDownloadBase> m_TextureDownloadTasks;

		private IDisposable[] m_AccessorData;

		private AccessorUsage[] m_AccessorUsage;

		private JobHandle m_AccessorJobsHandle;

		private List<MeshOrder> m_MeshOrders;

		private List<ImageCreateContext> m_ImageCreateContexts;

		private List<KtxLoadContextBase> m_KtxLoadContextsBuffer;

		private Texture2D[] m_Images;

		private Texture2D[] m_Textures;

		private HashSet<int> m_NonFlippedYTextureIndices;

		private ImageFormat[] m_ImageFormats;

		private bool[] m_ImageReadable;

		private bool[] m_ImageGamma;

		private GlbBinChunk? m_GlbBinChunk;

		private Dictionary<int, NativeArray<byte>> m_MeshoptBufferViews;

		private NativeArray<int> m_MeshoptReturnValues;

		private JobHandle m_MeshoptJobHandle;

		private HashSet<int> m_MaterialPointsSupport;

		private bool m_DefaultMaterialPointsSupport;

		private Material[] m_Materials;

		private List<Object> m_Resources;

		private string[] m_NodeNames;

		private List<Mesh> m_Meshes;

		private FlatArray<MeshAssignment> m_MeshAssignments;

		private Matrix4x4[][] m_SkinsInverseBindMatrices;

		private AnimationClip[] m_AnimationClips;

		public ICodeLogger Logger { get; }

		public IDeferAgent DeferAgent { get; }

		protected abstract RootBase Root { get; set; }

		public bool LoadingDone { get; private set; }

		public bool LoadingError { get; private set; }

		public int MaterialCount
		{
			get
			{
				Material[] materials = m_Materials;
				if (materials == null)
				{
					return 0;
				}
				return materials.Length;
			}
		}

		public int ImageCount
		{
			get
			{
				Texture2D[] images = m_Images;
				if (images == null)
				{
					return 0;
				}
				return images.Length;
			}
		}

		public int TextureCount
		{
			get
			{
				Texture2D[] textures = m_Textures;
				if (textures == null)
				{
					return 0;
				}
				return textures.Length;
			}
		}

		public int? DefaultSceneIndex
		{
			get
			{
				if (Root == null || Root.scene < 0)
				{
					return null;
				}
				return Root.scene;
			}
		}

		public int SceneCount => (Root?.Scenes?.Count).GetValueOrDefault();

		public IReadOnlyCollection<Mesh> Meshes => m_Meshes;

		public int MaterialsVariantsCount => Root.MaterialsVariantsCount;

		public event Action LoadAccessorDataEvent;

		public event Action<int, int, int[]> MeshResultAssigned;

		public GltfImportBase(IDownloadProvider downloadProvider = null, IDeferAgent deferAgent = null, IMaterialGenerator materialGenerator = null, ICodeLogger logger = null)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			m_DownloadProvider = downloadProvider ?? new DefaultDownloadProvider();
			if (deferAgent == null)
			{
				if (s_DefaultDeferAgent != null)
				{
					IDeferAgent deferAgent2 = s_DefaultDeferAgent;
					Object val = (Object)((deferAgent2 is Object) ? deferAgent2 : null);
					if (val == null || !(val == (Object)null))
					{
						goto IL_0058;
					}
				}
				GameObject val2 = new GameObject("glTF-StableFramerate");
				Object.DontDestroyOnLoad((Object)val2);
				SetDefaultDeferAgent(val2.AddComponent<TimeBudgetPerFrameDeferAgent>());
				val2.AddComponent<DefaultDeferAgent>();
				goto IL_0058;
			}
			DeferAgent = deferAgent;
			goto IL_006c;
			IL_0058:
			DeferAgent = s_DefaultDeferAgent;
			goto IL_006c;
			IL_006c:
			m_MaterialGenerator = materialGenerator ?? MaterialGenerator.GetDefaultMaterialGenerator();
			Logger = logger;
			ImportAddonRegistry.InjectAllAddons(this);
		}

		public static void SetDefaultDeferAgent(IDeferAgent deferAgent)
		{
			s_DefaultDeferAgent = deferAgent;
		}

		public static void UnsetDefaultDeferAgent(IDeferAgent deferAgent)
		{
			if (s_DefaultDeferAgent == deferAgent)
			{
				s_DefaultDeferAgent = null;
			}
		}

		public void AddImportAddonInstance<T>(T importInstance) where T : ImportAddonInstance
		{
			if (m_ImportInstances == null)
			{
				m_ImportInstances = new Dictionary<Type, ImportAddonInstance>();
			}
			m_ImportInstances[typeof(T)] = importInstance;
		}

		public T GetImportAddonInstance<T>() where T : ImportAddonInstance
		{
			if (m_ImportInstances == null)
			{
				return null;
			}
			if (m_ImportInstances.TryGetValue(typeof(T), out var value))
			{
				return (T)value;
			}
			return null;
		}

		public async Task<bool> Load(string url, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			return await Load(new Uri(url, UriKind.RelativeOrAbsolute), importSettings, cancellationToken);
		}

		public async Task<bool> Load(Uri url, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			m_Settings = importSettings ?? new ImportSettings();
			return await LoadFromUri(url, cancellationToken);
		}

		public async Task<bool> Load(byte[] data, Uri uri = null, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (GltfGlobals.IsGltfBinary(data))
			{
				return await LoadGltfBinary(data, uri, importSettings, cancellationToken);
			}
			string @string = Encoding.UTF8.GetString(data, 0, data.Length);
			return await LoadGltfJson(@string, uri, importSettings, cancellationToken);
		}

		public async Task<bool> LoadFile(string localPath, Uri uri = null, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			FileStream fs = new FileStream(localPath, FileMode.Open, FileAccess.Read);
			bool result;
			try
			{
				bool flag = await LoadStream(fs, uri, importSettings, cancellationToken);
				fs.Dispose();
				result = flag;
			}
			finally
			{
				if (fs != null)
				{
					await fs.DisposeAsync();
				}
			}
			return result;
		}

		public async Task<bool> LoadStream(Stream stream, Uri uri = null, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (!stream.CanRead)
			{
				Logger?.Error(LogCode.StreamError, "Not readable");
				return false;
			}
			long initialStreamPosition = (stream.CanSeek ? stream.Position : (-1));
			byte[] firstBytes = new byte[4];
			if (!(await stream.ReadToArrayAsync(firstBytes, 0, firstBytes.Length, cancellationToken)))
			{
				Logger?.Error(LogCode.StreamError, "First bytes");
				return false;
			}
			if (cancellationToken.IsCancellationRequested)
			{
				return false;
			}
			if (GltfGlobals.IsGltfBinary(firstBytes))
			{
				byte[] glbHeader = new byte[8];
				if (!(await stream.ReadToArrayAsync(glbHeader, 0, glbHeader.Length, cancellationToken)))
				{
					Logger?.Error(LogCode.StreamError, "glb header");
					return false;
				}
				uint num = BitConverter.ToUInt32(glbHeader, 4);
				if (num >= int.MaxValue)
				{
					Logger?.Error("glb exceeds 2GB limit.");
					return false;
				}
				byte[] data = new byte[num];
				Array.Copy(firstBytes, data, firstBytes.Length);
				Array.Copy(glbHeader, 0, data, firstBytes.Length, glbHeader.Length);
				int num2 = firstBytes.Length + glbHeader.Length;
				int length = (int)num - num2;
				if (!(await stream.ReadToArrayAsync(data, num2, length, cancellationToken)))
				{
					Logger?.Error(LogCode.StreamError, "glb data");
				}
				return await LoadGltfBinary(data, uri, importSettings, cancellationToken);
			}
			StreamReader reader = new StreamReader(stream);
			string json;
			if (stream.CanSeek)
			{
				stream.Seek(initialStreamPosition, SeekOrigin.Begin);
				json = await reader.ReadToEndAsync();
			}
			else
			{
				string @string = Encoding.UTF8.GetString(firstBytes);
				json = @string + await reader.ReadToEndAsync();
			}
			reader.Dispose();
			bool flag = !cancellationToken.IsCancellationRequested;
			if (flag)
			{
				flag = await LoadGltfJson(json, uri, importSettings, cancellationToken);
			}
			return flag;
		}

		public async Task<bool> LoadGltfBinary(byte[] bytes, Uri uri = null, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			m_Settings = importSettings ?? new ImportSettings();
			bool success2 = await LoadGltfBinaryBuffer(bytes, uri);
			if (success2)
			{
				await LoadContent();
			}
			bool flag = success2;
			if (flag)
			{
				flag = await Prepare();
			}
			success2 = flag;
			DisposeVolatileData();
			LoadingError = !success2;
			LoadingDone = true;
			return success2;
		}

		public async Task<bool> LoadGltfJson(string json, Uri uri = null, ImportSettings importSettings = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			m_Settings = importSettings ?? new ImportSettings();
			bool success2 = await LoadGltf(json, uri);
			if (success2)
			{
				await LoadContent();
			}
			bool flag = success2;
			if (flag)
			{
				flag = await Prepare();
			}
			success2 = flag;
			DisposeVolatileData();
			LoadingError = !success2;
			LoadingDone = true;
			return success2;
		}

		[Obsolete("Use InstantiateMainSceneAsync for increased performance and safety. Consult the Upgrade Guide for instructions.")]
		public bool InstantiateMainScene(Transform parent)
		{
			return InstantiateMainSceneAsync(parent).Result;
		}

		[Obsolete("Use InstantiateMainSceneAsync for increased performance and safety. Consult the Upgrade Guide for instructions.")]
		public bool InstantiateMainScene(IInstantiator instantiator)
		{
			return InstantiateMainSceneAsync(instantiator).Result;
		}

		[Obsolete("Use InstantiateSceneAsync for increased performance and safety. Consult the Upgrade Guide for instructions.")]
		public bool InstantiateScene(Transform parent, int sceneIndex = 0)
		{
			return InstantiateSceneAsync(parent, sceneIndex).Result;
		}

		[Obsolete("Use InstantiateSceneAsync for increased performance and safety. Consult the Upgrade Guide for instructions.")]
		public bool InstantiateScene(IInstantiator instantiator, int sceneIndex = 0)
		{
			return InstantiateSceneAsync(instantiator, sceneIndex).Result;
		}

		public async Task<bool> InstantiateMainSceneAsync(Transform parent, CancellationToken cancellationToken = default(CancellationToken))
		{
			GameObjectInstantiator instantiator = new GameObjectInstantiator(this, parent);
			return await InstantiateMainSceneAsync((IInstantiator)instantiator, cancellationToken);
		}

		public async Task<bool> InstantiateMainSceneAsync(IInstantiator instantiator, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (!LoadingDone || LoadingError)
			{
				return false;
			}
			if (Root.scene < 0)
			{
				return true;
			}
			return await InstantiateSceneAsync(instantiator, Root.scene, cancellationToken);
		}

		public async Task<bool> InstantiateSceneAsync(Transform parent, int sceneIndex = 0, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (!LoadingDone || LoadingError)
			{
				return false;
			}
			if (sceneIndex < 0 || sceneIndex > Root.Scenes.Count)
			{
				return false;
			}
			GameObjectInstantiator instantiator = new GameObjectInstantiator(this, parent);
			return await InstantiateSceneAsync((IInstantiator)instantiator, sceneIndex, cancellationToken);
		}

		public async Task<bool> InstantiateSceneAsync(IInstantiator instantiator, int sceneIndex = 0, CancellationToken cancellationToken = default(CancellationToken))
		{
			if (!LoadingDone || LoadingError)
			{
				return false;
			}
			if (sceneIndex < 0 || sceneIndex > Root.Scenes.Count)
			{
				return false;
			}
			await InstantiateSceneInternal(instantiator, sceneIndex);
			return true;
		}

		public void Dispose()
		{
			if (m_ImportInstances != null)
			{
				foreach (KeyValuePair<Type, ImportAddonInstance> importInstance in m_ImportInstances)
				{
					importInstance.Value.Dispose();
				}
				m_ImportInstances = null;
			}
			m_NodeNames = null;
			DisposeArray((IEnumerable<Object>)(object)m_Materials);
			m_Materials = null;
			DisposeArray((IEnumerable<Object>)(object)m_AnimationClips);
			m_AnimationClips = null;
			DisposeArray((IEnumerable<Object>)(object)m_Textures);
			m_Textures = null;
			if (m_AccessorData != null)
			{
				IDisposable[] accessorData = m_AccessorData;
				for (int i = 0; i < accessorData.Length; i++)
				{
					accessorData[i]?.Dispose();
				}
				m_AccessorData = null;
			}
			m_MeshAssignments = null;
			DisposeArray((IEnumerable<Object>)m_Meshes);
			m_Meshes = null;
			DisposeArray(m_Resources);
			m_Resources = null;
			static void DisposeArray(IEnumerable<Object> objects)
			{
				if (objects != null)
				{
					foreach (Object @object in objects)
					{
						SafeDestroy(@object);
					}
				}
			}
		}

		public string GetSceneName(int sceneIndex)
		{
			return Root?.Scenes?[sceneIndex]?.name;
		}

		public Material GetMaterial(int index = 0)
		{
			if (m_Materials != null && index >= 0 && index < m_Materials.Length)
			{
				return m_Materials[index];
			}
			return null;
		}

		public async Task<Material> GetMaterialAsync(int index)
		{
			return await GetMaterialAsync(index, default(CancellationToken));
		}

		public Task<Material> GetMaterialAsync(int index, CancellationToken cancellationToken)
		{
			return Task.FromResult<Material>(GetMaterial(index));
		}

		public Material GetDefaultMaterial()
		{
			m_MaterialGenerator.SetLogger(Logger);
			Material defaultMaterial = m_MaterialGenerator.GetDefaultMaterial(m_DefaultMaterialPointsSupport);
			m_MaterialGenerator.SetLogger(null);
			return defaultMaterial;
		}

		public async Task<Material> GetDefaultMaterialAsync()
		{
			return await GetDefaultMaterialAsync(default(CancellationToken));
		}

		public Task<Material> GetDefaultMaterialAsync(CancellationToken cancellationToken)
		{
			return Task.FromResult<Material>(GetDefaultMaterial());
		}

		public Texture2D GetImage(int index = 0)
		{
			if (m_Images != null && index >= 0 && index < m_Images.Length)
			{
				return m_Images[index];
			}
			return null;
		}

		public Texture2D GetTexture(int index = 0)
		{
			if (m_Textures != null && index >= 0 && index < m_Textures.Length)
			{
				return m_Textures[index];
			}
			return null;
		}

		public bool IsTextureYFlipped(int index = 0)
		{
			if (m_NonFlippedYTextureIndices == null || !m_NonFlippedYTextureIndices.Contains(index))
			{
				return GetSourceTexture(index).IsKtx;
			}
			return false;
		}

		public AnimationClip[] GetAnimationClips()
		{
			return m_AnimationClips;
		}

		[Obsolete("Use Meshes instead.")]
		public Mesh[] GetMeshes()
		{
			if (m_Meshes == null || m_Meshes.Count < 1)
			{
				return Array.Empty<Mesh>();
			}
			return m_Meshes.ToArray();
		}

		public int GetMeshCount(int meshIndex)
		{
			return m_MeshAssignments.GetLength(meshIndex);
		}

		[IteratorStateMachine(typeof(<GetMeshes>d__106))]
		public IEnumerable<Mesh> GetMeshes(int meshIndex)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetMeshes>d__106(-2)
			{
				<>4__this = this,
				<>3__meshIndex = meshIndex
			};
		}

		public Mesh GetMesh(int meshIndex, int meshNumeration)
		{
			return m_MeshAssignments.GetValue(meshIndex, meshNumeration).mesh;
		}

		public CameraBase GetSourceCamera(uint index)
		{
			if (Root?.Cameras != null && index < Root.Cameras.Count)
			{
				return Root.Cameras[(int)index];
			}
			return null;
		}

		public LightPunctual GetSourceLightPunctual(uint index)
		{
			if (Root?.Extensions?.KHR_lights_punctual.lights != null && index < Root.Extensions.KHR_lights_punctual.lights.Length)
			{
				return Root.Extensions.KHR_lights_punctual.lights[index];
			}
			return null;
		}

		public GLTFast.Schema.Scene GetSourceScene(int index = 0)
		{
			if (Root?.Scenes != null && index >= 0 && index < Root.Scenes.Count)
			{
				return Root.Scenes[index];
			}
			return null;
		}

		public MaterialBase GetSourceMaterial(int index = 0)
		{
			if (Root?.Materials != null && index >= 0 && index < Root.Materials.Count)
			{
				return Root.Materials[index];
			}
			return null;
		}

		public MeshBase GetSourceMesh(int meshIndex)
		{
			if (Root?.Meshes != null && meshIndex >= 0 && meshIndex < Root.Meshes.Count)
			{
				return Root.Meshes[meshIndex];
			}
			return null;
		}

		public MeshPrimitiveBase GetSourceMeshPrimitive(int meshIndex, int primitiveIndex)
		{
			if (Root?.Meshes != null && meshIndex >= 0 && meshIndex < Root.Meshes.Count)
			{
				MeshBase meshBase = Root.Meshes[meshIndex];
				if (meshBase?.Primitives != null && primitiveIndex >= 0 && primitiveIndex < meshBase.Primitives.Count)
				{
					return meshBase.Primitives[primitiveIndex];
				}
			}
			return null;
		}

		public IMaterialsVariantsSlot[] GetMaterialsVariantsSlots(int meshIndex, int meshNumeration)
		{
			List<IMaterialsVariantsSlot> list = null;
			int[] primitives = m_MeshAssignments.GetValue(meshIndex, meshNumeration).primitives;
			foreach (int primitiveIndex in primitives)
			{
				MeshPrimitiveBase sourceMeshPrimitive = GetSourceMeshPrimitive(meshIndex, primitiveIndex);
				if (sourceMeshPrimitive.Extensions?.KHR_materials_variants?.mappings != null)
				{
					if (list == null)
					{
						list = new List<IMaterialsVariantsSlot>();
					}
					list.Add(sourceMeshPrimitive);
				}
			}
			return list?.ToArray();
		}

		public NodeBase GetSourceNode(int index = 0)
		{
			if (Root?.Nodes != null && index >= 0 && index < Root.Nodes.Count)
			{
				return Root.Nodes[index];
			}
			return null;
		}

		public GLTFast.Schema.TextureBase GetSourceTexture(int index = 0)
		{
			if (Root?.Textures != null && index >= 0 && index < Root.Textures.Count)
			{
				return Root.Textures[index];
			}
			return null;
		}

		public GLTFast.Schema.Image GetSourceImage(int index = 0)
		{
			if (Root?.Images != null && index >= 0 && index < Root.Images.Count)
			{
				return Root.Images[index];
			}
			return null;
		}

		public Matrix4x4[] GetBindPoses(int skinId)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (m_SkinsInverseBindMatrices == null)
			{
				return null;
			}
			if (m_SkinsInverseBindMatrices[skinId] != null)
			{
				return m_SkinsInverseBindMatrices[skinId];
			}
			Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[Root.Skins[skinId].joints.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Matrix4x4.identity;
			}
			m_SkinsInverseBindMatrices[skinId] = array;
			return array;
		}

		[Obsolete("Use GetAccessorData instead.")]
		public NativeSlice<byte> GetAccessor(int accessorIndex)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return GetAccessorData(accessorIndex);
	

plugins/Unity.Collections.LowLevel.ILSupport.dll

Decompiled a month ago
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("Unity.Collections")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[CompilerGenerated]
[EditorBrowsable(EditorBrowsableState.Never)]
[GeneratedCode("Unity.MonoScriptGenerator.MonoScriptInfoGenerator", null)]
internal class UnitySourceGeneratedAssemblyMonoScriptTypes_v1
{
	private struct MonoScriptData
	{
		public byte[] FilePathsData;

		public byte[] TypesData;

		public int TotalTypes;

		public int TotalFiles;

		public bool IsEditorOnly;
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	private static MonoScriptData Get()
	{
		MonoScriptData result = default(MonoScriptData);
		result.FilePathsData = new byte[144]
		{
			0, 0, 0, 1, 0, 0, 0, 136, 67, 58,
			92, 100, 101, 118, 92, 100, 111, 116, 115, 92,
			80, 97, 99, 107, 97, 103, 101, 115, 92, 99,
			111, 109, 46, 117, 110, 105, 116, 121, 46, 99,
			111, 108, 108, 101, 99, 116, 105, 111, 110, 115,
			92, 85, 110, 105, 116, 121, 46, 67, 111, 108,
			108, 101, 99, 116, 105, 111, 110, 115, 46, 76,
			111, 119, 76, 101, 118, 101, 108, 46, 73, 76,
			83, 117, 112, 112, 111, 114, 116, 92, 115, 111,
			117, 114, 99, 101, 92, 85, 110, 105, 116, 121,
			46, 67, 111, 108, 108, 101, 99, 116, 105, 111,
			110, 115, 46, 76, 111, 119, 76, 101, 118, 101,
			108, 46, 73, 76, 83, 117, 112, 112, 111, 114,
			116, 92, 73, 76, 83, 117, 112, 112, 111, 114,
			116, 46, 99, 115
		};
		result.TypesData = new byte[48]
		{
			0, 0, 0, 0, 43, 85, 110, 105, 116, 121,
			46, 67, 111, 108, 108, 101, 99, 116, 105, 111,
			110, 115, 46, 76, 111, 119, 76, 101, 118, 101,
			108, 46, 85, 110, 115, 97, 102, 101, 124, 73,
			76, 83, 117, 112, 112, 111, 114, 116
		};
		result.TotalFiles = 1;
		result.TotalTypes = 1;
		result.IsEditorOnly = false;
		return result;
	}
}
namespace Unity.Collections.LowLevel.Unsafe;

internal static class ILSupport
{
	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public unsafe static void* AddressOf<T>(in T thing) where T : struct
	{
		return System.Runtime.CompilerServices.Unsafe.AsPointer(ref thing);
	}

	[MethodImpl(MethodImplOptions.AggressiveInlining)]
	public static ref T AsRef<T>(in T thing) where T : struct
	{
		return ref thing;
	}
}