API tour
Games talk to Kerabit through a tiny builder + run closure.
wgpu and winit stay inside the crates. Full freeze table:
API.md.
Composition
use kerabit::prelude::*;
fn main() {
Kerabit::new("Demo")
.clear_color(Color::rgb(0.08, 0.09, 0.12))
.spawn(
Entity::new("cube")
.mesh(Mesh::cube())
.material(Material::color(Color::ORANGE).roughness(0.35))
.at(Vec3::new(0.0, 0.5, 0.0)),
)
.camera(Camera::perspective(60.0).look_at(vec3(5.0, 3.0, 7.0), Vec3::ZERO))
.light(Light::sun(vec3(-0.35, -1.0, -0.25)).intensity(1.2))
.ambient(Color::rgb(0.15, 0.16, 0.18))
.run(|ctx| {
if ctx.input().key_pressed(Key::Escape) {
ctx.quit();
}
if let Some(cube) = ctx.world_mut().get_mut("cube") {
cube.rotate_y(1.1 * ctx.dt());
}
});
}
What you use every frame
-
ctx.dt()— frame delta seconds -
ctx.input()— keys / mouse (key_down,key_pressed) -
ctx.world()/world_mut()— named entities, tags, layers, enable/disable -
ctx.camera_mut()— orbit / follow -
ctx.physics()— static AABBs, casts,move_and_collide; dynamics + character controller (M2) -
ctx.audio()— WAV play; spatialplay_at, buses,play_music(M3) -
ctx.ui()— immediatetext/rect -
ctx.spawn_particles(…)— billboard bursts (M1) -
ctx.quit()— leave the loop
Materials & lights
PBR-lite: albedo + roughness + metallic (+ optional normal map). Up to
4 lights via Kerabit::lights /
ctx.set_lights (Light::sun,
Light::point). Soft shadows come from the first directional
light. HDR path goes through tonemap + cheap bloom.
Scenes
Author .kerabit.json in the editor or load at runtime:
Kerabit::new("Level")
.scene("games/reach/levels/01_intro.kerabit.json")
.run(|ctx| { /* … */ });
// or inside the loop:
ctx.load_scene("path/to/scene.kerabit.json")?;
Mesh files on entities: OBJ, glTF / glb,
and FBX. Schema version stays
SCENE_VERSION = 1 with additive
components / extras objects reserved for
growth.
Try more examples
cargo run -p kerabit --example playground
cargo run -p kerabit --example pbr_room
cargo run -p kerabit --example physics_sandbox
cargo run -p showcase # engine trailer, when the crate is in the workspace
Next: Editor guide · Contract: API.md