Showcase

Engine studies

Play a 3D game, then run the individual systems it takes to build one, from materials and fluids to audio and networking.

Sunbreak Plaza

Browser demo
First-person view across Sunbreak Plaza from the starting point

WASD to move, mouse or arrows to look, Space to jump, click or G to fire. Esc releases the mouse.

Drag left to move and right to look. Tap Jump, Fire or Link.

Built with Keel — by Cubeage
Featured game

Explore a 3D plaza in first person, rendered by Keel in your browser.

Open Sunbreak Plaza →
02Write this, get this

From Rust to the rendered frame.

See what Keel rendered, then read the lines from the Rust source used to build the scene.

Rigid bodies

Boxes and balls tumbling onto a floor
Fig. 1A frame from the rigid-body simulation.
scenes/src/lib.rs · excerptRust
let dt = w.resource::<Time>().map_or(1.0 / 60.0, |time| time.delta());
w.resource_mut::<RapierPhysics>().unwrap().step(dt).unwrap();
Full Rust listing: Rigid bodies
scenes/src/lib.rsRust
#[cfg(any(not(target_arch = "wasm32"), feature = "web-studies"))]
fn physics(world: &mut WorldConfig) {
    world
        .profile(GameProfile::Playable3d)
        .insert_resource(RapierPhysics::new());
    // A floor, then a tower of boxes.
    body(
        world,
        BodyType::Static,
        Vec3::new(0.0, -0.5, 0.0),
        ColliderShape::Cuboid {
            half_extents: Vec3::new(8.0, 0.5, 8.0),
        },
    );
    for level in 0..8 {
        for x in -2..=2 {
            let at = Vec3::new(x as f32 * 1.05, 0.5 + level as f32 * 1.02, 0.0);
            body(
                world,
                BodyType::Dynamic,
                at,
                ColliderShape::Cuboid {
                    half_extents: Vec3::splat(0.5),
                },
            );
        }
    }
    world.exclusive(SystemPhase::Fixed, |w: &mut EcsWorld| {
        // Step the simulation, then move each mesh to its body.
        let dt = w.resource::<Time>().map_or(1.0 / 60.0, |time| time.delta());
        w.resource_mut::<RapierPhysics>().unwrap().step(dt).unwrap();
        for entity in w.entities_with::<Body>() {
            let state = w
                .resource::<RapierPhysics>()
                .unwrap()
                .body_state(entity)
                .unwrap();
            let mut transform = w.get_mut::<Transform3d>(entity).unwrap();
            transform.translation = state.translation;
            transform.rotation = state.rotation;
        }
    });
}

Particles

Sparks spiralling up from an emitter with glowing trails
Fig. 2A frame from the particle simulation.
scenes/src/lib.rs · excerptRust
emitter.tick(dt);
// Swirl: every particle turns around the vertical axis as it rises.
for p in emitter.particles.iter_mut() {
    let (x, z) = (p.pos[0], p.pos[2]);
    p.pos[0] = x * 0.995 - z * 0.05;
    p.pos[2] = z * 0.995 + x * 0.05;
Full Rust listing: Particles
scenes/src/lib.rsRust
#[cfg(any(not(target_arch = "wasm32"), feature = "web-studies"))]
fn vfx(world: &mut WorldConfig) {
    let sparks = EmitterDesc {
        rate: 220.0,
        speed: 2.4.into(),
        life: 2.2.into(),
        size: 0.09.into(),
        gravity: [0.0, 1.6, 0.0],
        drag: 0.6,
        shape: SpawnShape::Ring {
            radius: 0.6,
            tube: 0.08,
        },
        color: Srgba::rgb(1.0, 0.55, 0.2).into(),
        color_end: Some(Srgba::rgb(0.3, 0.8, 1.0)),
        size_end: 0.0,
        ..EmitterDesc::default()
    };
    world
        .profile(GameProfile::Playable3d)
        .insert_resource(ParticleEmitter::new(sparks))
        .exclusive(SystemPhase::Fixed, |w: &mut EcsWorld| {
            let dt = w
                .resource::<Time>()
                .map_or(1.0 / 60.0, |time| time.delta_f32());
            let mut emitter = w.resource_mut::<ParticleEmitter>().unwrap();
            emitter.tick(dt);
            // Swirl: every particle turns around the vertical axis as it rises.
            for p in emitter.particles.iter_mut() {
                let (x, z) = (p.pos[0], p.pos[2]);
                p.pos[0] = x * 0.995 - z * 0.05;
                p.pos[2] = z * 0.995 + x * 0.05;
            }
        });
}
Quickstart

Build your next game, app and site on Keel.

Keel Engine is source-available under the Business Source License 1.1. Commercial licences are agreed per licensee.