Skip to content

2D physics functions and components

Read as Markdown

import {
Capsule2D,
Chain2D,
PhysicsDebug2D,
PhysicsShape2D,
PhysicsWorld2D,
Segment2D,
circleShape2D,
collider2D,
pibblPhysicsBody2D,
pibblPhysicsWorld2D,
dynamicBody2D,
} from "@pibbl/core/physics/2d";

@pibbl/core/physics/2d is a component-scoped, Pibbl-scheduled Rapier 2D world. It does not start a second animation loop. For recipes and interaction examples, read the 2D physics guide. Pure construction and geometry operations are also exported by @pibbl/core/physics/2d/geometry. The central contracts are PibblPhysicsWorld2DProps, PibblPhysicsBodyHandle2D, and PibblPhysicsShape2D.

const world = (
<PhysicsWorld2D gravity={[0, 600]} fixedStepMilliseconds={1000 / 60} />
);

Creates one world for descendants. It owns fixed-step simulation, collision delivery, presentation interpolation, and teardown. Default space="root" uses root-logical coordinates; creation-only space="local" follows the world’s viewport transform. See PibblPhysicsWorld2DProps.

function pibblPhysicsWorld2D(): PibblPhysicsWorldHandle2D;

Returns the nearest world while a descendant evaluates. Use it for world queries, coordinate conversion, and inspection.

PhysicsShape2D, Capsule2D, Segment2D, and Chain2D

Section titled “PhysicsShape2D, Capsule2D, Segment2D, and Chain2D”

Canvas primitives that paint exact supported shapes and accept physics:

const primitiveShapes = (
<>
<PhysicsShape2D style={{ shape: circleShape2D({ radius: 8 }) }} />
<Capsule2D style={{ start: [0, 0], end: [36, 0], radius: 5 }} />
<Segment2D style={{ start: [0, 0], end: [60, 0] }} />
<Chain2D
style={{
points: [
[0, 0],
[40, 0],
[40, 24],
],
radius: 2,
}}
/>
</>
);

Their props and styles are covered by the 2D physics types.

const debug = (
<PhysicsDebug2D world={pibblPhysicsWorld2D()} color="rgba(0, 160, 255, .8)" />
);

Renders a read-only diagnostic overlay of committed collider bounds, centers of mass, contact points, and contact normals. It creates no pointer targets, does not advance the world, and is appropriate for tests and development-only scenes.

function withPhysicsShape2D<P, I, ResolvedStyle>(
component: PibblPrimitiveComponent<P, I>,
options: { resolveShape(style: Readonly<ResolvedStyle>): PibblPhysicsShape2D },
): PibblPrimitiveComponent<
P & PibblPhysicsPrimitiveProps2D,
I & { physics?: PibblPhysicsAttachment2D }
>;

Derives a primitive that resolves an immutable shape synchronously from its resolved style. This is the custom-primitive extension point; it does not mount a world or alter paint order.

function dynamicBody2D(
options?: PibblPhysicsDynamicBody2DOptions,
): PibblPhysicsBodyAttachment2D;
function staticBody2D(
options?: PibblPhysicsStaticBody2DOptions,
): PibblPhysicsBodyAttachment2D;
function kinematicBody2D(
options?: PibblPhysicsKinematicBody2DOptions,
): PibblPhysicsBodyAttachment2D;
function collider2D(
options?: PibblPhysicsColliderConfiguration2D,
): PibblPhysicsColliderAttachment2D;
function pibblPhysicsBody2D(): PibblPhysicsBodyHandle2D;

Attach a body descriptor to a primitive and child collider2D() descriptors to its geometry. Dynamic bodies receive forces and contacts; static bodies remain fixed; kinematic bodies follow declared signals and affect other bodies. The body primitive’s authored transform supplies its initial pose. pibblPhysicsBody2D is a stable hook handle that can bind to one live body at a time.

Commands enter Pibbl’s Begin phase and take effect on the next admitted physics frame; none mutate a world during render.

function applyForce2D(
body: PibblPhysicsBodyHandle2D,
force: PibblPhysicsVector2,
options?: { at?: PibblPhysicsVector2; wake?: boolean },
): void;
function applyImpulse2D(
body: PibblPhysicsBodyHandle2D,
impulse: PibblPhysicsVector2,
options?: { at?: PibblPhysicsVector2; wake?: boolean },
): void;
function applyTorque2D(body: PibblPhysicsBodyHandle2D, torque: number): void;
function setLinearVelocity2D(
body: PibblPhysicsBodyHandle2D,
velocity: PibblPhysicsVector2,
): void;
function setAngularVelocity2D(
body: PibblPhysicsBodyHandle2D,
degreesPerSecond: number,
): void;
function teleportBody2D(
body: PibblPhysicsBodyHandle2D,
pose: PibblPhysicsPose2D,
): void;
function wakeBody2D(body: PibblPhysicsBodyHandle2D): void;
function sleepBody2D(body: PibblPhysicsBodyHandle2D): void;
function disableBody2D(body: PibblPhysicsBodyHandle2D): void;
function enableBody2D(
body: PibblPhysicsBodyHandle2D,
options?: { velocity?: "zero" | "preserve" },
): void;

