Factor outline definition into variable.

This commit is contained in:
Robin KAY 2022-11-22 22:42:25 +00:00
parent fd5cfd0a1c
commit cc388a5f61
1 changed files with 13 additions and 28 deletions

View File

@ -31,6 +31,16 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
) { ) {
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 // Add sphere with child meshes sticking out of it
commands commands
.spawn(PbrBundle { .spawn(PbrBundle {
@ -44,18 +54,9 @@ fn setup(
), ),
material: materials.add(Color::rgb(0.9, 0.1, 0.1).into()), material: materials.add(Color::rgb(0.9, 0.1, 0.1).into()),
transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)), 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() ..default()
}) })
.insert(outline.clone())
.insert(Rotates) .insert(Rotates)
.with_children(|parent| { .with_children(|parent| {
parent parent
@ -76,15 +77,7 @@ fn setup(
.with_translation(Vec3::new(0.0, 0.0, 0.75)), .with_translation(Vec3::new(0.0, 0.0, 0.75)),
..default() ..default()
}) })
.insert(OutlineBundle { .insert(outline.clone())
outline: OutlineVolume {
visible: true,
colour: Color::WHITE,
width: 10.0,
},
stencil: OutlineStencil { offset: 5.0 },
..default()
})
.insert(InheritOutlineDepth); .insert(InheritOutlineDepth);
parent parent
.spawn(PbrBundle { .spawn(PbrBundle {
@ -102,15 +95,7 @@ fn setup(
.with_translation(Vec3::new(0.0, 0.0, -0.75)), .with_translation(Vec3::new(0.0, 0.0, -0.75)),
..default() ..default()
}) })
.insert(OutlineBundle { .insert(outline.clone())
outline: OutlineVolume {
visible: true,
colour: Color::WHITE,
width: 10.0,
},
stencil: OutlineStencil { offset: 5.0 },
..default()
})
.insert(InheritOutlineDepth); .insert(InheritOutlineDepth);
}); });