API Reference · Model and texture loading

GltfLoader

Namespace: Ava3D

public static class GltfLoader

Loads glTF into an Ava3D scene in one call.

The node hierarchy is kept as a hierarchy: one Node per glTF node, carrying its own local transform, with the parents above it. That is what a CAD assembly wants — one draw call per part, identical geometry sharing a Mesh — and it is also the only shape an animation can be played over, because a clip rotates a shoulder and expects a hand to follow.

Every method here is GltfAsset.Load followed by GltfAsset.Instantiate: read the file, make one copy of it, put the copy in a scene. That is the right amount of API for a viewer with one model in it. For two copies of the same model, or a .gltf whose textures live in other files, or a file that has to come over HTTP, go to GltfAsset directly — the model that comes back from here carries it as GltfModel.Asset.

The reader is the library's own, over System.Text.Json's source generator, so a trimmed or ahead-of-time compiled application carries no reflection for it. See the From a .glb file to these types guide for what is and is not read.

Methods

MemberDescription
static Scene Load(byte[] bytes, string name = null)

Reads a .glb into a fresh scene.

static Node LoadInto(Scene scene, byte[] bytes, string name = null)

Reads a .glb and adds its nodes to an existing scene.

static GltfModel LoadModel(byte[] bytes, string name = null)

Reads a .glb into a fresh scene and hands back everything in it — the clips, the morph targets and the materials, not only the geometry.

static GltfModel LoadModelInto(Scene scene, byte[] bytes, string name = null)

Reads a .glb into an existing scene and hands back everything in it.

The model's GltfModel.Animator is registered with the scene, so Ava3DView advances it without the caller running a clock. Nothing plays until it is asked to: set Animator.Default or call Animator.Play, or the model stands in its bind pose exactly as a file with no animation in it would.

See also