@yagejs/physics
v0.1.0
Published
Rapier 2D physics integration (rigid bodies, colliders, joints) for the YAGE 2D game engine
Maintainers
Readme
@yagejs/physics
Rapier 2D physics integration - rigid bodies, colliders, and joints for the YAGE 2D game engine.
Install
npm install @yagejs/physicsBundles Rapier 2D - no separate install required. Rapier uses WebAssembly; if you use Vite, install vite-plugin-wasm.
Usage
import { Engine } from "@yagejs/core";
import { PhysicsPlugin, RigidBodyComponent, ColliderComponent } from "@yagejs/physics";
const engine = new Engine();
engine.use(new PhysicsPlugin({ gravity: { x: 0, y: 980 } }));Attach bodies and colliders to entities:
entity.add(new RigidBodyComponent({ type: "dynamic" }));
entity.add(new ColliderComponent({ shape: { type: "box", width: 40, height: 40 } }));What's in the box
- PhysicsPlugin - Rapier world management with fixed-timestep accumulator
- RigidBodyComponent - dynamic, static, kinematic bodies
- ColliderComponent - boxes, circles, polygons, sensors with trigger events
- Raycasts - query the world for collisions along a ray
- Collision layers / masks - filter collisions by group
- Joints - distance, revolute, prismatic, fixed
Docs
Full documentation at yage.dev.
License
MIT