at is a world-space application point. Teleportation sets a pose without a sweep. Re-enabling uses zero velocity unless preserve is selected.

function raycastAny2D(
world: PibblPhysicsWorldHandle2D,
ray: PibblPhysicsRay2D,
options?: PibblPhysicsQueryOptions2D,
): boolean;
function raycastClosest2D(
world: PibblPhysicsWorldHandle2D,
ray: PibblPhysicsRay2D,
options?: PibblPhysicsQueryOptions2D,
): PibblPhysicsQueryHit2D | null;
function raycastAll2D(
world: PibblPhysicsWorldHandle2D,
ray: PibblPhysicsRay2D,
options?: PibblPhysicsQueryOptions2D,
): readonly PibblPhysicsQueryHit2D[];
function shapeCastAny2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
from: PibblPhysicsPose2D,
translation: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): boolean;
function shapeCastClosest2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
from: PibblPhysicsPose2D,
translation: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): PibblPhysicsQueryHit2D | null;
function shapeCastAll2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
from: PibblPhysicsPose2D,
translation: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): readonly PibblPhysicsQueryHit2D[];
function hasShapeOverlap2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
pose: PibblPhysicsPose2D,
options?: PibblPhysicsQueryOptions2D,
): boolean;
function findShapeOverlap2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
pose: PibblPhysicsPose2D,
options?: PibblPhysicsQueryOptions2D,
): PibblPhysicsQueryMatch2D | null;
function findAllShapeOverlaps2D(
world: PibblPhysicsWorldHandle2D,
shape: PibblPhysicsShape2D,
pose: PibblPhysicsPose2D,
options?: PibblPhysicsQueryOptions2D,
): readonly PibblPhysicsQueryMatch2D[];
function hasAabbMatch2D(
world: PibblPhysicsWorldHandle2D,
bounds: PibblPhysicsAabb2D,
options?: PibblPhysicsQueryOptions2D,
): boolean;
function findAabbMatch2D(
world: PibblPhysicsWorldHandle2D,
bounds: PibblPhysicsAabb2D,
options?: PibblPhysicsQueryOptions2D,
): PibblPhysicsQueryMatch2D | null;
function findAllAabbMatches2D(
world: PibblPhysicsWorldHandle2D,
bounds: PibblPhysicsAabb2D,
options?: PibblPhysicsQueryOptions2D,
): readonly PibblPhysicsQueryMatch2D[];
function hasPointMatch2D(
world: PibblPhysicsWorldHandle2D,
point: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): boolean;
function findPointMatch2D(
world: PibblPhysicsWorldHandle2D,
point: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): PibblPhysicsQueryMatch2D | null;
function findAllPointMatches2D(
world: PibblPhysicsWorldHandle2D,
point: PibblPhysicsVector2,
options?: PibblPhysicsQueryOptions2D,
): readonly PibblPhysicsQueryMatch2D[];
function toPhysicsPoint2D(
world: PibblPhysicsWorldHandle2D,
point: PibblPhysicsVector2,
): PibblPhysicsVector2;
function fromPhysicsPoint2D(
world: PibblPhysicsWorldHandle2D,
point: PibblPhysicsVector2,
): PibblPhysicsVector2;
function inspectPhysics2D(
world: PibblPhysicsWorldHandle2D,
): PibblPhysicsInspection2D;
function inspectPhysics2D(
body: PibblPhysicsBodyHandle2D,
): PibblPhysicsBodyInspection2D | undefined;

Queries read the committed world and accept filtering options. Each named operation returns a fixed boolean, nullable record, or readonly array contract. The point helpers cross between root-logical and simulation coordinates. inspectPhysics2D(world) returns an immutable JSON-safe world observation without advancing, restoring, or scheduling. inspectPhysics2D(body) returns only that body’s observation; an unbound or stale handle returns undefined.

circleShape2D, ellipseShape2D, boxShape2D, roundedBoxShape2D, capsuleShape2D, arcShape2D, wedgeShape2D, segmentShape2D, chainShape2D, and polygonShape2D each create an immutable PibblPhysicsShape2D from their corresponding option object.

