use the code below to make a slm model importer c# script for unity for instance a path for where the file is and render the model when finished aka instantiate it show it set it up all that jazz

using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq; // used for Sum of array

using Unity.Jobs;
using Unity.Mathematics;
using Unity.Collections;
using UnityEngine;

using OpenMetaverse;
using static OpenMetaverse.Primitive;

#if useHDRP
using UnityEngine.Rendering.HighDefinition;
#endif

using CrystalFrost;
using static CrystalFrost.CFAssetManager;
using CrystalFrost.Assets;
using CrystalFrost.Assets.Textures;
using CrystalFrost.Assets.Mesh;
using CrystalFrost.Config;
using CrystalFrost.Extensions;
using CrystalFrost.Lib;
using CrystalFrost.Logging;
using CrystalFrost.UnityRendering;
using CrystalFrost.WorldState;
using CrystalFrost.ObjectPooling;
using Unity.VisualScripting;
using OpenMetaverse.Assets;

#if USE_KWS
using KWS;
using static KWS.WaterSystem;
#endif

#if USE_FUNLY_SKY
using Funly.SkyStudio;
#endif

public class SLMFileReader : MonoBehaviour
{
	[Header("SLM Renderer Settings")]
	[Tooltip("Path to the .SLM file to load.")]
	public string filePath;

	[Tooltip("Material to apply to decoded meshes.")]
	public UnityEngine.Material defaultMaterial;

	[SerializeField]
	private bool isSkinnedMesh = false;

	private DecodedMesh decodedMesh;

	void Start()
	{
		if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
		{
			Debug.LogError($"[SLMFileReader] File not found: {filePath}");
			return;
		}

		LoadSLMMesh(filePath);

		if (decodedMesh != null)
		{
			if (isSkinnedMesh)
				RenderSkinnedMesh();
			else
				RenderStaticMeshes();
		}
	}

	private void LoadSLMMesh(string path)
	{
		Debug.Log($"[SLMFileReader] Loading SLM Mesh from: {path}");

		// Read mesh binary data from the file
		byte[] data = File.ReadAllBytes(path);

		if (data == null || data.Length == 0)
		{
			Debug.LogError("[SLMFileReader] Failed to read the SLM mesh data.");
			return;
		}

		// Create a dummy primitive
		var primitive = new Primitive
		{
			ID = UUID.Random(), // Assign a random UUID to this mesh primitive
			Scale = new OpenMetaverse.Vector3(1, 1, 1)
		};

		AssetMesh meshAsset = new AssetMesh(primitive.ID, data);

		// Decode the mesh
		var meshRequest = new MeshRequest
		{
			UUID = primitive.ID,
			AssetMesh = meshAsset,
			Primitive = primitive
		};

		var readyMeshQueue = new DecodedMeshQueue(); // A simple mesh queue
		var decoder = new MeshDecoder(readyMeshQueue); // Simulates decoding

		Debug.Log("[SLMFileReader] Decoding mesh...");
		decoder.Decode(meshRequest);

		if (readyMeshQueue.TryDequeue(out var request) && request?.DecodedMesh != null)
		{
			decodedMesh = request.DecodedMesh;
			Debug.Log($"[SLMFileReader] Successfully decoded SLM mesh: {primitive.ID}");
		}
		else
		{
			Debug.LogError("[SLMFileReader] Decoding the SLM mesh failed.");
		}
	}

	private void RenderStaticMeshes()
	{
		if (decodedMesh.meshData == null || decodedMesh.meshData.Count == 0)
		{
			Debug.LogError("[SLMFileReader] Mesh data is empty.");
			return;
		}

		// Iterate over all decoded mesh data
		foreach (var rawMeshData in decodedMesh.meshData)
		{
			GameObject meshObject = new GameObject($"SLM_Mesh_{rawMeshData.GetHashCode()}");
			meshObject.transform.SetParent(transform, false);

			// Create Unity mesh
			var unityMesh = rawMeshData.ToUnityMesh();

			var meshFilter = meshObject.AddComponent<MeshFilter>();
			var meshRenderer = meshObject.AddComponent<MeshRenderer>();
			meshRenderer.material = defaultMaterial ?? new UnityEngine.Material(Shader.Find("Standard"));

			meshFilter.mesh = unityMesh;

			Debug.Log($"[SLMFileReader] Static mesh rendered: {meshObject.name}");
		}
	}

	private void RenderSkinnedMesh()
	{
		if (decodedMesh.meshData == null || decodedMesh.meshData.Count == 0)
		{
			Debug.LogError("[SLMFileReader] Decoded mesh data is empty. Cannot render skinned mesh.");
			return;
		}

		// Assume we are working with an indexed mesh
		GameObject skinnedObject = new GameObject("SLM_SkinnedMesh");
		skinnedObject.transform.SetParent(transform, false);

		var skinnedMeshRenderer = skinnedObject.AddComponent<SkinnedMeshRenderer>();

		// Convert raw data to Unity `Mesh`
		var skinnedMesh = decodedMesh.meshData[0].ToUnityMesh(); // First mesh
		skinnedMeshRenderer.sharedMesh = skinnedMesh;

		if (decodedMesh.isSkinned)
		{
			Debug.Log("[SLMFileReader] Applying bind poses for skinned mesh...");

			Matrix4x4[] bindPoses = new Matrix4x4[decodedMesh.joints.Length];
			for (int i = 0; i < decodedMesh.joints.Length; i++)
			{
				//bindPoses[i] = decodedMesh.joints[i].BindTransform.ToMatrix4x4();
			}

			skinnedMesh.bindposes = bindPoses;
		}

		skinnedMeshRenderer.material = defaultMaterial ?? new UnityEngine.Material(Shader.Find("Standard"));

		Debug.Log("[SLMFileReader] Skinned mesh rendered.");
	}
}