Skip to content

Commit

Permalink
model loading works!
Browse files Browse the repository at this point in the history
  • Loading branch information
cart committed Apr 20, 2020
1 parent 75ab0e2 commit 1143f16
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 616 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ type-uuid = "0.1"
env_logger = "0.7"

[profile.dev]
opt-level = 3
# opt-level = 3
25 changes: 22 additions & 3 deletions bevy_gltf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,35 @@ fn load_node(buffer_data: &[Vec<u8>], node: &gltf::Node, depth: i32) -> Result<M
reader
.read_positions()
.map(|v| VertexAttribute {
name: "position".into(),
name: "Vertex_Position".into(),
values: VertexAttributeValues::Float3(v.collect()),
})
.map(|vertex_attribute| mesh.attributes.push(vertex_attribute));

// let indices = reader.read_indices().unwrap();
reader
.read_normals()
.map(|v| VertexAttribute {
name: "Vertex_Normal".into(),
values: VertexAttributeValues::Float3(v.collect()),
})
.map(|vertex_attribute| mesh.attributes.push(vertex_attribute));

reader
.read_tex_coords(0)
.map(|v| VertexAttribute {
name: "Vertex_Uv".into(),
values: VertexAttributeValues::Float2(v.into_f32().collect()),
})
.map(|vertex_attribute| mesh.attributes.push(vertex_attribute));


reader.read_indices().map(|indices| {
mesh.indices = Some(indices.into_u32().collect::<Vec<u32>>());
});

return Ok(mesh);
}
}
println!();

for child in node.children() {
return Ok(load_node(buffer_data, &child, depth + 1)?);
Expand Down
Binary file removed examples/assets/Box.glb
Binary file not shown.
142 changes: 0 additions & 142 deletions examples/assets/Box.gltf

This file was deleted.

Loading

0 comments on commit 1143f16

Please sign in to comment.