Skip to content

Guides ​

Each guide covers one subsystem's Rust API and where it differs from SHAG. The behaviour itself, such as which cvars exist, what a shader keyword does or what a snapshot holds, is in SHAG's manual, linked at the top of each guide.

GuideCoversSHAG's page
Cvars and consolecore::cvar, console, debug::debug_consoleCvar system, Console system
Inputinputnone yet
Packages and mapsloader::{pk3, bsp, shader, texture}PK3 filesystem, BSP system, Shader system, Skybox system
Models and animationloader::model, animation, worldModel loading, Pickup system
Renderingrendering, lighting, effects, babylonRender variables, Lighting system
Audioaudionone yet
Networking and lobbyshagger_shared::net, network, lobbyNetworking, Lobby server
Collision and physicsshagger_shared::collision, physics, movementPhysics system, Movement system
Viewport and weaponscamera, viewport, weaponCamera system, Viewport effects, Weapon system
UIuinone yet
Demos and highlight reelsshagger_shared::demonone yet
JavaScript parityshagger_shared::{js, fdlibm, json, math_random}none: this is the port's own
Native runtimecore::{crash_report, console_log, atomic_file, join}, TLSnone: this is the port's own

Conventions across the API ​

  • Names follow the TypeScript. A Rust item keeps its TypeScript name in snake case, and its doc comment quotes the TypeScript name in backticks (`Cvar.init()`), so a search for either finds it.
  • The game owns I/O and the clock. Where SHAG relies on the browser's event loop, the Rust port is a state machine the game drives: it passes in the time (wall milliseconds for Date.now(), mono milliseconds for performance.now()) and polls for what happened. Threads that block (sockets, downloads, sound) report through channels, and nothing a frame calls blocks.
  • The game's parts come in through traits and closures. The engine does not know Washoi's events, files or settings. It asks for them: an EventCodec for snapshot events, a fetch closure for files out of the packages, a context type C for console commands.
  • Axes are Babylon's in public, Q3's inside. As in SHAG, collision and map code takes and returns y-up vectors and works in Quake's z-up space internally.
  • f64 where JavaScript computes. JavaScript numbers are doubles. Simulation and protocol code keeps f64 wherever the TypeScript does arithmetic, and narrows to the wire type only where the TypeScript writes bytes. File data stays in the type it is stored as (f32 in a BSP) and widens where the TypeScript computes with it.

Released under the MIT License. Babylon.js ports under Apache-2.0.