From cc388a5f61365606448eeff8849b5a8b635e8fd4 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Tue, 22 Nov 2022 22:42:25 +0000 Subject: [PATCH] Factor outline definition into variable. --- examples/pieces.rs | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/examples/pieces.rs b/examples/pieces.rs index 52daa1d..397234d 100644 --- a/examples/pieces.rs +++ b/examples/pieces.rs @@ -31,6 +31,16 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { + let outline = OutlineBundle { + outline: OutlineVolume { + visible: true, + colour: Color::WHITE, + width: 10.0, + }, + stencil: OutlineStencil { offset: 5.0 }, + ..default() + }; + // Add sphere with child meshes sticking out of it commands .spawn(PbrBundle { @@ -44,18 +54,9 @@ fn setup( ), material: materials.add(Color::rgb(0.9, 0.1, 0.1).into()), transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)), - - ..default() - }) - .insert(OutlineBundle { - outline: OutlineVolume { - visible: true, - colour: Color::WHITE, - width: 10.0, - }, - stencil: OutlineStencil { offset: 5.0 }, ..default() }) + .insert(outline.clone()) .insert(Rotates) .with_children(|parent| { parent @@ -76,15 +77,7 @@ fn setup( .with_translation(Vec3::new(0.0, 0.0, 0.75)), ..default() }) - .insert(OutlineBundle { - outline: OutlineVolume { - visible: true, - colour: Color::WHITE, - width: 10.0, - }, - stencil: OutlineStencil { offset: 5.0 }, - ..default() - }) + .insert(outline.clone()) .insert(InheritOutlineDepth); parent .spawn(PbrBundle { @@ -102,15 +95,7 @@ fn setup( .with_translation(Vec3::new(0.0, 0.0, -0.75)), ..default() }) - .insert(OutlineBundle { - outline: OutlineVolume { - visible: true, - colour: Color::WHITE, - width: 10.0, - }, - stencil: OutlineStencil { offset: 5.0 }, - ..default() - }) + .insert(outline.clone()) .insert(InheritOutlineDepth); });