Skip to content

ColliderShape

ColliderShape = { borderRadius?: number; height: number; type: "box"; width: number; } | { radius: number; type: "circle"; } | { axis?: "x" | "y"; halfHeight: number; radius: number; type: "capsule"; } | { type: "polygon"; vertices: Vec2Like[]; } | { type: "polyline"; vertices: Vec2Like[]; }

Defined in: physics/src/types.ts:171

Discriminated union for collider shapes. All dimensions in pixels. Every entry that takes a shape (ColliderComponent, setShape, castShape, queryShape, queryRadius) throws on a dimension that is not finite and above 0, naming the field.

{ borderRadius?: number; height: number; type: "box"; width: number; }

optional borderRadius?: number

Rounds the corners by this many pixels. The inner half-extents shrink by the radius, so the outer footprint stays width × height and a resting body keeps its height.

The flat part of each face shrinks to width - 2 * borderRadius, so a body supported only by the last borderRadius pixels of a ledge slides off it.

Mass is the rounded footprint’s area at the configured density, so rounding changes it only by the four corner pieces. Angular inertia is the inner rectangle’s, scaled by the same area ratio — an approximation of the exact round-rectangle inertia.

Finite, >= 0 and smaller than half the shorter side; anything else throws. Applies to shape casts and overlap queries too.

height: number

Finite and > 0.

type: "box"

width: number

Finite and > 0.


{ radius: number; type: "circle"; }

radius: number

Finite and > 0.

type: "circle"


{ axis?: "x" | "y"; halfHeight: number; radius: number; type: "capsule"; }

optional axis?: "x" | "y"

Orientation of the long axis. Default: "y" (vertical).

halfHeight: number

Half the straight section, finite and >= 0. Each cap adds radius, so the collider is 2 * (halfHeight + radius) tall: { halfHeight: 20, radius: 10 } stands 60 px. 0 is a circle.

radius: number

Cap radius, finite and > 0.

type: "capsule"


{ type: "polygon"; vertices: Vec2Like[]; }

Closed convex shape: at least 3 vertices, every coordinate finite, not all on one line. Rapier silently widens concave input to its convex hull; use polyline for non-convex outlines.


{ type: "polyline"; vertices: Vec2Like[]; }

Chain of line segments: at least 2 vertices, every coordinate finite. Supports non-convex shapes but is static-only (no mass/inertia computed). Best for world boundaries.

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/physics.md.