using Engine.Asset.Mesh.Loader;

namespace Engine.Resource.Loader;

public class MeshLoader : IResourceLoader
{
  public object Load(string parPath, IResourceStreamProvider parStreamProvider)
  {
    var extension = Path.GetExtension(parPath);
    using var reader = new StreamReader(parStreamProvider.GetStream(parPath));

    return extension switch
    {
      ".obj" => ObjMeshLoader.Load(reader),
      ".stl" => StlMeshLoader.Load(reader),
      _ => throw new InvalidOperationException($"Unsupported mesh format: {extension}")
    };
  }
}