diff --git a/crates/bevy_render/src/mesh/mesh/mod.rs b/crates/bevy_render/src/mesh/mesh/mod.rs index 8f891ec0e7e487..3193ebb5d1a095 100644 --- a/crates/bevy_render/src/mesh/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mesh/mod.rs @@ -141,6 +141,22 @@ impl Mesh { .map(|data| &mut data.values) } + /// Returns an iterator that yields references to the data of each vertex attribute. + pub fn attributes( + &self, + ) -> impl Iterator { + self.attributes.iter().map(|(id, data)| (*id, &data.values)) + } + + /// Returns an iterator that yields mutable references to the data of each vertex attribute. + pub fn attributes_mut( + &mut self, + ) -> impl Iterator { + self.attributes + .iter_mut() + .map(|(id, data)| (*id, &mut data.values)) + } + /// Sets the vertex indices of the mesh. They describe how triangles are constructed out of the /// vertex attributes and are therefore only useful for the [`PrimitiveTopology`] variants /// that use triangles.