function boundsOfShape2D(shape: PibblPhysicsShape2D): PibblPhysicsAabb2D;
function massProperties2D(
shape: PibblPhysicsShape2D,
density?: number,
): PibblPhysicsMassProperties2D;
function transformShape2D(
shape: PibblPhysicsShape2D,
transform: PibblPhysicsTransform2D,
): PibblPhysicsShape2D;
function containsPoint2D(
shape: PibblPhysicsShape2D,
pose: PibblPhysicsPose2D,
point: PibblPhysicsVector2,
): boolean;
function distanceBetweenShapes2D(
first: PibblPhysicsShape2D,
firstPose: PibblPhysicsPose2D,
second: PibblPhysicsShape2D,
secondPose: PibblPhysicsPose2D,
): PibblPhysicsDistance2D;
function overlapShapes2D(
first: PibblPhysicsShape2D,
firstPose: PibblPhysicsPose2D,
second: PibblPhysicsShape2D,
secondPose: PibblPhysicsPose2D,
): boolean;
function contactBetweenShapes2D(
first: PibblPhysicsShape2D,
firstPose: PibblPhysicsPose2D,
second: PibblPhysicsShape2D,
secondPose: PibblPhysicsPose2D,
): PibblPhysicsShapeContact2D | null;
function raycastShape2D(
shape: PibblPhysicsShape2D,
pose: PibblPhysicsPose2D,
ray: PibblPhysicsRay2D,
options?: { includeInitialOverlap?: boolean },
): PibblPhysicsShapeHit2D | null;
function shapeCastAgainstShape2D(
moving: PibblPhysicsShape2D,
from: PibblPhysicsPose2D,
translation: PibblPhysicsVector2,
target: PibblPhysicsShape2D,
targetPose: PibblPhysicsPose2D,
options?: { includeInitialOverlap?: boolean },
): PibblPhysicsShapeHit2D | null;

These deterministic functions need neither a mounted world nor Pibbl core. transformShape2D returns a new descriptor. Contact normals point from the second shape toward the first.

Query Boolean One result or null Readonly result array
raycast raycastAny2D raycastClosest2D raycastAll2D
shapeCast shapeCastAny2D shapeCastClosest2D shapeCastAll2D
overlapShape hasShapeOverlap2D findShapeOverlap2D findAllShapeOverlaps2D
queryAabb hasAabbMatch2D findAabbMatch2D findAllAabbMatches2D
queryPoint hasPointMatch2D findPointMatch2D findAllPointMatches2D

All functions accept PibblPhysicsQueryOptions2D for sensor policy, collision filtering, and exclusions. There is no mode option. Boolean queries stop at the first match. Cast results sort by time of impact, distance, then collider index and generation. Overlap, bounds, and point results sort by collider index and generation; find… returns the first in that order, not a nearest match. Returned result arrays are frozen; no matches produce false, null, or an empty array according to the named operation.

Creates an immutable arc collision shape without initializing a physics world.

arcShape2D: (input: Readonly<{ center?: PibblPhysicsVector2; radius: number; startAngleRadians: number; endAngleRadians: number; counterclockwise?: boolean; thickness: number; }>) => PibblPhysicsShape2D

Related API: arcShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

  • input — Arc center, radius, angular endpoints in radians, sweep direction, and thickness. See PibblPhysicsVector2 .

An immutable thick-arc collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:232

Computes axis-aligned bounds for an immutable shape at an optional pose.

boundsOfShape2D: (shape: PibblPhysicsShape2D, pose?: PibblPhysicsPose2D) => PibblPhysicsAabb2D

Related API: boundsOfShape2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsAabb2D.

Axis-aligned bounds of the posed shape. See PibblPhysicsAabb2D.

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsAabb2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:391

Creates an immutable box collision shape without initializing a physics world.

boxShape2D: (input: Readonly<{ width: number; height: number; center?: PibblPhysicsVector2; }>) => PibblPhysicsShape2D

Related API: boxShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable box collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:107

Creates an immutable capsule collision shape without initializing a physics world.

capsuleShape2D: (input: Readonly<{ start: PibblPhysicsVector2; end: PibblPhysicsVector2; radius: number; }>) => PibblPhysicsShape2D

Related API: capsuleShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable capsule collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:199

Creates an immutable chain collision shape without initializing a physics world.

chainShape2D: (input: Readonly<{ points: readonly PibblPhysicsVector2[]; closed?: boolean; radius?: number; }>) => PibblPhysicsShape2D

Related API: chainShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

  • input — Ordered chain points, closure policy, and optional radius. See PibblPhysicsVector2 .

An immutable chain collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:337

Creates an immutable circle collision shape without initializing a physics world.

circleShape2D: (input: Readonly<{ radius: number; center?: PibblPhysicsVector2; }>) => PibblPhysicsShape2D

Related API: circleShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable circle collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:49

Creates an immutable ellipse collision shape without initializing a physics world.

ellipseShape2D: (input: Readonly<{ radiusX: number; radiusY: number; center?: PibblPhysicsVector2; rotationDegrees?: number; }>) => PibblPhysicsShape2D

Related API: ellipseShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable ellipse collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:74

Computes shape area, centroid, mass, and rotational inertia at the requested density.

massProperties2D: (shape: PibblPhysicsShape2D, options?: Readonly<{ density?: number; }>) => PibblPhysicsMassProperties2D

Related API: massProperties2D, PibblPhysicsShape2D, PibblPhysicsMassProperties2D.

  • shape — Shape whose mass properties are needed. See PibblPhysicsShape2D.

  • options — Optional material density.

