3 releases
0.1.2 | Apr 25, 2022 |
---|---|
0.1.1 | Apr 23, 2022 |
0.1.0 | Apr 18, 2022 |
#542 in WebAssembly
4.5MB
6.5K
SLoC
μglTF
Minimal glTF 2.0 asset loader for Rust
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) enablesstd
support.serde
- (default) enablesserde
parsing of glTF assetsgltf-name
- enables thename
field for all glTF nodesgltf-extras
- enables theextras
field for all glTF nodesgltf-extensions
- enables theextensions
field for all glTF nodesfile-loader
- enablesGltfResourceFileLoader
for loading glTF resources from file systemfetch-loader
- enablesGltfResourceFetchLoader
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