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
//! The README's first scene: a cube that turns on its own and goes where you click.
//!
//! ```text
//! cargo run --example hello
//! ```
use codecraft::ecs::Entity;
use codecraft::glam::Vec3;
use codecraft::prelude::*;
use codecraft::{Light, OrbitCamera, Transform, gizmos, primitives};

struct Hello {
    cube: Entity,
}

impl Hello {
    // Builds the scene with the app in hand, and keeps what it will touch later.
    fn new(app: &mut AppState) -> Self {
        app.spawn(gizmos::grid());

        // Lights are entities; a scene that spawns none has none.
        app.spawn_entity((
            Light::default()
                .from(Vec3::new(-0.55, 1.0, -0.45))
                .temperature(4200.0)
                .strength(2.2)
                .angle(1.5),
            Light::object("Key Light"),
        ));
        app.spawn_entity((
            Light::default()
                .from(Vec3::new(1.0, 0.35, 0.1))
                .temperature(9500.0)
                .strength(1.5)
                .angle(0.0)
                .shadow(false),
            Light::object("Rim Light"),
        ));

        let cube = app.spawn_entity(
            primitives::Box::cube(1.0)
                .name("Cube")
                .color(Color::srgb(0.9, 0.45, 0.2))
                .transform(Transform::at(0.0, 0.5, 0.0)),
        );

        // Right-drag orbits, middle-drag pans, WASD walks, the wheel dollies.
        app.spawn_entity(OrbitCamera::new(Vec3::new(0.0, 0.5, 0.0), 5.0));

        Hello { cube }
    }
}

impl Scene for Hello {
    fn update(&mut self, app: &mut AppState) {
        // Runs every frame: turn the cube with the clock.
        let turn = app.time().elapsed * 0.6;
        app.edit::<Transform>(self.cube, |transform| transform.set_yaw(turn));

        // A click on the ground sends the cube there.
        if app.mouse().just_pressed
            && let Some(hit) = app.cursor_ray().plane_hit(0.0)
        {
            app.edit::<Transform>(self.cube, |transform| {
                transform.translation = hit + Vec3::Y * 0.5;
            });
        }
    }
}

fn main() {
    App::new("hello").scene(Hello::new).run();
}