Skip to content

API Interface PhysicsWorld2DBackend

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

Interface: PhysicsWorld2DBackend

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

One World's simulation in a backend.

Extends

Properties

gravity

gravity: PhysicsVec2;

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

Inherited from

PhysicsWorldBackend.gravity

Methods

castCollider()

castCollider(
   collider, 
   direction, 
   maxDistance, 
   groups, 
   exclude
): 
  | {
  body: BackendBody<Dim2> | null;
  collider: number;
}
  | null;

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

Sweep collider (ignoring sensors, itself and exclude); the hit collider's body, if any.

Parameters

collider

BackendCollider<Dim2>

direction

PhysicsVec2

maxDistance

number

groups

number

exclude

BackendBody<Dim2> | null

Returns

| { body: BackendBody<Dim2> | null; collider: number; } | null

Inherited from

PhysicsWorldBackend.castCollider


castShape()

castShape(
   shape, 
   position, 
   rotation, 
   direction, 
   maxDistance, 
   groups?
): RayHit<Dim2> | null;

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

Parameters

shape

QueryShape2D

position

PhysicsVec2

rotation

number

direction

PhysicsVec2

maxDistance

number

groups?

number

Returns

RayHit<Dim2> | null

Inherited from

PhysicsWorldBackend.castShape


contactImpulses()

contactImpulses(collider): object[];

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

The impulses the last step's contacts gave collider's body, each where it acted when known.

Parameters

collider

BackendCollider<Dim2>

Returns

object[]

Inherited from

PhysicsWorldBackend.contactImpulses


createBody()

createBody(
   type, 
   pose, 
   settings
): BackendBody<Dim2>;

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

Parameters

type

BodyType

pose

Pose<Dim2>

settings

BodySettings | null

Returns

BackendBody<Dim2>

Inherited from

PhysicsWorldBackend.createBody


createCharacter()

createCharacter(): BackendCharacter<Dim2>;

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

Returns

BackendCharacter<Dim2>

Inherited from

PhysicsWorldBackend.createCharacter


createCollider()

createCollider(desc): BackendCollider<Dim2>;

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

Parameters

desc

ColliderDesc<Dim2>

Returns

BackendCollider<Dim2>

Inherited from

PhysicsWorldBackend.createCollider


createJoint()

createJoint(desc): BackendJoint;

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

Parameters

desc

JointDesc<Dim2>

Returns

BackendJoint

Inherited from

PhysicsWorldBackend.createJoint


drainCollisionEvents()

drainCollisionEvents(fn): void;

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

Contact pairs that started or stopped since the last drain (triggers included).

Parameters

fn

(collider1, collider2, started) => void

Returns

void

Inherited from

PhysicsWorldBackend.drainCollisionEvents


dropThrough()

dropThrough(body): void;

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

Capability oneWayPlatforms (ADR 0439): let body (a rigid body, or a character controller's own body) pass down through every one-way collider it stands on or overlaps now. Each such pair stays dropping until the body's top is below the collider's top, the two no longer touch, or 0.5 s have passed; one-way colliders it reaches later, and solid ones, still hold it. A backend without the capability does nothing.

Parameters

body

BackendBody<Dim2>

Returns

void


free()

free(): void;

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

Returns

void

Inherited from

PhysicsWorldBackend.free


linkVoxels()?

linkVoxels?(
   a, 
   b, 
   shift
): void;

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

Capability voxelColliders (ADR 0444): make two voxel colliders whose cells meet or overlap treat the faces between their cells as inside. Called once per pair, when the later of the two is made; setVoxels keeps it so. shift is where b's cell (0, 0) is from a's, in cells.

Parameters

a

BackendCollider<Dim2>

b

BackendCollider<Dim2>

shift

PhysicsVec2

Returns

void


overlap()

overlap(
   shape, 
   position, 
   rotation, 
   groups?
): number[];

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

Parameters

shape

QueryShape2D

position

PhysicsVec2

rotation

number

groups?

number

Returns

number[]

Inherited from

PhysicsWorldBackend.overlap


overlapPoint()

overlapPoint(point, groups?): number[];

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

Parameters

point

PhysicsVec2

groups?

number

Returns

number[]

Inherited from

PhysicsWorldBackend.overlapPoint


raycast()

raycast(
   origin, 
   direction, 
   maxDistance, 
   groups?
): RayHit<Dim2> | null;

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

direction is unit length; groups filters by layer (undefined: every collider).

Parameters

origin

PhysicsVec2

direction

PhysicsVec2

maxDistance

number

groups?

number

Returns

RayHit<Dim2> | null

Inherited from

PhysicsWorldBackend.raycast


removeBody()

removeBody(body): void;

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

Parameters

body

BackendBody<Dim2>

Returns

void

Inherited from

PhysicsWorldBackend.removeBody


removeCharacter()

removeCharacter(character): void;

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

Parameters

character

BackendCharacter<Dim2>

Returns

void

Inherited from

PhysicsWorldBackend.removeCharacter


removeCollider()

removeCollider(collider): void;

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

Parameters

collider

BackendCollider<Dim2>

Returns

void

Inherited from

PhysicsWorldBackend.removeCollider


removeJoint()

removeJoint(joint): void;

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

Parameters

joint

BackendJoint

Returns

void

Inherited from

PhysicsWorldBackend.removeJoint


setVoxels()?

setVoxels?(
   collider, 
   changes, 
   neighbours
): void;

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

Capability voxelColliders (ADR 0444): fill or empty cells of a voxels collider in place, then pass each change on to neighbours (voxel colliders whose cells meet or overlap its own), so bodies sliding from one onto another don't catch on the faces between them.

Parameters

collider

BackendCollider<Dim2>

changes

readonly VoxelChange2D[]

neighbours

readonly VoxelLink2D[]

Returns

void


step()

step(dt): void;

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

Parameters

dt

number

Returns

void

Inherited from

PhysicsWorldBackend.step

Clone this wiki locally