Crate gltf [] [src]

glTF 2.0 loader

This crate is intended to load glTF 2.0, a file format designed for the efficient runtime transmission of 3D scenes. The crate aims to provide rustic utilities that make working with glTF simple and intuitive.

Installation

Add gltf version 0.9 to your Cargo.toml.

[dependencies.gltf]
version = "0.9"

Examples

Walking the node hierarchy

Below demonstates visiting the root Nodes of every Scene, printing the number of children each node has.

use gltf::Gltf;
let file = fs::File::open(path)?;
let gltf = Gltf::from_reader(io::BufReader::new(file))?.validate_minimally()?;
for scene in gltf.scenes() {
    for node in scene.nodes() {
        // Do something with this node.
        println!(
            "Node {} has {} children",
            node.index(),
            node.children().count(),
        );
    }
}

Modules

accessor

Accessors for reading vertex attributes from buffer views.

animation

Animations, their channels, targets, and samplers.

buffer

Buffers and buffer views.

camera

Cameras and their projections.

glb

Primitives for working with binary glTF.

gltf

The main module - start here.

image

Images that may be used by textures.

material

Material properties of primitives.

mesh

Meshes and their primitives.

scene

The glTF node heirarchy.

skin

Mesh skinning primitives.

texture

Textures and their samplers.

Structs

Accessor

A typed view into a buffer view.

Animation

A keyframe animation.

Buffer

A buffer points to binary data representing geometry, animations, or skins.

Camera

A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene.

Glb

The contents of a .glb file.

Gltf

The primary data structure of this crate.

Image

Image data used to create a texture.

Material

The material appearance of a primitive.

Mesh

A set of primitives to be rendered.

Node

A node in the node hierarchy.

Primitive

Geometry to be rendered with the given material.

Scene

The root Nodes of a scene.

Skin

Joints and matrices defining a skin.

Texture

A texture and its sampler.

Unvalidated

Represents glTF that hasn't been validated yet.

Enums

Error

Represents a runtime error.

Semantic

Vertex attribute semantic name.

Functions

is_binary

Returns true if the slice begins with the b"glTF" magic string, indicating a binary glTF asset.

Type Definitions

Attribute

Vertex attribute data.