Module gltf::mesh

source ·
Expand description

Meshes and their primitives.

Basic usage

Listing the attributes of each mesh primitive in a glTF asset.

for mesh in gltf.meshes() {
   println!("Mesh #{}", mesh.index());
   for primitive in mesh.primitives() {
       println!("- Primitive #{}", primitive.index());
       for (semantic, _) in primitive.attributes() {
           println!("-- {:?}", semantic);
       }
   }
}

Reader utility

Printing the vertex positions of each primitive of each mesh in a glTF asset.

let (gltf, buffers, _) = gltf::import("examples/Box.gltf")?;
for mesh in gltf.meshes() {
   println!("Mesh #{}", mesh.index());
   for primitive in mesh.primitives() {
       println!("- Primitive #{}", primitive.index());
       let reader = primitive.reader(|buffer| Some(&buffers[buffer.index()]));
       if let Some(iter) = reader.read_positions() {
           for vertex_position in iter {
               println!("{:?}", vertex_position);
           }
       }
   }
}

Modules

Structs

  • The minimum and maximum values for a generic accessor.
  • A set of primitives to be rendered.
  • A single morph target for a mesh primitive.
  • Geometry to be rendered with the given material.
  • Mesh primitive reader.

Enums

  • The type of primitives to render.
  • Vertex attribute semantic name.

Type Aliases