Mass, center of mass, and inertia for the shape. See PibblPhysicsMassProperties2D.

PibblPhysicsShape2D

PibblPhysicsMassProperties2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:411

Creates an immutable polygon collision shape without initializing a physics world.

polygonShape2D: (input: Readonly<{ points: readonly PibblPhysicsVector2[]; }>) => PibblPhysicsShape2D

Related API: polygonShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable polygon collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:363

Creates an immutable rounded box collision shape without initializing a physics world.

roundedBoxShape2D: (input: Readonly<{ width: number; height: number; radius: number | readonly [topLeft: number, topRight: number, bottomRight: number, bottomLeft: number]; center?: PibblPhysicsVector2; }>) => PibblPhysicsShape2D

Related API: roundedBoxShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable rounded-box collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:137

Creates an immutable segment collision shape without initializing a physics world.

segmentShape2D: (input: Readonly<{ start: PibblPhysicsVector2; end: PibblPhysicsVector2; }>) => PibblPhysicsShape2D

Related API: segmentShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

An immutable line-segment collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:313

Returns independent shape geometry transformed by a rigid 2D pose.

transformShape2D: (shape: PibblPhysicsShape2D, transform: PibblPhysicsTransform2D) => PibblPhysicsShape2D

Related API: transformShape2D, PibblPhysicsShape2D, PibblPhysicsTransform2D.

A shape containing the transformed geometry. See PibblPhysicsShape2D.

PibblPhysicsShape2D

PibblPhysicsTransform2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:446

Creates an immutable wedge collision shape without initializing a physics world.

wedgeShape2D: (input: Readonly<{ center?: PibblPhysicsVector2; radius: number; startAngleRadians: number; endAngleRadians: number; counterclockwise?: boolean; }>) => PibblPhysicsShape2D

Related API: wedgeShape2D, PibblPhysicsVector2, PibblPhysicsShape2D.

  • input — Wedge center, radius, angular endpoints in radians, and sweep direction. See PibblPhysicsVector2 .

An immutable wedge collision shape. See PibblPhysicsShape2D.

PibblPhysicsVector2

PibblPhysicsShape2D

View source — packages/core/src/features/physics/lib/2d/shapes.ts:263

Tests whether a point lies within a posed shape without creating a physics world.

containsPoint2D: (shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, point: PibblPhysicsVector2) => boolean

Related API: containsPoint2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsVector2.

Whether the posed shape contains the point.

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/2d-geometry.ts:209

Computes signed separation and witness geometry between two posed shapes.

distanceBetweenShapes2D: (first: PibblPhysicsShape2D, firstPose: PibblPhysicsPose2D, second: PibblPhysicsShape2D, secondPose: PibblPhysicsPose2D) => PibblPhysicsDistance2D

Related API: distanceBetweenShapes2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsDistance2D.

Distance and closest-point information for the two posed shapes. See PibblPhysicsDistance2D .

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsDistance2D

View source — packages/core/src/features/physics/2d-geometry.ts:231

Tests whether two posed shapes overlap without creating a physics world.

overlapShapes2D: (first: PibblPhysicsShape2D, firstPose: PibblPhysicsPose2D, second: PibblPhysicsShape2D, secondPose: PibblPhysicsPose2D) => boolean

Related API: overlapShapes2D, PibblPhysicsShape2D, PibblPhysicsPose2D.

Whether the two posed shapes overlap.

PibblPhysicsShape2D

PibblPhysicsPose2D

View source — packages/core/src/features/physics/2d-geometry.ts:252

Computes contact geometry for two posed shapes, or null when they do not contact.

contactBetweenShapes2D: (first: PibblPhysicsShape2D, firstPose: PibblPhysicsPose2D, second: PibblPhysicsShape2D, secondPose: PibblPhysicsPose2D) => PibblPhysicsShapeContact2D | null

Related API: contactBetweenShapes2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsShapeContact2D.

Contact information, or null when the shapes do not contact. See PibblPhysicsShapeContact2D .

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsShapeContact2D

View source — packages/core/src/features/physics/2d-geometry.ts:275

Casts a ray against one posed shape and returns its first hit or null.

raycastShape2D: (shape: PibblPhysicsShape2D, publicPose: PibblPhysicsPose2D, ray: PibblPhysicsRay2D, options?: Readonly<{ includeInitialOverlap?: boolean; }>) => PibblPhysicsShapeHit2D | null

Related API: raycastShape2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsRay2D, PibblPhysicsShapeHit2D.

The first shape hit, or null when there is no hit. See PibblPhysicsShapeHit2D.

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsRay2D

PibblPhysicsShapeHit2D

View source — packages/core/src/features/physics/lib/2d/collision/casts.ts:68

Sweeps a posed shape along a translation against another posed shape and returns a hit or null.

