Move `PickingSettings` out of main module

main
copygirl 3 weeks ago
parent af0732fdc4
commit 2aa370dc60
  1. 12
      client/src/input/mod.rs
  2. 11
      client/src/main.rs
  3. 6
      client/src/ui/mod.rs

@ -12,4 +12,16 @@ pub fn plugin(app: &mut App) {
cursor_grab::plugin, cursor_grab::plugin,
head_orientation::plugin, head_orientation::plugin,
)); ));
// Make entities require the `Pickable` component if
// they should be considered for the picking system.
app.insert_resource(MeshPickingSettings {
require_markers: true,
..default()
});
// Insert `MeshPickingCamera` component on any 3D camera.
app.add_observer(|event: On<Add, Camera3d>, mut commands: Commands| {
commands.entity(event.entity).insert(MeshPickingCamera);
});
} }

@ -51,16 +51,6 @@ fn main() -> Result {
bevy_fix_cursor_unlock_web::FixPointerUnlockPlugin, bevy_fix_cursor_unlock_web::FixPointerUnlockPlugin,
)); ));
// Make entities require the `Pickable` component if
// they should be considered for the picking system.
app.insert_resource(UiPickingSettings {
require_markers: true,
});
app.insert_resource(MeshPickingSettings {
require_markers: true,
..default()
});
app.add_plugins(( app.add_plugins((
common::assets::plugin, common::assets::plugin,
common::network::plugin, common::network::plugin,
@ -131,6 +121,5 @@ fn handle_predicted_player_spawn(event: On<Add, Predicted>, mut commands: Comman
InputMarker::<Action>::default(), InputMarker::<Action>::default(),
// TODO: Attach camera to player head eventually. // TODO: Attach camera to player head eventually.
Camera3d::default(), Camera3d::default(),
MeshPickingCamera,
)); ));
} }

@ -5,4 +5,10 @@ mod loading_screen;
pub fn plugin(app: &mut App) { pub fn plugin(app: &mut App) {
app.add_plugins((crosshair::plugin, loading_screen::plugin)); app.add_plugins((crosshair::plugin, loading_screen::plugin));
// Make entities require the `Pickable` component if
// they should be considered for the picking system.
app.insert_resource(UiPickingSettings {
require_markers: true,
});
} }

Loading…
Cancel
Save