Skip to main content

bevy_fsl_box_frame/
lib.rs

1#![deny(missing_docs)]
2#![doc = include_str!("../README.md")]
3
4mod box_frame;
5mod drag_face;
6mod handle_visibility;
7mod highlight;
8mod picking_backend;
9mod solid_color_material;
10
11pub use box_frame::*;
12pub use solid_color_material::*;
13
14use bevy::{
15    asset::load_internal_asset,
16    picking::PickingSystems,
17    prelude::{IntoScheduleConfigs, MaterialPlugin, Plugin, PreUpdate, Shader, Update},
18};
19use drag_face::*;
20use handle_visibility::*;
21use highlight::*;
22use picking_backend::box_frame_backend;
23
24/// Enables pointer interactions for [`BoxFrame`] entities.
25pub struct BoxFramePlugin;
26
27impl Plugin for BoxFramePlugin {
28    fn build(&self, app: &mut bevy::prelude::App) {
29        load_internal_asset!(
30            app,
31            SHADER_HANDLE,
32            "shaders/solid_color.wgsl",
33            Shader::from_wgsl
34        );
35
36        app.add_plugins(MaterialPlugin::<SolidColorMaterial>::default())
37            .add_systems(PreUpdate, box_frame_backend.in_set(PickingSystems::Backend))
38            .add_systems(Update, (handle_visibility, highlight_handles))
39            // Correct highlighting updates depend on the state of dragging.
40            .add_systems(Update, (drag_face, highlight_face).chain());
41    }
42}