shapeCastAgainstShape2D: (moving: PibblPhysicsShape2D, publicFrom: PibblPhysicsPose2D, publicTranslation: PibblPhysicsVector2, target: PibblPhysicsShape2D, publicTargetPose: PibblPhysicsPose2D, options?: Readonly<{ includeInitialOverlap?: boolean; }>) => PibblPhysicsShapeHit2D | null

Related API: shapeCastAgainstShape2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsVector2, PibblPhysicsShapeHit2D.

The first sweep hit, or null when there is no hit. See PibblPhysicsShapeHit2D.

PibblPhysicsShape2D

PibblPhysicsPose2D

PibblPhysicsVector2

PibblPhysicsShapeHit2D

View source — packages/core/src/features/physics/lib/2d/collision/casts.ts:150

Owns one transparent, component-scoped 2D physics world.

PhysicsWorld2D: PibblComponent<PibblPhysicsWorld2DProps>

Related API: PhysicsWorld2D, PibblComponent, PibblPhysicsWorld2DProps.

PibblComponent

PibblPhysicsWorld2DProps

View source — packages/core/src/features/physics/lib/2d/runtime/world-component.ts:48

Draws an immutable physics shape as a Canvas primitive with optional body or collider attachment.

PhysicsShape2D: PibblPrimitiveComponent<PhysicsShape2DProps, PrimitiveInput<PhysicsShape2DProps, PhysicsShape2DStyle>>

Related API: PhysicsShape2D, PibblPrimitiveComponent, PhysicsShape2DProps, PrimitiveInput, PhysicsShape2DStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

PhysicsShape2DProps

PhysicsShape2DStyle

View source — packages/core/src/features/physics/lib/2d/canvas/components.ts:79

Draws a capsule between two endpoints with optional physics attachment.

Capsule2D: PibblPrimitiveComponent<Capsule2DProps, PrimitiveInput<Capsule2DProps, Capsule2DStyle>>

Related API: Capsule2D, PibblPrimitiveComponent, Capsule2DProps, PrimitiveInput, Capsule2DStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

Capsule2DProps

Capsule2DStyle

View source — packages/core/src/features/physics/lib/2d/canvas/components.ts:96

Draws a line segment with optional physics attachment.

Segment2D: PibblPrimitiveComponent<Segment2DProps, PrimitiveInput<Segment2DProps, Segment2DStyle>>

Related API: Segment2D, PibblPrimitiveComponent, Segment2DProps, PrimitiveInput, Segment2DStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

Segment2DProps

Segment2DStyle

View source — packages/core/src/features/physics/lib/2d/canvas/components.ts:118

Draws an open or closed point chain with optional physics attachment.

Chain2D: PibblPrimitiveComponent<Chain2DProps, PrimitiveInput<Chain2DProps, Chain2DStyle>>

Related API: Chain2D, PibblPrimitiveComponent, Chain2DProps, PrimitiveInput, Chain2DStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

Chain2DProps

Chain2DStyle

View source — packages/core/src/features/physics/lib/2d/canvas/components.ts:139

Creates a declarative collider attachment for a primitive within a physics body.

collider2D: (options?: PibblPhysicsColliderConfiguration2D) => PibblPhysicsColliderAttachment2D

Related API: collider2D, PibblPhysicsColliderConfiguration2D, PibblPhysicsColliderAttachment2D.

A collider attachment for a supported primitive’s physics prop. See PibblPhysicsColliderAttachment2D .

PibblPhysicsColliderConfiguration2D

PibblPhysicsColliderAttachment2D

View source — packages/core/src/features/physics/lib/2d/runtime/descriptors.ts:285

Creates a declarative body attachment whose motion is advanced by the physics solver.

dynamicBody2D: (options?: PibblPhysicsDynamicBody2DOptions) => PibblPhysicsBodyAttachment2D

Related API: dynamicBody2D, PibblPhysicsDynamicBody2DOptions, PibblPhysicsBodyAttachment2D.

A dynamic-body attachment for a supported primitive’s physics prop. See PibblPhysicsBodyAttachment2D .

PibblPhysicsDynamicBody2DOptions

PibblPhysicsBodyAttachment2D

View source — packages/core/src/features/physics/lib/2d/runtime/descriptors.ts:162

Creates a declarative body attachment driven by application-supplied target signals.

kinematicBody2D: (options?: PibblPhysicsKinematicBody2DOptions) => PibblPhysicsBodyAttachment2D

Related API: kinematicBody2D, PibblPhysicsKinematicBody2DOptions, PibblPhysicsBodyAttachment2D.

A kinematic-body attachment for a supported primitive’s physics prop. See PibblPhysicsBodyAttachment2D .

PibblPhysicsKinematicBody2DOptions

PibblPhysicsBodyAttachment2D

View source — packages/core/src/features/physics/lib/2d/runtime/descriptors.ts:245

Creates a declarative body attachment that remains fixed in the simulation.

staticBody2D: (options?: PibblPhysicsStaticBody2DOptions) => PibblPhysicsBodyAttachment2D

