codecraft 0.1.2

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 smallest scene worth looking at: a lit cube turning on a grid, and a
//! camera to fly around it.
//!
//! ```text
//! cargo run --example cube
//! ```
use codecraft::ecs::Entity;
use codecraft::glam::Vec3;
use codecraft::prelude::*;
use codecraft::sceneobjects::lights::default_lights;
use codecraft::{Light, OrbitCamera, Transform, gizmos, primitives};

struct CubeScene {
    cube: Option<Entity>,
}

impl Scene for CubeScene {
    fn setup(&mut self, app: &mut AppState) {
        app.spawn(gizmos::grid());

        let [key, rim] = default_lights();
        app.spawn_entity((key, Light::object("Key Light")));
        app.spawn_entity((rim, Light::object("Rim Light")));

        self.cube = Some(
            app.spawn_primitive(
                primitives::Box::cube(1.0)
                    .at(0.0, 0.5, 0.0)
                    .color(Color::srgb(0.9, 0.45, 0.2)),
            ),
        );
        app.spawn_primitive(
            primitives::Sphere::new(0.4)
                .at(1.8, 0.4, -0.6)
                .color(Color::srgb(0.3, 0.6, 0.9)),
        );

        app.spawn_entity((
            OrbitCamera::new(Vec3::new(0.0, 0.5, 0.0), 5.0).touchpad(),
            OrbitCamera::object("Orbit Camera"),
        ));
    }

    fn update(&mut self, app: &mut AppState) {
        let turn = app.time().elapsed * 0.6;
        if let Some(cube) = self.cube {
            app.edit::<Transform>(cube, |transform| transform.set_yaw(turn));
        }
    }
}

fn main() {
    App::new("cube").scene(CubeScene { cube: None }).run();
}