src/systems/PhysicsWorld.tsimport RAPIER from '@dimforge/rapier2d-compat';/*** Wraps a Rapier 2D physics world.** Rapier is a Rust → WASM physics engine — deterministic, fast, and the* modern choice for 2D and 3D web physics. We use the `-compat` build,* which embeds the WASM in the JS bundle so there's no separate fetch.** After construction, you MUST `await world.init()` before using it (the* WASM module loads asynchronously). The Game class does this for you.** Usage:* const body = world.createDynamicBody(x, y);* const collider = world.createBoxCollider(body, halfW, halfH);* world.step();* const { x, y } = body.translation();*/export class PhysicsWorld {private world?: RAPIER.World;
Showing the first 20 lines.
Get full code