@drawcall/physics
v0.19.0
Published
Physics scene objects, automatic colliders, and joints for Three.js.
Readme
@drawcall/physics
Physics scene objects for Three.js. Build rigid and soft bodies, colliders, and joints as ordinary Object3Ds, then simulate them with a backend. Use CapsuleMotor for collision-aware character movement.
| Package | Purpose |
| --- | --- |
| @drawcall/physics | Scene objects and shared contracts |
| @drawcall/physics-rapier | Rapier simulation |
| @drawcall/physics-mujoco | MuJoCo simulation in browsers and Node |
| @drawcall/physics-fem | Cached reduced FEM components |
| @drawcall/physics-usd | USD Physics import and export |
Quick start
npm install three @drawcall/physics @drawcall/physics-rapierimport { BoxGeometry, Mesh, Scene } from "three";
import { RigidBody } from "@drawcall/physics";
import { buildWorld } from "@drawcall/physics-rapier";
const scene = new Scene();
const body = new RigidBody({ mass: 1 });
body.add(new Mesh(new BoxGeometry()));
scene.add(body);
const world = await buildWorld({ scene });
world.update(1 / 60); // each frame, with elapsed seconds
world.dispose(); // when doneFor MuJoCo, import buildWorld from @drawcall/physics-mujoco instead. The shipped physics skill covers scene authoring and links to each package's workflows.
The shipped game-controller skill includes source files to copy and adapt for characters, cars, planes, and quadcopters.
Examples
In a clone of the repository:
pnpm --filter @drawcall/example-ragdoll dev # articulated ragdoll, pointer grab
pnpm --filter @drawcall/example-car dev # powered car with suspension
pnpm --filter @drawcall/example-controllers dev # character, car, plane, quadcopter
pnpm --filter @drawcall/example-scale dev # scaled colliders and decomposition
pnpm --filter @drawcall/example-softbody dev # grip a block, cloth, or cord with reduced FEM padsThe controller playground shows four game controllers built on the shared API: capsule movement, a raycast car, an assisted plane, and a hovering quadcopter. Switch modes and backends in the page; every controller runs on Rapier and MuJoCo.
