Static loader that selects a donor rig importer based on file extension and returns a DonorRig. It supports .glb/.gltf via GltfDonorImporter and .fbx via FbxDonorImporter, and throws FormatException for others.
using AutoRig.Formats.Gltf;
using AutoRig.Rig;
namespace AutoRig.Formats;
/// <summary>
/// Loads a rigged model to act as a transfer donor. glTF/GLB today; other rigged
/// formats can join behind the same facade.
/// </summary>
public static class DonorLoader
{
/// <exception cref="FormatException">Unsupported format or unrigged file.</exception>
public static DonorRig Load( byte[] data, string fileName )
{
ArgumentNullException.ThrowIfNull( data );
ArgumentNullException.ThrowIfNull( fileName );
var extension = Path.GetExtension( fileName ).ToLowerInvariant();
return extension switch
{
".glb" or ".gltf" => GltfDonorImporter.Import( data, fileName ),
".fbx" => Fbx.FbxDonorImporter.Import( data, fileName ),
_ => throw new FormatException(
$"'{fileName}': donors must be rigged glTF/GLB or FBX files; "
+ $"'{extension}' is not supported yet." ),
};
}
}