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:113

Discriminated union for collider shapes. All dimensions in pixels.

{ 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.

Must be smaller than half the shorter side; anything else throws when the collider is built. Applies to shape casts and overlap queries too.

height: number

type: "box"

width: number


{ radius: number; 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

radius: number

type: "capsule"


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

Closed convex shape. Rapier silently widens concave input to its convex hull; use polyline for non-convex outlines.


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

Chain of line segments. Supports non-convex shapes but is static-only (no mass/inertia computed). Best for world boundaries.