Skip to content

API Type ShapeDesc2D

github-actions[bot] edited this page Nov 30, 2026 · 3 revisions

Type Alias: ShapeDesc2D

type ShapeDesc2D = 
  | {
  halfExtents: PhysicsVec2;
  kind: "box";
}
  | {
  kind: "circle";
  radius: number;
}
  | {
  halfHeight: number;
  kind: "capsule";
  radius: number;
}
  | {
  kind: "convexPolygons";
  label?: string;
  outline: readonly PhysicsPoint2[];
  parts: readonly (readonly PhysicsPoint2[])[];
}
  | {
  kind: "convexHull";
  points: readonly PhysicsPoint2[];
}
  | {
  kind: "polyline";
  oriented?: boolean;
  points: readonly PhysicsPoint2[];
}
  | {
  fixInternalEdges?: boolean;
  kind: "compound";
  parts: readonly object[];
}
  | {
  cells: Int32Array;
  kind: "voxels";
  size: PhysicsVec2;
};

Defined in: src/plugins/physics/runtime/backend.ts:42

2D shapes, in the collider's frame.

Union Members

Type Literal

{
  halfExtents: PhysicsVec2;
  kind: "box";
}

Type Literal

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

Type Literal

{
  halfHeight: number;
  kind: "capsule";
  radius: number;
}

Upright (along y); halfHeight is the straight part's.


Type Literal

{
  kind: "convexPolygons";
  label?: string;
  outline: readonly PhysicsPoint2[];
  parts: readonly (readonly PhysicsPoint2[])[];
}

A polygon split into convex parts (one part: a convex hull). If a part has no hull, the closed outline collides as a line.


Type Literal

{
  kind: "convexHull";
  points: readonly PhysicsPoint2[];
}

The convex hull of the points (a tiny circle when they have none).


Type Literal

{
  kind: "polyline";
  oriented?: boolean;
  points: readonly PhysicsPoint2[];
}

A line through the points; closed shapes repeat the first point. Oriented lines are solid on their left only.


Type Literal

{
  fixInternalEdges?: boolean;
  kind: "compound";
  parts: readonly object[];
}

Several shapes as one collider; fixInternalEdges keeps bodies sliding over the seams from catching.


Type Literal

{
  cells: Int32Array;
  kind: "voxels";
  size: PhysicsVec2;
}

Capability voxelColliders (ADR 0444): grid cells, each size (positive) on a side. cells holds the filled cells' integer coordinates as (x, y) pairs; cell (x, y) covers x·size.x .. (x+1)·size.x (and the same in y) in the collider's frame. Edited in place with setVoxels; never a compound's part.

Clone this wiki locally