google/xb-physics
>- Add rigid-body physics to an XR Blocks app using the Rapier3D engine — gravity, collisions, and (with xb-depth) colliders that match real-world geometry so virtual objects bounce off the floor and furniture. Use for ball pits, throwing/ dropping objects, projectiles, or any depth-aware physical interaction. Covers enabling physics via `options.physics.RAPIER`, the `initPhysics(physics)` / `physicsStep()` Script hooks, and the depth-mesh collider recipe. There is no `enablePhysics()` method — assigning `options.physics.RAPIER` is what turns it on.
npx skills add https://github.com/google/xrblocks --skill xb-physics
Physics is enabled by giving Options the Rapier module; your Script then sets up bodies in
initPhysics(). See demos/ballpit, demos/splash, and demos/drone.
import RAPIER from '@dimforge/rapier3d-simd-compat';
import * as xb from 'xrblocks';
const options = new xb.Options();
options.physics.RAPIER = RAPIER; // assigning RAPIER enables physics
// options.physics.useEventQueue = true; // opt in to collision events (see demos/splash)
xb.init(options);
> There is no options.enablePhysics(). Assigning options.physics.RAPIER is the switch.
class Balls extends xb.Script {
// Called once after init() when physics is enabled. `physics` is the xb Physics wrapper
// around the Rapier world — create rigid bodies/colliders here.
initPhysics(physics) {
this.physics = physics;
// …create RAPIER bodies/colliders; see demos/ballpit/BallPit.js for the full API…
}
// Called each physics step — apply forces, sync transforms, read collisions.
physicsStep() {}
}
To collide with the real room, combine physics with a depth-mesh collider (see
xb-depth):
options.depth = new xb.DepthOptions(xb.xrDepthMeshPhysicsOptions);
options.depth.depthMesh.colliderUpdateFps = 5;
options.physics.RAPIER = RAPIER;
Now thrown objects bounce off the live depth mesh of the environment.
physics instance passed toinitPhysics() — copy the patterns in demos/ballpit/BallPit.js
and src/physics/Physics.ts.
@dimforge/rapier3d-simd-compat).
Take google/xb-physics from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.