Related API: staticBody2D, PibblPhysicsStaticBody2DOptions, PibblPhysicsBodyAttachment2D.

A static-body attachment for a supported primitive’s physics prop. See PibblPhysicsBodyAttachment2D .

PibblPhysicsStaticBody2DOptions

PibblPhysicsBodyAttachment2D

View source — packages/core/src/features/physics/lib/2d/runtime/descriptors.ts:220

Adds physics-attachment support to a custom primitive using its resolved-style shape callback.

withPhysicsShape2D: <P, I, ResolvedStyle>(component: PibblPrimitiveComponent<P, I>, options: Readonly<{ resolveShape(style: Readonly<ResolvedStyle>): PibblPhysicsShape2D; }>) => PibblPrimitiveComponent<P & PibblPhysicsPrimitiveProps2D, I & { readonly physics?: PibblPhysicsAttachment2D; }>

Related API: withPhysicsShape2D, ResolvedStyle, PibblPrimitiveComponent, PibblPhysicsShape2D, PibblPhysicsPrimitiveProps2D, PibblPhysicsAttachment2D.

A derived primitive accepting the public physics attachment prop. See PibblPrimitiveComponent , PibblPhysicsPrimitiveProps2D , PibblPhysicsAttachment2D .

PibblPrimitiveComponent

PibblPhysicsShape2D

PibblPhysicsPrimitiveProps2D

PibblPhysicsAttachment2D

View source — packages/core/src/features/physics/lib/2d/canvas/custom.ts:30

Returns one stable, component-owned 2D body endpoint for this hook slot.

pibblPhysicsBody2D: () => PibblPhysicsBodyHandle2D

Related API: pibblPhysicsBody2D, PibblPhysicsBodyHandle2D.

A stable body handle that can be attached to a physics body. See PibblPhysicsBodyHandle2D .

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:77

Returns the nearest 2D physics world while a descendant is evaluating.

pibblPhysicsWorld2D: () => PibblPhysicsWorldHandle2D

Related API: pibblPhysicsWorld2D, PibblPhysicsWorldHandle2D.

A stable world handle that can be attached to a physics world. See PibblPhysicsWorldHandle2D .

PibblPhysicsWorldHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/world-component.ts:58

Queues a force on a body, optionally at a world point and with wake-up control.

applyForce2D: (body: PibblPhysicsBodyHandle2D, force: PibblPhysicsVector2, options?: Readonly<{ at?: PibblPhysicsVector2; wake?: boolean; }>) => void

Related API: applyForce2D, PibblPhysicsBodyHandle2D, PibblPhysicsVector2.

PibblPhysicsBodyHandle2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:98

Queues an instantaneous momentum change, optionally at a world point and with wake-up control.

applyImpulse2D: (body: PibblPhysicsBodyHandle2D, impulse: PibblPhysicsVector2, options?: Readonly<{ at?: PibblPhysicsVector2; wake?: boolean; }>) => void

Related API: applyImpulse2D, PibblPhysicsBodyHandle2D, PibblPhysicsVector2.

PibblPhysicsBodyHandle2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:130

Queues torque on a dynamic body through the shared scheduler.

applyTorque2D: (body: PibblPhysicsBodyHandle2D, torque: number) => void

Related API: applyTorque2D, PibblPhysicsBodyHandle2D.

  • body — Body receiving the torque. See PibblPhysicsBodyHandle2D.

  • torque — Torque to apply in the world’s public units.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:159

Queues removal of a body’s active participation in the simulation.

disableBody2D: (body: PibblPhysicsBodyHandle2D) => void

Related API: disableBody2D, PibblPhysicsBodyHandle2D.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:290

Queues re-enabling a body with the requested velocity-preservation policy.

enableBody2D: (body: PibblPhysicsBodyHandle2D, options?: Readonly<{ velocity?: "zero" | "preserve"; }>) => void

Related API: enableBody2D, PibblPhysicsBodyHandle2D.

  • body — Body to re-enable. See PibblPhysicsBodyHandle2D.

  • options — Whether to zero or preserve velocity when enabling.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:272

Queues a body’s angular velocity in degrees per second.

setAngularVelocity2D: (body: PibblPhysicsBodyHandle2D, degreesPerSecond: number) => void

Related API: setAngularVelocity2D, PibblPhysicsBodyHandle2D.

  • body — Body whose angular velocity changes. See PibblPhysicsBodyHandle2D.

  • degreesPerSecond — Angular speed in degrees per second.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:201

Queues a body’s linear velocity in physics units per second.

setLinearVelocity2D: (body: PibblPhysicsBodyHandle2D, velocity: PibblPhysicsVector2) => void

Related API: setLinearVelocity2D, PibblPhysicsBodyHandle2D, PibblPhysicsVector2.

PibblPhysicsBodyHandle2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:180

Queues a request to put a body to sleep.

sleepBody2D: (body: PibblPhysicsBodyHandle2D) => void

Related API: sleepBody2D, PibblPhysicsBodyHandle2D.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:260

