Web-First Physics & AI Engine powered by WebAssembly
C++ core compiled to WASM. Engineered for zero-copy memory sharing with TypeScript, eliminating the JS-bridge bottleneck for massive object counts.
Designed for authoritative server architectures. High stability during real-time state injections, perfect for multiplayer rollback and state sync.
Built-in support for NavMeshes, RVO/ORCA, and A* pathfinding running at native speeds within the physics loop.
Contiguous memory layouts and BVH spatial partitioning ensure maximum cache hits and sub-millisecond query times.
Real-time physics calculation at sub-millisecond speeds.
Integration is simple and unopinionated. Start building high-performance physics simulations with a developer experience that prioritizes clarity and speed.
import gearbox from 'gearbox2d'; async function start() { // Initialize the WASM core and prepare shared memory. Call this once. await gearbox.init(); const world = gearbox.makeWorld(); // Add a ground box const ground = world.makeBody(1, { x: 0, y: 10, type: gearbox.bodyTypes.FIXED_OBJECT }); ground.addFixture(1, { width: 20, height: 1, shape: gearbox.shapes.BOX, }); // Basic simulation loop let lastTime = performance.now(); let accumulator = 0; const physicsStep = 1/60; function loop(now) { let dt = (now - lastTime) / 1000; lastTime = now; if (dt > 0.25) dt = 0.25; accumulator += dt; while (accumulator >= physicsStep) { world.step(); accumulator -= physicsStep; } world.interpolationAlpha = accumulator / physicsStep; requestAnimationFrame(loop); } requestAnimationFrame(loop); } start();
Optimized for modern browser environments with SharedArrayBuffer and multi-threaded potential.
(Benchmarks coming soon...)
Gearbox2D is community-driven. Explore the source and contribute to the physics revolution.