3 releases

0.1.2 Apr 25, 2022
0.1.1 Apr 23, 2022
0.1.0 Apr 18, 2022

#542 in WebAssembly

MIT license

4.5MB
6.5K SLoC

μ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

[dependencies]
mugltf = "0.1"

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
  • fetch-loader - enables GltfResourceFetchLoader for loading glTF resources using fetch API for web WASM

Documentation

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

Usage

// Init a loader and set the base path (Use mugltf::GltfResourceFetchLoader for WASM web environment)
let mut loader = mugltf::GltfResourceFileLoader::default();
loader.set_path("./");

// Load a glTF JSON / GLB asset async
// You can set the last parameter to false to skip loading buffers and images
let asset = mugltf::GltfAsset.load(&loader, "./test.glb", true).await?;

// You can now read the glTF model and resources.
let gltf_model = asset.gltf;
let binary_chunk = asset.bin;
let buffers = asset.buffers;
let images = asset.images;

See tests for more example usages.

Dependencies

~0.5–6MB
~76K SLoC