diff --git a/src/model.rs b/src/model.rs index 0a18d0e..cd903e6 100644 --- a/src/model.rs +++ b/src/model.rs @@ -11,28 +11,22 @@ implement_vertex!(Vertex, position); pub struct Model { vb: VertexBuffer, - ib: IndexBuffer, + ib: IndexBuffer, } impl Model { pub fn new(display: &glium::Display, file: &str) -> Self { let (document, buffers, _images) = gltf::import(file).expect("Could not load gltf file"); - let mesh = document.meshes().next().expect("Could not find mesh"); - let primitive = mesh.primitives().next().expect("Could not find primitive"); + let mesh = document.meshes().next().unwrap(); + let primitive = mesh.primitives().next().unwrap(); let reader = primitive.reader(|buffer| Some(&buffers[buffer.index()])); - let vertices = reader - .read_positions() - .unwrap() - .map(|position| Vertex { position }) - .collect::>(); + + let vertices: Vec = reader.read_positions().unwrap().map(|position| Vertex{ position }).collect(); let vb = VertexBuffer::new(display, &vertices).unwrap(); - let indices = reader - .read_indices() - .unwrap() - .into_u32() - .map(|x| x as u16) - .collect::>(); + + let indices: Vec = reader.read_indices().unwrap().into_u32().collect(); let ib = IndexBuffer::new(display, glium::index::PrimitiveType::TrianglesList, &indices).unwrap(); + Model { vb, ib } }