Add OutlineBundle.
This commit is contained in:
parent
75dcc9077c
commit
ce228d1c2d
|
@ -46,12 +46,14 @@ fn setup(
|
||||||
transform: Transform::from_xyz(0.0, 1.0, 0.0),
|
transform: Transform::from_xyz(0.0, 1.0, 0.0),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(Outline {
|
.insert_bundle(OutlineBundle {
|
||||||
|
outline: Outline {
|
||||||
visible: true,
|
visible: true,
|
||||||
colour: Color::rgba(0.0, 1.0, 0.0, 1.0),
|
colour: Color::rgba(0.0, 1.0, 0.0, 1.0),
|
||||||
width: 25.0,
|
width: 25.0,
|
||||||
|
},
|
||||||
|
..default()
|
||||||
})
|
})
|
||||||
.insert(OutlineStencil)
|
|
||||||
.insert(Wobbles);
|
.insert(Wobbles);
|
||||||
|
|
||||||
commands
|
commands
|
||||||
|
@ -67,12 +69,14 @@ fn setup(
|
||||||
.with_rotation(Quat::from_rotation_x(0.5 * PI)),
|
.with_rotation(Quat::from_rotation_x(0.5 * PI)),
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(Outline {
|
.insert_bundle(OutlineBundle {
|
||||||
|
outline: Outline {
|
||||||
visible: true,
|
visible: true,
|
||||||
colour: Color::rgba(1.0, 0.0, 1.0, 0.3),
|
colour: Color::rgba(1.0, 0.0, 1.0, 0.3),
|
||||||
width: 15.0,
|
width: 15.0,
|
||||||
|
},
|
||||||
|
..default()
|
||||||
})
|
})
|
||||||
.insert(OutlineStencil)
|
|
||||||
.insert(Orbits);
|
.insert(Orbits);
|
||||||
commands.spawn_bundle(PointLightBundle {
|
commands.spawn_bundle(PointLightBundle {
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -40,7 +40,7 @@ pub const ATTRIBUTE_OUTLINE_NORMAL: MeshVertexAttribute = MeshVertexAttribute::n
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A component for stenciling meshes during outline rendering.
|
/// A component for stenciling meshes during outline rendering.
|
||||||
#[derive(Component, Default)]
|
#[derive(Clone, Component, Default)]
|
||||||
pub struct OutlineStencil;
|
pub struct OutlineStencil;
|
||||||
|
|
||||||
impl ExtractComponent for OutlineStencil {
|
impl ExtractComponent for OutlineStencil {
|
||||||
|
@ -53,7 +53,7 @@ impl ExtractComponent for OutlineStencil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A component for rendering outlines around meshes.
|
/// A component for rendering outlines around meshes.
|
||||||
#[derive(Clone, Component)]
|
#[derive(Clone, Component, Default)]
|
||||||
pub struct Outline {
|
pub struct Outline {
|
||||||
/// Enable rendering of the outline
|
/// Enable rendering of the outline
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
|
@ -63,6 +63,13 @@ pub struct Outline {
|
||||||
pub colour: Color,
|
pub colour: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A bundle for rendering stenciled outlines around meshes.
|
||||||
|
#[derive(Bundle, Clone, Component, Default)]
|
||||||
|
pub struct OutlineBundle {
|
||||||
|
pub outline: Outline,
|
||||||
|
pub stencil: OutlineStencil,
|
||||||
|
}
|
||||||
|
|
||||||
/// Failed to generate outline normals for the mesh.
|
/// Failed to generate outline normals for the mesh.
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum GenerateOutlineNormalsError {
|
pub enum GenerateOutlineNormalsError {
|
||||||
|
|
Loading…
Reference in New Issue