@skidpad/core
v0.8.0
Published
Deterministic, sim-grade vehicle physics core for the web (Rust compiled to WebAssembly).
Downloads
820
Maintainers
Readme
@skidpad/core
Deterministic, sim-grade vehicle physics for the web: a Rust core compiled to WebAssembly, with a TypeScript API. Slip-based tires, a coupled drivetrain, suspension, assists and a path-following driver, bit-identical in every browser engine and in Node.
npm install @skidpad/core @skidpad/presetsimport { init, WHEEL_ORDER } from "@skidpad/core";
import { preset } from "@skidpad/presets";
const sp = await init(); // loads the WASM; call once and share
const world = sp.createWorld(1);
const car = world.addVehicle(preset("hatchbackFwd"));
world.setInput(car, { throttle: 1, steer: 0.2 }); // gear: see VehicleInput.gear
world.step(1 / 60); // substeps at 1 kHz inside
world.read(car, "Speed"); // channel names are checked at compile time
world.read(car, `SlipRatio_${WHEEL_ORDER[0]}`);- Channels.
sp.telemetryLayoutlists every channel with its unit;CHANNEL_NAMESand theChannelNametype are the same list. Per-wheel channels end in_FL,_FR,_RL,_RR(WHEEL_ORDER). - Frame. ISO axes: x forward, y left, z up.
- Versions.
sp.versionis this package's version;sp.simulationVersionidentifies the simulation itself (equal values replay bit for bit). - Bundling. Vite and Node load the WASM with no configuration. A bundled
Node server (esbuild, say) should keep
@skidpad/coreexternal, or import@skidpad/core/compat(the same API with the WASM inlined), or passinit({ wasm })the path of a copy of@skidpad/core/wasm.
Guide: getting started, vehicle definitions, determinism contract, many cars. Source and issues: CS-Software-LLC/skidpad.
License: MIT OR Apache-2.0.
