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
.
[]
= "0.9"
Examples
Walking the node hierarchy
Below demonstates visiting the root Node
s of every Scene
, printing the
number of children each node has.
# fn run() -> Result<(), Box<std::error::Error>> {
# use std::{fs, io};
# let path = "examples/Box.gltf";
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(),
);
}
}
# Ok(())
# }
# fn main() {
# let _ = run().expect("No runtime errors");
# }