Queues an immediate pose change for a body at the next admitted simulation command phase.

teleportBody2D: (body: PibblPhysicsBodyHandle2D, pose: PibblPhysicsPose2D) => void

Related API: teleportBody2D, PibblPhysicsBodyHandle2D, PibblPhysicsPose2D.

PibblPhysicsBodyHandle2D

PibblPhysicsPose2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:225

Queues a request to wake a sleeping body.

wakeBody2D: (body: PibblPhysicsBodyHandle2D) => void

Related API: wakeBody2D, PibblPhysicsBodyHandle2D.

PibblPhysicsBodyHandle2D

View source — packages/core/src/features/physics/lib/2d/runtime/body-handle.ts:249

Tests whether the committed world has any ray match, stopping at the first match.

raycastAny2D: (world: PibblPhysicsWorldHandle2D, ray: PibblPhysicsRay2D, options?: PibblPhysicsQueryOptions2D) => boolean

Related API: raycastAny2D, PibblPhysicsWorldHandle2D, PibblPhysicsRay2D, PibblPhysicsQueryOptions2D.

Whether a matching collider exists.

View source — packages/core/src/features/physics/2d.ts:88

Returns the first ray result ordered by time of impact, distance, then collider identity, or null.

raycastClosest2D: (world: PibblPhysicsWorldHandle2D, ray: PibblPhysicsRay2D, options?: PibblPhysicsQueryOptions2D) => PibblPhysicsQueryHit2D | null

Related API: raycastClosest2D, PibblPhysicsWorldHandle2D, PibblPhysicsRay2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryHit2D.

One result or null. See PibblPhysicsQueryHit2D.

View source — packages/core/src/features/physics/2d.ts:104

Returns all ray results ordered by time of impact, distance, then collider identity as a frozen array.

raycastAll2D: (world: PibblPhysicsWorldHandle2D, ray: PibblPhysicsRay2D, options?: PibblPhysicsQueryOptions2D) => readonly PibblPhysicsQueryHit2D[]

Related API: raycastAll2D, PibblPhysicsWorldHandle2D, PibblPhysicsRay2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryHit2D.

Frozen results, empty when no collider matches. See PibblPhysicsQueryHit2D.

View source — packages/core/src/features/physics/2d.ts:120

Tests whether the committed world has any shape sweep match, stopping at the first match.

shapeCastAny2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, from: PibblPhysicsPose2D, translation: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => boolean

Related API: shapeCastAny2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D.

Whether a matching collider exists.

View source — packages/core/src/features/physics/2d.ts:138

Returns the first shape sweep result ordered by time of impact, distance, then collider identity, or null.

shapeCastClosest2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, from: PibblPhysicsPose2D, translation: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => PibblPhysicsQueryHit2D | null

Related API: shapeCastClosest2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D, PibblPhysicsQueryHit2D.

One result or null. See PibblPhysicsQueryHit2D.

View source — packages/core/src/features/physics/2d.ts:158

Returns all shape sweep results ordered by time of impact, distance, then collider identity as a frozen array.

shapeCastAll2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, from: PibblPhysicsPose2D, translation: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => readonly PibblPhysicsQueryHit2D[]

Related API: shapeCastAll2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D, PibblPhysicsQueryHit2D.

Frozen results, empty when no collider matches. See PibblPhysicsQueryHit2D.

View source — packages/core/src/features/physics/2d.ts:178

Tests whether the committed world has any shape overlap match, stopping at the first match.

hasShapeOverlap2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, options?: PibblPhysicsQueryOptions2D) => boolean

Related API: hasShapeOverlap2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsQueryOptions2D.

Whether a matching collider exists.

View source — packages/core/src/features/physics/2d.ts:197

Returns the first shape overlap result ordered by collider index, then generation, or null.

findShapeOverlap2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, options?: PibblPhysicsQueryOptions2D) => PibblPhysicsQueryMatch2D | null

Related API: findShapeOverlap2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

One result or null. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:215

Returns all shape overlap results ordered by collider index, then generation as a frozen array.

findAllShapeOverlaps2D: (world: PibblPhysicsWorldHandle2D, shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, options?: PibblPhysicsQueryOptions2D) => readonly PibblPhysicsQueryMatch2D[]

Related API: findAllShapeOverlaps2D, PibblPhysicsWorldHandle2D, PibblPhysicsShape2D, PibblPhysicsPose2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

Frozen results, empty when no collider matches. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:233

Tests whether the committed world has any bounds intersection match, stopping at the first match.

hasAabbMatch2D: (world: PibblPhysicsWorldHandle2D, bounds: PibblPhysicsAabb2D, options?: PibblPhysicsQueryOptions2D) => boolean

Related API: hasAabbMatch2D, PibblPhysicsWorldHandle2D, PibblPhysicsAabb2D, PibblPhysicsQueryOptions2D.

Whether a matching collider exists.

View source — packages/core/src/features/physics/2d.ts:250

