mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
transparency_3d
example tweaks (#4968)
Fixed a typo, removed unused component, normalized comments added a touch more detail.
This commit is contained in:
parent
7e6dd3f03e
commit
33a5f2b977
1 changed files with 5 additions and 8 deletions
|
@ -13,21 +13,18 @@ fn main() {
|
|||
.run();
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct FadeTransparency;
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// Opaque plane
|
||||
// opaque plane, uses `alpha_mode: Opaque` by default
|
||||
commands.spawn_bundle(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Plane { size: 6.0 })),
|
||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
|
||||
..default()
|
||||
});
|
||||
// transparent sphere, using alpha_mode: Mask
|
||||
// transparent sphere, uses `alpha_mode: Mask(f32)`
|
||||
commands.spawn_bundle(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Icosphere {
|
||||
radius: 0.5,
|
||||
|
@ -39,7 +36,7 @@ fn setup(
|
|||
// `fade_transparency` function.
|
||||
// Note that the transparency has no effect on the objects shadow.
|
||||
base_color: Color::rgba(0.2, 0.7, 0.1, 0.0),
|
||||
// Maks sets a cutoff for transparency. Alpha values below are fully transparent,
|
||||
// Mask sets a cutoff for transparency. Alpha values below are fully transparent,
|
||||
// alpha values above are fully opaque.
|
||||
alpha_mode: AlphaMode::Mask(0.5),
|
||||
..default()
|
||||
|
@ -47,7 +44,7 @@ fn setup(
|
|||
transform: Transform::from_xyz(1.0, 0.5, -1.5),
|
||||
..default()
|
||||
});
|
||||
// transparent cube, using alpha_mode: Blend
|
||||
// transparent cube, uses `alpha_mode: Blend`
|
||||
commands.spawn_bundle(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
|
||||
// Notice how there is no need to set the `alpha_mode` explicitly here.
|
||||
|
@ -57,7 +54,7 @@ fn setup(
|
|||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
// sphere
|
||||
// opaque sphere
|
||||
commands.spawn_bundle(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(shape::Icosphere {
|
||||
radius: 0.5,
|
||||
|
|
Loading…
Reference in a new issue