Expand description
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 to your Cargo.toml:
[dependencies.gltf]
version = "1"§Examples
§Basic usage
Walking the node hierarchy.
let gltf = Gltf::open("examples/Box.gltf")?;
for scene in gltf.scenes() {
for node in scene.nodes() {
println!(
"Node #{} has {} children",
node.index(),
node.children().count(),
);
}
}§Import function
Reading a glTF document plus its buffers and images from the file system.
let (document, buffers, images) = gltf::import("examples/Box.gltf")?;
assert_eq!(buffers.len(), document.buffers().count());
assert_eq!(images.len(), document.images().count());§Note
This function is provided as a convenience for loading glTF and associated resources from the file system. It is suitable for real world use but may not be suitable for all real world use cases. More complex import scenarios such downloading from web URLs are not handled by this function. These scenarios are delegated to the user.
You can read glTF without loading resources by constructing the Gltf
(standard glTF) or Glb (binary glTF) data structures explicitly. Buffer
and image data can then be imported separately using import_buffers and
import_images respectively.
Re-exports§
pub extern crate gltf_json as json;
Modules§
accessorAccessors for reading vertex attributes from buffer views.animationAnimations, their channels, targets, and samplers.binaryPrimitives for working with binary glTF.bufferBuffers and buffer views.cameraCameras and their projections.imageImages that may be used by textures.iterIterators for walking the glTF node hierarchy.khr_lights_ punctual KHR_lights_punctualSupport for theKHR_lights_punctualextension.khr_materials_ variants KHR_materials_variantsSupport for theKHR_materials_variantsextension.materialMaterial properties of primitives.meshMeshes and their primitives.sceneThe glTF node heirarchy.skinMesh skinning primitives.textureTextures and their samplers.
Structs§
AccessorA typed view into a buffer view.AnimationA keyframe animation.BufferA buffer points to binary data representing geometry, animations, or skins.CameraA camera’s projection. A node can reference a camera to apply a transform to place the camera in the scene.DocumentglTF JSON wrapper.GlbBinary glTF contents.GltfglTF JSON wrapper plus binary payload.ImageImage data used to create a texture.MaterialThe material appearance of a primitive.MeshA set of primitives to be rendered.NodeA node in the node hierarchy.PrimitiveGeometry to be rendered with the given material.SceneThe root nodes of a scene.SkinJoints and matrices defining a skin.TextureA texture and its sampler.
Enums§
Functions§
importimportImport glTF 2.0 from the file system.import_buffers importImport buffer data referenced by a glTF document.import_images importImport image data referenced by a glTF document.import_slice importImport glTF 2.0 from a slice.