Module gltf::accessor

source ·
Expand description

Accessors for reading vertex attributes from buffer views.

Basic usage

Visiting the accessors of a glTF asset.

for accessor in gltf.accessors() {
    println!("Accessor #{}", accessor.index());
    println!("offset: {:?}", accessor.offset());
    println!("count: {}", accessor.count());
    println!("data_type: {:?}", accessor.data_type());
    println!("dimensions: {:?}", accessor.dimensions());
}

Utility functions

Reading the values from the vec3 accessors of a glTF asset.

Note

The Iter utility is a low-level iterator intended for use in special cases. The average user is expected to use reader abstractions such as mesh::Reader.

let (gltf, buffers, _) = gltf::import("examples/Box.gltf")?;
let get_buffer_data = |buffer: gltf::Buffer| buffers.get(buffer.index()).map(|x| &*x.0);
for accessor in gltf.accessors() {
    match (accessor.data_type(), accessor.dimensions()) {
        (DataType::F32, Dimensions::Vec3) => {
            let iter = Iter::<[f32; 3]>::new(accessor, get_buffer_data);
            for item in iter {
                println!("{:?}", item);
            }
        }
        _ => {},
    }
}

Modules

  • Contains data structures for sparse storage.
  • Utility functions.

Structs

  • A typed view into a buffer view.

Enums

  • The component data type.
  • Specifies whether an attribute, vector, or matrix.
  • General iterator for an accessor.

Traits