μglTF

Minimal glTF 2.0 asset loader for Rust


License: MIT Crates.io Docs.rs

Overview

mugltf is a minimal implementation of glTF 2.0 asset model loader in Rust. It uses serde for parsing the glTF JSON.

Install

toml [dependencies] mugltf = "0.1.0" Features: - std - (default) enables std support. - serde - (default) enables serde parsing of glTF assets - gltf-name - enables the name field for all glTF nodes - gltf-extras - enables the extras field for all glTF nodes - gltf-extensions - enables the extensions field for all glTF nodes - file-loader - enables GltfResourceFileLoader for loading glTF resources from file system

Documentation

See Docs.rs: https://docs.rs/mugltf

Usage

```rust // 1. Start from parsing a gltf / glb file let asset = ::parsegltf(includestr!("./test.gltf")); let glbasset = ::parseglb(include_str!("./test.glb"));

// You can now read the glTF model and binry chunk (for glb file). let gltfmodel = glbasset.gltf; let binarychunk = glbasset.bin;

// 2. Init a loader to load resources (external/embedded buffers and images) async let mut loader = mugltf::GltfResourceFileLoader::default(); loader.setpath("./"); glbasset.load_resources(&loader).await?;

// Buffer and image resources are now populated let buffers = glbasset.buffers; let images = glbasset.images; ```

See tests for more example usages.