H073.HxGLTF
2.0.0
Prefix Reserved
dotnet add package H073.HxGLTF --version 2.0.0
NuGet\Install-Package H073.HxGLTF -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="H073.HxGLTF" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="H073.HxGLTF" Version="2.0.0" />
<PackageReference Include="H073.HxGLTF" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add H073.HxGLTF --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: H073.HxGLTF, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package H073.HxGLTF@2.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=H073.HxGLTF&version=2.0.0
#tool nuget:?package=H073.HxGLTF&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
HxGLTF — High-Performance GLTF/GLB Loader for .NET
HxGLTF is a fast, memory-efficient library for loading GLTF 2.0 and GLB files into structured C# objects.
Features
- GLTF & GLB Support — Load both
.gltfand binary.glbfiles - Complete GLTF 2.0 — Scenes, nodes, meshes, materials, textures, animations, skins, cameras
- PBR Materials — Metallic-Roughness and Specular-Glossiness workflows
- Async Loading —
GLTFReader.ReadAsync()with progress and cancellation - ArrayPool Integration — Zero-allocation accessor reading
- 7 Built-in Extensions — KHR_texture_transform, KHR_materials_unlit, KHR_materials_clearcoat, KHR_materials_transmission, KHR_materials_ior, KHR_materials_pbrSpecularGlossiness, KHR_mesh_quantization
- Custom Extension System — Register your own extension handlers
Installation
dotnet add package H073.HxGLTF
<PackageReference Include="H073.HxGLTF" Version="2.0.0" />
Quick Start
using HxGLTF;
using HxGLTF.Core;
// Load a GLTF/GLB file
var gltf = GLTFReader.Read("model.glb");
// With options
var gltf = GLTFReader.Read("model.glb", new GLTFReadOptions
{
SkipAnimations = false,
SkipSkins = false,
StrictExtensionCheck = true
});
// Async loading with progress
var gltf = await GLTFReader.ReadAsync("model.glb",
progress: new Progress<GLTFLoadProgress>(p => Console.WriteLine($"{p.Stage}: {p.Percentage:F0}%")),
cancellationToken: token);
Accessing Data
// Meshes
foreach (var mesh in gltf.Meshes)
{
foreach (var prim in mesh.Primitives)
{
var positions = AccessorReader.ReadData(prim.GetAttribute("POSITION"));
if (prim.HasIndices)
{
var indices = AccessorReader.ReadIndices(prim.Indices);
}
}
}
// Materials
foreach (var mat in gltf.Materials)
{
var baseColor = mat.BaseColorFactor;
var metallic = mat.MetallicFactor;
var roughness = mat.RoughnessFactor;
var emissive = mat.EmissiveFactor;
var alphaMode = mat.AlphaMode; // "OPAQUE", "MASK", "BLEND"
}
// Animations
foreach (var anim in gltf.Animations)
{
foreach (var channel in anim.Channels)
{
var times = AccessorReader.ReadData(channel.Sampler.Input);
var values = AccessorReader.ReadData(channel.Sampler.Output);
var targetPath = channel.Target.Path; // Translation, Rotation, Scale, Weights
}
}
// Skeletons
foreach (var skin in gltf.Skins)
{
var joints = skin.Joints;
var ibm = skin.InverseBindMatrices;
}
High-Performance Reading
// Zero-allocation with pooled arrays
var (array, length) = AccessorReader.ReadDataPooled(accessor);
try
{
ProcessVertices(array.AsSpan(0, length));
}
finally
{
AccessorReader.ReturnPooledArray(array);
}
Extensions
Built-in
| Extension | Description |
|---|---|
KHR_texture_transform |
UV offset, scale, rotation on textures |
KHR_materials_unlit |
Unlit materials (no lighting) |
KHR_materials_pbrSpecularGlossiness |
Legacy Specular-Glossiness workflow |
KHR_materials_clearcoat |
Clear coat layer |
KHR_materials_transmission |
Transparent/translucent materials |
KHR_materials_ior |
Index of refraction |
KHR_mesh_quantization |
Compressed vertex data |
Custom Extensions
using HxGLTF.Core.Extensions;
public class MyExtension : GLTFExtensionBase
{
public override string ExtensionName => "MY_custom_extension";
public override ExtensionParseResult ParseMaterialExtension(
JsonElement extensionData, Material material, ExtensionParseContext context)
{
float myValue = 0f;
if (extensionData.TryGetProperty("myValue", out var prop))
myValue = prop.GetSingle();
return ExtensionParseResult.Succeeded(new { MyValue = myValue });
}
}
// Register before loading
GLTFExtensionRegistry.Register(new MyExtension());
var gltf = GLTFReader.Read("model.glb");
// Access after loading
if (mat.Extensions.TryGetValue("MY_custom_extension", out var data))
{
// data contains what ParseMaterialExtension returned
}
Available parse hooks:
ParseRootExtension— document-levelParseMaterialExtension— per-materialParsePrimitiveExtension— per-mesh-primitiveParseNodeExtension— per-nodeParseTextureExtension— per-texture
Data Structure
GLTFFile
├── Asset (version, generator, copyright)
├── Scenes[] → Nodes[]
├── Nodes[] → Children[], Mesh, Camera, Skin
├── Meshes[] → Primitives[] → Attributes, Indices, Material
├── Materials[] → Textures, PBR factors, Extensions
├── Textures[] → Image, Sampler
├── Animations[] → Channels[], Samplers[]
├── Skins[] → Joints[], InverseBindMatrices
├── Cameras[] → Perspective/Orthographic
├── Buffers[] / BufferViews[] / Accessors[]
└── ExtensionsUsed[] / ExtensionsRequired[]
Using MonoGame?
Use HxGLTF.MonoGame — loads glTF/GLB directly into a ModelKit Scene with animations, skeletons, PBR materials, and morph targets.
License
MIT
Contact
Discord: sameplayer
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on H073.HxGLTF:
| Package | Downloads |
|---|---|
|
H073.HxGLTF.MonoGame
MonoGame bridge for HxGLTF – loads glTF/GLB into ModelKit scenes. |
|
|
H073.HxGLTF.MonoGame.WindowsDX
MonoGame WindowsDX bridge for HxGLTF – loads glTF/GLB into ModelKit scenes. |
GitHub repositories
This package is not used by any popular GitHub repositories.