Returns the first bounds intersection result ordered by collider index, then generation, or null.

findAabbMatch2D: (world: PibblPhysicsWorldHandle2D, bounds: PibblPhysicsAabb2D, options?: PibblPhysicsQueryOptions2D) => PibblPhysicsQueryMatch2D | null

Related API: findAabbMatch2D, PibblPhysicsWorldHandle2D, PibblPhysicsAabb2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

One result or null. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:266

Returns all bounds intersection results ordered by collider index, then generation as a frozen array.

findAllAabbMatches2D: (world: PibblPhysicsWorldHandle2D, bounds: PibblPhysicsAabb2D, options?: PibblPhysicsQueryOptions2D) => readonly PibblPhysicsQueryMatch2D[]

Related API: findAllAabbMatches2D, PibblPhysicsWorldHandle2D, PibblPhysicsAabb2D, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

Frozen results, empty when no collider matches. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:282

Tests whether the committed world has any point containment match, stopping at the first match.

hasPointMatch2D: (world: PibblPhysicsWorldHandle2D, point: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => boolean

Related API: hasPointMatch2D, PibblPhysicsWorldHandle2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D.

Whether a matching collider exists.

View source — packages/core/src/features/physics/2d.ts:298

Returns the first point containment result ordered by collider index, then generation, or null.

findPointMatch2D: (world: PibblPhysicsWorldHandle2D, point: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => PibblPhysicsQueryMatch2D | null

Related API: findPointMatch2D, PibblPhysicsWorldHandle2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

One result or null. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:314

Returns all point containment results ordered by collider index, then generation as a frozen array.

findAllPointMatches2D: (world: PibblPhysicsWorldHandle2D, point: PibblPhysicsVector2, options?: PibblPhysicsQueryOptions2D) => readonly PibblPhysicsQueryMatch2D[]

Related API: findAllPointMatches2D, PibblPhysicsWorldHandle2D, PibblPhysicsVector2, PibblPhysicsQueryOptions2D, PibblPhysicsQueryMatch2D.

Frozen results, empty when no collider matches. See PibblPhysicsQueryMatch2D.

View source — packages/core/src/features/physics/2d.ts:330

Converts root-logical pointer coordinates to this world’s simulation space.

toPhysicsPoint2D: (world: PibblPhysicsWorldHandle2D, point: PibblPhysicsVector2) => PibblPhysicsVector2

Related API: toPhysicsPoint2D, PibblPhysicsWorldHandle2D, PibblPhysicsVector2.

The equivalent point in this world’s local simulation space. See PibblPhysicsVector2 .

PibblPhysicsWorldHandle2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/2d.ts:350

Converts a simulation-space point to root-logical Canvas coordinates.

fromPhysicsPoint2D: (world: PibblPhysicsWorldHandle2D, point: PibblPhysicsVector2) => PibblPhysicsVector2

Related API: fromPhysicsPoint2D, PibblPhysicsWorldHandle2D, PibblPhysicsVector2.

The equivalent point in public Canvas coordinates. See PibblPhysicsVector2.

PibblPhysicsWorldHandle2D

PibblPhysicsVector2

View source — packages/core/src/features/physics/2d.ts:368

Returns immutable JSON-safe observations without advancing the simulation. See PibblPhysicsWorldHandle2D. Returns the immutable observation for this currently bound body, if any. See PibblPhysicsBodyHandle2D. Returns a diagnostic snapshot of a live world or body, or undefined when unavailable.

inspectPhysics2D: { (world: PibblPhysicsWorldHandle2D): PibblPhysicsInspection2D; (body: PibblPhysicsBodyHandle2D): PibblPhysicsBodyInspection2D | undefined; }

Related API: inspectPhysics2D, PibblPhysicsWorldHandle2D, PibblPhysicsInspection2D, PibblPhysicsBodyHandle2D, PibblPhysicsBodyInspection2D.

Current world simulation and ownership diagnostics.

Current body diagnostics, or undefined when the handle has no live body.

The corresponding diagnostics, or undefined for an unmounted body.

PibblPhysicsWorldHandle2D

PibblPhysicsBodyHandle2D

PibblPhysicsInspection2D

PibblPhysicsBodyInspection2D

View source — packages/core/src/features/physics/2d.ts:388

Read-only authoritative bounds, mass centers and contact normals; no hit targets.

PhysicsDebug2D: PibblPrimitiveComponent<PibblPhysicsDebug2DProps, PrimitiveInput<PibblPhysicsDebug2DProps, SystemStyle>>

Related API: PhysicsDebug2D, PibblPrimitiveComponent, PibblPhysicsDebug2DProps, PrimitiveInput, SystemStyle.

  • props — Authored component inputs, supplied through JSX or createElement. See the linked props and style types.

When called directly; Pibbl mounts this component through JSX or createElement.

PibblPhysicsDebug2DProps

View source — packages/core/src/features/physics/lib/2d/canvas/debug.ts:28

Read the Physics and geometry companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.