Skip to content

Commit

Permalink
Add GI toggle to example
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Sep 28, 2023
1 parent 15a683c commit a29d962
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion examples/3d/solari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ fn main() {
)
.add_systems(
Update,
(camera_controller, update_sun_direction).run_if(resource_exists::<SolariSupported>()),
(toggle_solari, camera_controller, update_sun_direction)
.run_if(resource_exists::<SolariSupported>()),
)
.run();
}
Expand Down Expand Up @@ -94,6 +95,25 @@ fn solari_not_supported(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}

fn toggle_solari(
key_input: Res<Input<KeyCode>>,
mut commands: Commands,
camera: Query<(Entity, Has<SolariGlobalIlluminationSettings>), With<Camera>>,
) {
if key_input.just_pressed(KeyCode::Space) {
let (entity, gi_enabled) = camera.single();
if gi_enabled {
commands
.entity(entity)
.remove::<SolariGlobalIlluminationSettings>();
} else {
commands
.entity(entity)
.insert(SolariGlobalIlluminationSettings::default());
}
}
}

// --------------------------------------------------------------------------------------

use bevy::input::mouse::MouseMotion;
Expand Down

0 comments on commit a29d962

Please sign in to comment.