Optionalgravity: Vec2Initial gravity vector (default (0, 0)).
Optionalbroadphase: BroadphaseBroadphase algorithm to use.
Read-only list of all active collision/fluid arbiters.
Read-only list of all Body objects directly in this space.
The broadphase algorithm currently in use (SWEEP_AND_PRUNE or DYNAMIC_AABB_TREE).
Read-only list of all Compound objects in this space.
Read-only list of all Constraint objects in this space.
Cumulative time simulated (sum of all deltaTime values passed to step()).
Read-only list of all event listeners registered to this space.
Read-only list of bodies that are awake and actively simulated.
Read-only list of active (awake) constraints.
If true, contact points are sorted for determinism. Default: true.
Number of step() calls made so far.
Arbitrary user data attached to this Space.
The static world body that acts as an immovable anchor for constraints.
Return all bodies that have at least one shape overlapping the given AABB.
The axis-aligned bounding box to test against.
If true, only shapes fully contained within the AABB count.
If true, exact shape geometry is tested; otherwise only AABBs are compared.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: BodyList | nullOptional existing BodyList to accumulate results into.
A BodyList of matching bodies.
Return all bodies in the space that overlap with any shape attached to body.
Equivalent to calling bodiesInShape for each of body's shapes and merging results.
The body whose shapes are used as the query region.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: BodyList | nullOptional existing BodyList to accumulate results into.
A BodyList of overlapping bodies.
Return all bodies that have at least one shape overlapping a query circle.
World-space centre of the query circle.
Radius of the query circle; must be strictly positive and not NaN.
If true, only shapes fully contained within the circle count.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: BodyList | nullOptional existing BodyList to accumulate results into.
A BodyList of matching bodies.
Return all bodies in the space that have at least one shape overlapping shape.
The query shape; must be attached to a Body.
If true, only shapes fully contained within shape count.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: BodyList | nullOptional existing BodyList to accumulate results into.
A BodyList of overlapping bodies.
Return all bodies that have at least one shape containing the given world-space point.
The world-space point to test.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: BodyList | nullOptional existing BodyList to accumulate results into.
A BodyList of matching bodies.
Sweep shape along its current velocity for deltaTime seconds and return the first hit.
The shape to sweep; must belong to a Body.
Duration of the sweep; must be non-negative.
If true, other body velocities are considered during the sweep.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
The first RayResult hit, or null if nothing was struck.
Sweep shape along its current velocity for deltaTime seconds and return all hits.
The shape to sweep; must belong to a Body.
Duration of the sweep; must be non-negative.
If true, other body velocities are considered during the sweep.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ConvexResultList | nullOptional existing RayResultList to accumulate results into.
A RayResultList of all hits encountered during the sweep.
Draw the current state of the physics world using a user-supplied renderer.
Walks all bodies, shapes, constraints, contacts, AABBs, and velocity
vectors and calls the appropriate draw primitives on drawer. Only the
layers selected by flags are rendered.
Performance note: this method allocates temporary vertex arrays for polygon shapes on every call. It is intended for development/debug use only — do not call it in a performance-critical production loop.
The renderer to use. Must not be null.
Bitmask of DebugDrawFlags layers to render.
Defaults to DebugDrawFlags.ALL.
Determine the type of interaction between two shapes (COLLISION, FLUID, SENSOR, or null if they don't interact).
The InteractionType, or null if the shapes would not interact.
Cast a ray into the space and return the closest hit.
The ray to cast.
If true, shapes are tested from the inside as well (useful for concave queries).
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
The closest RayResult, or null if nothing was hit.
Cast a ray into the space and return all hits.
The ray to cast.
If true, shapes are tested from the inside as well.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: RayResultList | nullOptional existing RayResultList to accumulate results into.
A RayResultList of all shapes the ray intersected.
Return all shapes that overlap with the given AABB.
The axis-aligned bounding box to test against.
If true, only shapes fully contained within the AABB are returned.
If true, exact shape geometry is tested; otherwise only AABBs are compared.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ShapeList | nullOptional existing ShapeList to accumulate results into.
A ShapeList of matching shapes.
Return all shapes in the space that overlap with any shape attached to body.
Equivalent to calling shapesInShape for each of body's shapes and merging results.
The body whose shapes are used as the query region.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ShapeList | nullOptional existing ShapeList to accumulate results into.
A ShapeList of overlapping shapes.
Return all shapes that overlap with a circle defined by position and radius.
World-space centre of the query circle.
Radius of the query circle; must be strictly positive and not NaN.
If true, only shapes fully contained within the circle are returned.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ShapeList | nullOptional existing ShapeList to accumulate results into.
A ShapeList of matching shapes.
Return all shapes in the space that overlap with shape.
The query shape; must be attached to a Body.
If true, only shapes fully contained within shape are returned.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ShapeList | nullOptional existing ShapeList to accumulate results into.
A ShapeList of overlapping shapes.
Return all shapes whose geometry contains the given world-space point.
The world-space point to test.
Optionalfilter: InteractionFilter | nullOptional interaction filter to restrict results.
Optionaloutput: ShapeList | nullOptional existing ShapeList to accumulate results into.
A ShapeList of matching shapes.
Advance the simulation by deltaTime seconds.
velocityIterations and positionIterations control solver accuracy (default 10 each).
Time step in seconds; must be strictly positive and not NaN.
Number of velocity solver iterations (minimum 1).
Number of position solver iterations (minimum 1).
Returns a brief string summary of this space.
A string in the form Space(bodies=N).
Call lambda for every body in the space, including those inside compounds.
Callback invoked with each Body.
Call lambda for every compound in the space (recursively).
Callback invoked with each Compound.
Call lambda for every constraint in the space, including those inside compounds.
Callback invoked with each Constraint.
The physics world. Add bodies, shapes, and constraints, then call
step()each frame to advance the simulation.