glTFNet.Extensions.Khronos 0.1.0-prerelease

This is a prerelease version of glTFNet.Extensions.Khronos.
dotnet add package glTFNet.Extensions.Khronos --version 0.1.0-prerelease
                    
NuGet\Install-Package glTFNet.Extensions.Khronos -Version 0.1.0-prerelease
                    
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="glTFNet.Extensions.Khronos" Version="0.1.0-prerelease" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="glTFNet.Extensions.Khronos" Version="0.1.0-prerelease" />
                    
Directory.Packages.props
<PackageReference Include="glTFNet.Extensions.Khronos" />
                    
Project file
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 glTFNet.Extensions.Khronos --version 0.1.0-prerelease
                    
#r "nuget: glTFNet.Extensions.Khronos, 0.1.0-prerelease"
                    
#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 glTFNet.Extensions.Khronos@0.1.0-prerelease
                    
#: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=glTFNet.Extensions.Khronos&version=0.1.0-prerelease&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=glTFNet.Extensions.Khronos&version=0.1.0-prerelease&prerelease
                    
Install as a Cake Tool

glTFNet

A fast and modern glTF reader.

This library can read binary and JSON-based glTF 2.0 files.

Generator

This project contains a C# code generator to convert the schema definition provided by Khronos to model classes.

Usage

This library provides a wrapper struct GltfRef<T> with extension methods for easy access to the glFT models.

var inputFile = "Examples/glTF-Binary/Avocado.glb";

// Loading the glTF data
await using var file = new GltfFile();
var gltf = await file.Open(inputFile);

if (!gltf.HasScene(out var scene)) return;

foreach (var node in scene.Nodes())
{
    if (!node.HasMesh(out var mesh)) continue;

    foreach (var meshPrimitive in mesh.Primitives())
    {
        if (!meshPrimitive.HasIndices(out var indicesAccessor)) continue;
        if (!meshPrimitive.HasAttributes("POSITION", out var positionAccessor)) continue;
        
        // Lazy-loading the data from the gbl file
        var indices = await indicesAccessor.Read();
        var positions = await positionAccessor.Read();
        
        // ...
    }
}

External resources in glTF (like textures or mesh data) are linked via an URI. A FileResolver for the parent directory is automatically added as IResourceResolver, if the GltfFile is loaded by from a filename. Custom resolvers can implement the IResourceResolver interface and overwrite the GltfFile.ResourceResolver property:

await using var file = new GltfFile();
file.ResourceResolver = new MyCustomResourceResolver();

Extensions

The glTF extension can be used by importing the additional extension packages: glTFNet.Extensions.Khronos, glTFNet.Extensions.Vendor or glTFNet.Extensions.Archived.

Make sure to register the extension in the GltfFile before using them:

await using var file = new GltfFile();

// Register the extension set
file.UseKhronosExtensions();

var gltf = await file.Open(inputFile);

Extension data cam be read with TryGetExtension:

var material = gltf.Materials()[0];

// Accessing the extension data
if (material.TryGetExtension("KHR_materials_ior", out MaterialKHRMaterialsIor extension))
{
    var ior = extension.Ior;
    
    // ...
}

When adding custom extension, make sure to create a JSON serializer context and add to the GltfFile:

// For example: Create an extension method for your extension
public static void UseMyCustomExtension(this GltfSerializer serializer)
{
    serializer.AddSerializerContext(MyCustomExtensionSerializerContext.Default);
}
// Register your extension when reading the file
await using var file = new GltfFile();
file.UseMyCustomExtension();
Product 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 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-prerelease 75 3/20/2026