diff --git a/examples/3d/mixed_lighting.rs b/examples/3d/mixed_lighting.rs index 0cf0edf8da4f5..9ff49f9fd1be5 100644 --- a/examples/3d/mixed_lighting.rs +++ b/examples/3d/mixed_lighting.rs @@ -274,11 +274,22 @@ fn update_radio_buttons( fn handle_lighting_mode_change( mut widget_click_events: EventReader>, mut lighting_mode_change_events: EventWriter, + mut objects: Query<(&Name, &mut Transform)>, mut app_status: ResMut, ) { for event in widget_click_events.read() { app_status.lighting_mode = **event; lighting_mode_change_events.send(LightingModeChanged); + + // Reset the sphere's position if the lighting mode was set to `Baked`. + if app_status.lighting_mode == LightingMode::Baked { + for (name, mut transform) in &mut objects { + if &**name == "Sphere" { + transform.translation = INITIAL_SPHERE_POSITION; + break; + } + } + } } } @@ -287,8 +298,11 @@ fn move_sphere( pointers: Query<&PointerInteraction>, mut meshes: Query<(&Name, &Parent), With>, mut transforms: Query<&mut Transform>, + app_status: Res, ) { - if !mouse_button_input.pressed(MouseButton::Left) { + if app_status.lighting_mode == LightingMode::Baked + || !mouse_button_input.pressed(MouseButton::Left) + { return; }