From 8f1eaa6db508ac86158280d1c57affe3a9beb875 Mon Sep 17 00:00:00 2001 From: Julian Heinken Date: Tue, 13 Apr 2021 01:47:25 +0000 Subject: [PATCH] glTF: added color attribute support (#1775) --- crates/bevy_gltf/src/loader.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 25da841eb3664..7631686b9f044 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -142,6 +142,13 @@ async fn load_gltf<'a, 'b>( mesh.set_attribute(Mesh::ATTRIBUTE_UV_0, vertex_attribute); } + if let Some(vertex_attribute) = reader + .read_colors(0) + .map(|v| VertexAttributeValues::Float4(v.into_rgba_f32().collect())) + { + mesh.set_attribute(Mesh::ATTRIBUTE_COLOR, vertex_attribute); + } + if let Some(indices) = reader.read_indices() { mesh.set_indices(Some(Indices::U32(indices.into_u32().collect()))); };