codecraft 0.2.0

A minimalist 3D game engine built on parts of Bevy (ECS, color) with wgpu and winit: OpenPBR materials, clustered lighting, a yakui-drawn UI, audio and gamepad haptics; its binary maps any folder, and the symbols of its Rust files, as a 3D wall of boxes
Documentation
use bevy_ecs::prelude::*;
use glam::Vec2;

/// Latest cursor position in screen pixels, updated by the host app.
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct CursorPosition {
    pub x: f32,
    pub y: f32,
}

/// Mouse state from `winit`; the single-frame parts are cleared at the end of every update tick.
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct MouseInput {
    pub left_down: bool,
    pub just_pressed: bool,
    pub just_released: bool,
    pub right_down: bool,
    pub middle_down: bool,
    /// Wheel clicks since last frame, positive away from the user; summed so a fast flick is not lost.
    pub scroll: f32,
    /// Raw mouse counts since last frame, straight from the device: no pointer speed, acceleration or pixel rounding.
    pub motion: Vec2,
}

/// Current window size in pixels, updated by the host app on resize.
#[derive(Resource, Clone, Copy, Debug)]
pub struct ScreenSize {
    pub width: f32,
    pub height: f32,
}

impl Default for ScreenSize {
    fn default() -> Self {
        Self {
            width: 800.0,
            height: 600.0,
        }
    }
}

/// What the pointer is over, so a wheel over a panel scrolls it rather than zooming the camera.
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct PointerCapture {
    pub over_panel: bool,
}

impl PointerCapture {
    /// Whether the world should ignore the mouse this frame.
    pub fn taken(self) -> bool {
        self.over_panel
    }
}