diff --git a/examples/simple.rs b/examples/simple.rs index 42c228b4b7..72888c9bcc 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -17,19 +17,19 @@ fn main() { world.insert((), vec![ ( - Material { color: math::vec4(0.1, 0.2, 0.1, 1.0), bind_group: None, uniform_buf: None }, + Material::new(math::vec4(0.1, 0.2, 0.1, 1.0)), plane_handle.clone(), LocalToWorld(math::translation(&math::vec3(0.0, 0.0, 0.0))), Translation::new(0.0, 0.0, 0.0) ), ( - Material { color: math::vec4(0.1, 0.1, 0.6, 1.0), bind_group: None, uniform_buf: None }, + Material::new(math::vec4(0.1, 0.1, 0.6, 1.0)), mesh_handle.clone(), LocalToWorld(math::translation(&math::vec3(1.5, 0.0, 1.0))), Translation::new(0.0, 0.0, 0.0) ), ( - Material { color: math::vec4(0.6, 0.1, 0.1, 1.0), bind_group: None, uniform_buf: None }, + Material::new(math::vec4(0.6, 0.1, 0.1, 1.0)), mesh_handle, LocalToWorld(math::translation(&math::vec3(-1.5, 0.0, 1.0))), Translation::new(0.0, 0.0, 0.0) diff --git a/src/render/material.rs b/src/render/material.rs index 005460aebf..66a4ce075e 100644 --- a/src/render/material.rs +++ b/src/render/material.rs @@ -7,6 +7,16 @@ pub struct Material { pub uniform_buf: Option, } +impl Material { + pub fn new(color: math::Vec4) -> Self { + Material { + color, + bind_group: None, + uniform_buf: None, + } + } +} + #[repr(C)] #[derive(Clone, Copy, AsBytes, FromBytes)] pub struct RenderedUniforms {