Skip to Content
defold-typescript libraries
d954mas

d954mas/defold-box2d/box2d

Box2D physics: worlds, bodies, fixtures, shapes and joints.

  • GitHub: d954mas/defold-box2d — pinned to 1.0.3
    1. Pick a release from d954mas/defold-box2d releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as box2d from "box2d"

Functions

NewWorld(gravity?: Vector3): World

Creates a world.

Parameters

  • gravity?: Vector3 — The gravity vector. Default is no gravity.

Returns

  • World — The world.

NewDebugDraw(data: DebugDrawCallbacks): DebugDraw

Creates a debug draw to register with {@link World.SetDebugDraw}. Its callbacks run in the script instance that created it; call {@link DebugDraw.Destroy} when it is no longer needed.

Parameters

  • data: DebugDrawCallbacks — The flags and the drawing callbacks.

Returns

  • DebugDraw — The debug draw.

NewPolygonShape(): PolygonShape

Creates an empty polygon shape. Give it vertices with {@link PolygonShape.Set} or {@link PolygonShape.SetAsBox}.

Returns

  • PolygonShape — The shape.

NewCircleShape(): CircleShape

Creates a circle shape with a radius of 0.

Returns

  • CircleShape — The shape.

NewChainShape(): ChainShape

Creates an empty chain shape. Give it vertices with {@link ChainShape.CreateLoop} or {@link ChainShape.CreateChain}.

Returns

  • ChainShape — The shape.

NewEdgeShape(): EdgeShape

Creates an edge shape. Give it vertices with {@link EdgeShape.SetTwoSided} or {@link EdgeShape.SetOneSided}.

Returns

  • EdgeShape — The shape.

b2LinearStiffness(frequencyHertz: number, dampingRatio: number, bodyA: Body, bodyB: Body): LuaMultiReturn<[ stiffness: number, damping: number ]>

Computes linear stiffness and damping from a frequency and a damping ratio.

Parameters

  • frequencyHertz: number — The frequency in hertz.
  • dampingRatio: number — The damping ratio.
  • bodyA: Body — The first body.
  • bodyB: Body — The second body.

Returns

  • LuaMultiReturn<[ stiffness: number, damping: number ]> — stiffness and damping.

b2AngularStiffness(frequencyHertz: number, dampingRatio: number, bodyA: Body, bodyB: Body): LuaMultiReturn<[ stiffness: number, damping: number ]>

Computes angular stiffness and damping from a frequency and a damping ratio.

Parameters

  • frequencyHertz: number — The frequency in hertz.
  • dampingRatio: number — The damping ratio.
  • bodyA: Body — The first body.
  • bodyB: Body — The second body.

Returns

  • LuaMultiReturn<[ stiffness: number, damping: number ]> — stiffness and damping.

InitializeRevoluteJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): RevoluteJointDef

Fills a revolute joint definition: the bodies, the local anchors and the reference angle, from a world anchor.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchor: Vector3 — The world anchor.

Returns

  • RevoluteJointDef — The definition.

InitializePrismaticJointDef(bodyA: Body, bodyB: Body, anchor: Vector3, axis: Vector3): PrismaticJointDef

Fills a prismatic joint definition: the bodies, the local anchors, the axis and the reference angle, from a world anchor and a unit world axis.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchor: Vector3 — The world anchor.
  • axis: Vector3 — The unit world axis.

Returns

  • PrismaticJointDef — The definition.

InitializeDistanceJointDef(bodyA: Body, bodyB: Body, anchorA: Vector3, anchorB: Vector3): DistanceJointDef

Fills a distance joint definition: the bodies, the local anchors and the rest length, from world anchors. The minimum and maximum lengths are set to the rest length.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchorA: Vector3 — The world anchor on bodyA.
  • anchorB: Vector3 — The world anchor on bodyB.

Returns

  • DistanceJointDef — The definition.

InitializePulleyJointDef(bodyA: Body, bodyB: Body, groundAnchorA: Vector3, groundAnchorB: Vector3, anchorA: Vector3, anchorB: Vector3, ratio: number): PulleyJointDef

Fills a pulley joint definition: the bodies, the anchors, the lengths and the ratio, from world anchors.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • groundAnchorA: Vector3 — The world ground anchor for bodyA.
  • groundAnchorB: Vector3 — The world ground anchor for bodyB.
  • anchorA: Vector3 — The world anchor on bodyA.
  • anchorB: Vector3 — The world anchor on bodyB.
  • ratio: number — The pulley ratio.

Returns

  • PulleyJointDef — The definition.

InitializeMouseJointDef(bodyA: Body, bodyB: Body): MouseJointDef

Fills a mouse joint definition with the two bodies.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The body that tracks the target.

Returns

  • MouseJointDef — The definition.

InitializeGearJointDef(bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint): GearJointDef

Fills a gear joint definition with the two bodies and the two joints it connects.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • joint1: RevoluteJoint | PrismaticJoint — The first revolute or prismatic joint.
  • joint2: RevoluteJoint | PrismaticJoint — The second revolute or prismatic joint.

Returns

  • GearJointDef — The definition.

InitializeWheelJointDef(bodyA: Body, bodyB: Body, anchor: Vector3, axis: Vector3): WheelJointDef

Fills a wheel joint definition: the bodies, the local anchors and the axis, from a world anchor and a world axis.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchor: Vector3 — The world anchor.
  • axis: Vector3 — The world axis.

Returns

  • WheelJointDef — The definition.

InitializeWeldJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): WeldJointDef

Fills a weld joint definition: the bodies, the local anchors and the reference angle, from a world anchor.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchor: Vector3 — The world anchor.

Returns

  • WeldJointDef — The definition.

InitializeFrictionJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): FrictionJointDef

Fills a friction joint definition: the bodies and the local anchors, from a world anchor.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.
  • anchor: Vector3 — The world anchor.

Returns

  • FrictionJointDef — The definition.

InitializeMotorJointDef(bodyA: Body, bodyB: Body): MotorJointDef

Fills a motor joint definition: the bodies and the offsets, from their current transforms.

Parameters

  • bodyA: Body — The first body.
  • bodyB: Body — The second body.

Returns

  • MotorJointDef — The definition.

Variables

b2Shape.e_circle: 0

b2Shape.e_edge: 1

b2Shape.e_polygon: 2

b2Shape.e_chain: 3

b2BodyType.b2_staticBody: 0

Zero mass, zero velocity; may be moved by hand.

b2BodyType.b2_kinematicBody: 1

Zero mass, velocity set by the user, moved by the solver.

b2BodyType.b2_dynamicBody: 2

Positive mass, velocity determined by forces, moved by the solver.

b2JointType.e_unknownJoint: 0

b2JointType.e_revoluteJoint: 1

b2JointType.e_prismaticJoint: 2

b2JointType.e_distanceJoint: 3

b2JointType.e_pulleyJoint: 4

b2JointType.e_mouseJoint: 5

b2JointType.e_gearJoint: 6

b2JointType.e_wheelJoint: 7

b2JointType.e_weldJoint: 8

b2JointType.e_frictionJoint: 9

b2JointType.e_ropeJoint: 10

b2JointType.e_motorJoint: 11

b2Draw.e_shapeBit: 1

Draw shapes.

b2Draw.e_jointBit: 2

Draw joint connections.

b2Draw.e_aabbBit: 4

Draw axis-aligned bounding boxes.

b2Draw.e_pairBit: 8

Draw broad-phase pairs.

b2Draw.e_centerOfMassBit: 16

Draw the center of mass frame.

b2Manifold_Type.e_circles: 0

b2Manifold_Type.e_faceA: 1

b2Manifold_Type.e_faceB: 2

Types

type ShapeType = typeof b2Shape.e_circle | typeof b2Shape.e_edge | typeof b2Shape.e_polygon | typeof b2Shape.e_chain

type ShapeTable = CircleShapeTable | OneSidedEdgeShapeTable | TwoSidedEdgeShapeTable | BoxShapeTable | PolygonShapeTable | ChainShapeTable

type BoxShapeTable = AxisAlignedBoxShapeTable | OrientedBoxShapeTable

type ChainShapeTable = LoopChainShapeTable | OpenChainShapeTable

type BodyType = typeof b2BodyType.b2_staticBody | typeof b2BodyType.b2_kinematicBody | typeof b2BodyType.b2_dynamicBody

type ManifoldType = typeof b2Manifold_Type.e_circles | typeof b2Manifold_Type.e_faceA | typeof b2Manifold_Type.e_faceB

type JointType = typeof b2JointType.e_unknownJoint | typeof b2JointType.e_revoluteJoint | typeof b2JointType.e_prismaticJoint | typeof b2JointType.e_distanceJoint | typeof b2JointType.e_pulleyJoint | typeof b2JointType.e_mouseJoint | typeof b2JointType.e_gearJoint | typeof b2JointType.e_wheelJoint | typeof b2JointType.e_weldJoint | typeof b2JointType.e_frictionJoint | typeof b2JointType.e_ropeJoint | typeof b2JointType.e_motorJoint

type JointDef = RevoluteJointDef | PrismaticJointDef | DistanceJointDef | PulleyJointDef | MouseJointDef | GearJointDef | WheelJointDef | WeldJointDef | FrictionJointDef | MotorJointDef

World

World.SetDestructionListener(listener: DestructionListener | undefined)

Registers a destruction listener, replacing any earlier one.

Parameters

  • listener: DestructionListener | undefined — The callbacks, or nil to remove the listener.

World.SetContactListener(listener: ContactListener | undefined)

Registers a contact listener, replacing any earlier one. Its callbacks run in the script instance that registered it.

Parameters

  • listener: ContactListener | undefined — The callbacks, or nil to remove the listener.

World.SetDebugDraw(draw: DebugDraw | undefined)

Registers the debug draw that {@link World.DebugDraw} calls. The debug draw stays owned by the caller.

Parameters

  • draw: DebugDraw | undefined — The debug draw, or nil to remove it.

World.CreateBody(bodyDef?: BodyDef): Body

Creates a rigid body. Not allowed during callbacks.

Parameters

  • bodyDef?: BodyDef — The body definition. Default is a static body at the origin.

Returns

  • Body — The body.

World.DestroyBody(body: Body)

Destroys a body, with its fixtures and joints. Not allowed during callbacks.

Parameters

  • body: Body — The body.

World.CreateJoint(def: RevoluteJointDef): RevoluteJoint

Creates a revolute joint. Not allowed during callbacks.

Parameters

  • def: RevoluteJointDef — The joint definition.

Returns

  • RevoluteJoint — The joint.

World.CreateJoint(def: PrismaticJointDef): PrismaticJoint

Creates a prismatic joint. Not allowed during callbacks.

Parameters

  • def: PrismaticJointDef — The joint definition.

Returns

  • PrismaticJoint — The joint.

World.CreateJoint(def: DistanceJointDef): DistanceJoint

Creates a distance joint. Not allowed during callbacks.

Parameters

  • def: DistanceJointDef — The joint definition.

Returns

  • DistanceJoint — The joint.

World.CreateJoint(def: PulleyJointDef): PulleyJoint

Creates a pulley joint. Not allowed during callbacks.

Parameters

  • def: PulleyJointDef — The joint definition.

Returns

  • PulleyJoint — The joint.

World.CreateJoint(def: MouseJointDef): MouseJoint

Creates a mouse joint. Not allowed during callbacks.

Parameters

  • def: MouseJointDef — The joint definition.

Returns

  • MouseJoint — The joint.

World.CreateJoint(def: GearJointDef): GearJoint

Creates a gear joint. Not allowed during callbacks.

Parameters

  • def: GearJointDef — The joint definition.

Returns

  • GearJoint — The joint.

World.CreateJoint(def: WheelJointDef): WheelJoint

Creates a wheel joint. Not allowed during callbacks.

Parameters

  • def: WheelJointDef — The joint definition.

Returns

  • WheelJoint — The joint.

World.CreateJoint(def: WeldJointDef): WeldJoint

Creates a weld joint. Not allowed during callbacks.

Parameters

  • def: WeldJointDef — The joint definition.

Returns

  • WeldJoint — The joint.

World.CreateJoint(def: FrictionJointDef): FrictionJoint

Creates a friction joint. Not allowed during callbacks.

Parameters

  • def: FrictionJointDef — The joint definition.

Returns

  • FrictionJoint — The joint.

World.CreateJoint(def: MotorJointDef): MotorJoint

Creates a motor joint. Not allowed during callbacks.

Parameters

  • def: MotorJointDef — The joint definition.

Returns

  • MotorJoint — The joint.

World.CreateJoint(def: JointDef): Joint

Creates a joint whose kind is known only at run time. Not allowed during callbacks.

Parameters

  • def: JointDef — The joint definition.

Returns

  • Joint — The joint.

World.DestroyJoint(joint: Joint)

Destroys a joint. The bodies it connected may begin to collide. Not allowed during callbacks.

Parameters

  • joint: Joint — The joint.

World.Step(timeStep: number, velocityIterations: number, positionIterations: number)

Takes a time step: collision detection, integration and constraint solution. Contact listener callbacks run inside it.

Parameters

  • timeStep: number — The time to simulate. It should not vary.
  • velocityIterations: number — Iterations of the velocity constraint solver.
  • positionIterations: number — Iterations of the position constraint solver.

World.ClearForces()

Clears the force buffer on all bodies. Forces clear after each step unless {@link World.SetAutoClearForces} turned that off, for sub-stepping.

World.DebugDraw()

Calls the registered debug draw for the shapes and other debug data.

World.RayCast(callback: (this: void, fixture: Fixture, point: Vector3, normal: Vector3, fraction: number) => number, point1: Vector3, point2: Vector3)

Casts a ray against every fixture in its path. The ray ignores shapes that contain its start.

Parameters

  • callback: (this: void, fixture: Fixture, point: Vector3, normal: Vector3, fraction: number) => number — Called for each fixture hit. Return -1 to ignore the fixture, 0 to stop, fraction to clip the ray to this hit, or 1 to continue without clipping.
  • point1: Vector3 — The ray start.
  • point2: Vector3 — The ray end.

World.QueryAABB(callback: (this: void, fixture: Fixture) => boolean, aabb: AABB)

Finds every fixture whose AABB overlaps a box.

Parameters

  • callback: (this: void, fixture: Fixture) => boolean — Called for each fixture. Return true to continue the query, false to stop it.
  • aabb: AABB — The query box.

World.GetBodyList(): Body | undefined

Gets the first body in the world. Use {@link Body.GetNext} for the rest.

Returns

  • Body | undefined — The first body, or nil if there is none.

World.GetContactList(): Contact | undefined

Gets the first contact in the world. Use {@link Contact.GetNext} for the rest. Contacts come and go during a time step, so use a {@link ContactListener} not to miss any.

Returns

  • Contact | undefined — The first contact, or nil if there is none.

World.GetJointList(): Joint | undefined

Gets the first joint in the world. Use {@link Joint.GetNext} for the rest.

Returns

  • Joint | undefined — The first joint, or nil if there is none.

World.SetAllowSleeping(flag: boolean)

Enables or disables sleep.

Parameters

  • flag: boolean — true allows bodies to sleep.

World.GetAllowSleeping(): boolean

Whether bodies may sleep.

Returns

  • boolean — true if sleep is allowed.

World.SetWarmStarting(flag: boolean)

Enables or disables warm starting. For testing.

Parameters

  • flag: boolean — true enables it.

World.GetWarmStarting(): boolean

Whether warm starting is enabled.

Returns

  • boolean — true if it is.

World.SetContinuousPhysics(flag: boolean)

Enables or disables continuous physics. For testing.

Parameters

  • flag: boolean — true enables it.

World.GetContinuousPhysics(): boolean

Whether continuous physics is enabled.

Returns

  • boolean — true if it is.

World.SetSubStepping(flag: boolean)

Enables or disables single-stepped continuous physics. For testing.

Parameters

  • flag: boolean — true enables it.

World.GetSubStepping(): boolean

Whether single-stepped continuous physics is enabled.

Returns

  • boolean — true if it is.

World.GetProxyCount(): number

Gets the number of broad-phase proxies.

Returns

  • number — The count.

World.GetBodyCount(): number

Gets the number of bodies.

Returns

  • number — The count.

World.GetJointCount(): number

Gets the number of joints.

Returns

  • number — The count.

World.GetContactCount(): number

Gets the number of contacts, each with zero or more contact points.

Returns

  • number — The count.

World.GetTreeHeight(): number

Gets the height of the dynamic tree.

Returns

  • number — The height.

World.GetTreeBalance(): number

Gets the balance of the dynamic tree.

Returns

  • number — The balance.

World.GetTreeQuality(): number

Gets the quality metric of the dynamic tree. Smaller is better; the minimum is 1.

Returns

  • number — The quality.

World.SetGravity(gravity: Vector3)

Changes the global gravity vector.

Parameters

  • gravity: Vector3 — The gravity.

World.GetGravity(): Vector3

Gets the global gravity vector.

Returns

  • Vector3 — The gravity.

World.IsLocked(): boolean

Whether the world is in the middle of a time step.

Returns

  • boolean — true if it is locked.

World.SetAutoClearForces(flag: boolean)

Sets whether forces clear automatically after each time step.

Parameters

  • flag: boolean — true clears them.

World.GetAutoClearForces(): boolean

Whether forces clear automatically after each time step.

Returns

  • boolean — true if they do.

World.ShiftOrigin(newOrigin: Vector3)

Shifts the world origin, for large worlds. Each body's position becomes position - newOrigin.

Parameters

  • newOrigin: Vector3 — The new origin relative to the old one.

World.GetProfile(): Profile

Gets the profile of the last step.

Returns

  • Profile — The times spent in each phase.

World.Dump()

Dumps the world to the log. Call it outside a time step. Not supported on Android or iOS.

World.Destroy()

Destroys the world with its bodies, fixtures, joints, contacts and listeners.

DestructionListener

DestructionListener.SayGoodbyeFixture?: (this: void, fixture: Fixture) => void

Called before the fixture is destroyed.

DestructionListener.SayGoodbyeJoint?: (this: void, joint: Joint) => void

Called before the joint is destroyed.

Fixture

Fixture.GetType(): ShapeType

Gets the type of the fixture's shape.

Returns

  • ShapeType — A {@link b2Shape} value.

Fixture.GetShape(): Shape

Gets a copy of the shape. Changing the copy does not change the fixture.

Returns

  • Shape — The shape copy.

Fixture.SetSensor(sensor: boolean)

Sets whether this fixture is a sensor.

Parameters

  • sensor: boolean — true makes it a sensor.

Fixture.IsSensor(): boolean

Whether this fixture is a sensor (non-solid).

Returns

  • boolean — true if it is a sensor.

Fixture.SetFilterData(filter: Filter)

Sets the contact filtering data. Contacts update at the next step when either body is active and awake. This calls {@link Fixture.Refilter}.

Parameters

  • filter: Filter — The filtering data.

Fixture.GetFilterData(): Filter

Gets the contact filtering data.

Returns

  • Filter — The filtering data.

Fixture.Refilter()

Re-establishes collision that a contact filter previously disabled.

Fixture.GetBody(): Body

Gets the body this fixture is attached to.

Returns

  • Body — The body.

Fixture.GetNext(): Fixture | undefined

Gets the next fixture in the body's fixture list.

Returns

  • Fixture | undefined — The next fixture, or nil at the end of the list.

Fixture.GetUserData(): object | undefined

Gets the application data.

Returns

  • object | undefined — The table, or nil if none is set.

Fixture.SetUserData(userdata: object | undefined)

Sets the application data.

Parameters

  • userdata: object | undefined — A table, or nil to clear it.

Fixture.TestPoint(point: Vector3): boolean

Tests a point for containment in this fixture.

Parameters

  • point: Vector3 — A point in world coordinates.

Returns

  • boolean — true if the point is inside.

Fixture.RayCast(input: RayCastInput, childIndex: number): RayCastOutput | undefined

Casts a ray against this fixture's shape.

Parameters

  • input: RayCastInput — The ray-cast input parameters.
  • childIndex: number — The child shape index. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • RayCastOutput | undefined — The hit, or nil if the ray misses.

Fixture.GetMassData(): MassData

Gets the mass data, from the density and the shape. The inertia is about the shape's origin. This may be expensive.

Returns

  • MassData — The mass data.

Fixture.GetDensity(): number

Gets the density.

Returns

  • number — The density.

Fixture.SetDensity(density: number)

Sets the density. This does not update the body's mass; call {@link Body.ResetMassData} for that.

Parameters

  • density: number — The density.

Fixture.GetFriction(): number

Gets the friction coefficient.

Returns

  • number — The friction.

Fixture.SetFriction(friction: number)

Sets the friction coefficient. Existing contacts keep their friction.

Parameters

  • friction: number — The friction.

Fixture.GetRestitution(): number

Gets the restitution coefficient.

Returns

  • number — The restitution.

Fixture.SetRestitution(restitution: number)

Sets the restitution coefficient. Existing contacts keep their restitution.

Parameters

  • restitution: number — The restitution.

Fixture.GetRestitutionThreshold(): number

Gets the restitution velocity threshold.

Returns

  • number — The threshold.

Fixture.SetRestitutionThreshold(threshold: number)

Sets the restitution velocity threshold. Existing contacts keep theirs.

Parameters

  • threshold: number — The threshold.

Fixture.GetAABB(childIndex: number): AABB

Gets the fixture's AABB, which may be enlarged or stale. For an exact box, compute it from the shape and the body transform.

Parameters

  • childIndex: number — The child shape index. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • AABB — The box.

Fixture.Dump(bodyIndex: number)

Dumps this fixture to the log.

Parameters

  • bodyIndex: number — The index the dump gives the fixture's body. 0️⃣ 0-based; passed to box2d unchanged.

Shape

Shape.Clone(): Shape

Copies the shape.

Returns

  • Shape — A new shape of the same type.

Shape.GetType(): ShapeType

Gets the type of this shape. Use it to tell which shape type the object is.

Returns

  • ShapeType — A {@link b2Shape} value.

Shape.GetChildCount(): number

Gets the number of child primitives.

Returns

  • number — The child count.

Shape.TestPoint(xf: Transform, p: Vector3): boolean

Tests a point for containment in this shape. This only works for convex shapes.

Parameters

  • xf: Transform — The shape's world transform.
  • p: Vector3 — A point in world coordinates.

Returns

  • boolean — true if the point is inside.

Shape.RayCast(input: RayCastInput, transform: Transform, childIndex?: number): RayCastOutput | undefined

Casts a ray against a child shape.

Parameters

  • input: RayCastInput — The ray-cast input parameters.
  • transform: Transform — The transform applied to the shape.
  • childIndex?: number — The child shape index. Circle, polygon and edge shapes have one child and ignore it; a chain shape requires it. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • RayCastOutput | undefined — The hit, or nil if the ray misses.

Shape.ComputeAABB(xf: Transform, childIndex?: number): AABB

Computes the axis-aligned bounding box of a child shape.

Parameters

  • xf: Transform — The world transform of the shape.
  • childIndex?: number — The child shape index. Circle, polygon and edge shapes have one child and ignore it; a chain shape requires it. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • AABB — The box.

Shape.ComputeMass(density: number): MassData

Computes the mass properties of this shape from its dimensions and density. The inertia is computed about the local origin.

Parameters

  • density: number — The density in kilograms per square meter.

Returns

  • MassData — The mass data.

Shape.GetRadius(): number

Gets the radius. For a polygon it is the polygon skin radius.

Returns

  • number — The radius.

Shape.SetRadius(radius: number)

Sets the radius.

Parameters

  • radius: number — The new radius.

Transform

Transform.p: Vector3

The position.

Transform.q: number

The rotation angle in radians.

RayCastInput

RayCastInput.p1: Vector3

RayCastInput.p2: Vector3

RayCastInput.maxFraction: number

RayCastOutput

RayCastOutput.normal: Vector3

RayCastOutput.fraction: number

AABB

AABB.lowerBound: Vector3

The lower vertex.

AABB.upperBound: Vector3

The upper vertex.

MassData

MassData.mass: number

The mass, usually in kilograms.

MassData.center: Vec2

The position of the center of mass relative to the shape origin. A plain {x, y} table.

MassData.I: number

The rotational inertia about the local origin.

Vec2

Vec2.x: number

Vec2.y: number

Filter

Filter.categoryBits: number

The collision category bits. Normally one bit is set.

Filter.maskBits: number

The categories this shape accepts for collision.

Filter.groupIndex: number

Objects in the same negative group never collide; in the same positive group they always collide. Zero means no group. A non-zero group wins over the mask bits.

Body

Body.CreateFixture(def: FixtureDef): Fixture

Creates a fixture from a definition and attaches it to this body. If the density is non-zero, the body's mass is updated. Contacts are not created until the next step. Not allowed during callbacks.

Parameters

  • def: FixtureDef — The fixture definition.

Returns

  • Fixture — The fixture.

Body.CreateFixture(shape: Shape | ShapeTable, density: number): Fixture

Creates a fixture from a shape and attaches it to this body. Use a {@link FixtureDef} to set friction, restitution, user data or filtering. Not allowed during callbacks.

Parameters

  • shape: Shape | ShapeTable — The shape. The fixture gets a copy.
  • density: number — The shape density; zero for a static body.

Returns

  • Fixture — The fixture.

Body.DestroyFixture(fixture: Fixture)

Destroys a fixture, removing it from the broad-phase and destroying its contacts. A dynamic body's mass is adjusted if the fixture had positive density. Not allowed during callbacks.

Parameters

  • fixture: Fixture — The fixture.

Body.SetTransform(position: Vector3, angle?: number)

Sets the position of the body's origin and its rotation. This may cause non-physical behavior; contacts update at the next step.

Parameters

  • position: Vector3 — The world position of the body's local origin.
  • angle?: number — The world rotation in radians. Default is the current angle.

Body.GetTransform(): Transform

Gets the transform of the body's origin.

Returns

  • Transform — The transform.

Body.GetPosition(): Vector3

Gets the world position of the body's origin.

Returns

  • Vector3 — The position.

Body.GetPositionRaw(): LuaMultiReturn<[ number, number ]>

Gets the world position of the body's origin as two numbers, with no vector3 allocated.

Returns

  • LuaMultiReturn<[ number, number ]> — x and y.

Body.GetAngle(): number

Gets the angle.

Returns

  • number — The angle in radians.

Body.GetWorldCenter(): Vector3

Gets the world position of the center of mass.

Returns

  • Vector3 — The position.

Body.GetLocalCenter(): Vector3

Gets the local position of the center of mass.

Returns

  • Vector3 — The position.

Body.SetLinearVelocity(velocity: Vector3)

Sets the linear velocity of the center of mass.

Parameters

  • velocity: Vector3 — The velocity.

Body.GetLinearVelocity(): Vector3

Gets the linear velocity of the center of mass.

Returns

  • Vector3 — The velocity.

Body.SetAngularVelocity(omega: number)

Sets the angular velocity.

Parameters

  • omega: number — The angular velocity in radians per second.

Body.GetAngularVelocity(): number

Gets the angular velocity.

Returns

  • number — The angular velocity in radians per second.

Body.ApplyForce(force: Vector3, point: Vector3, wake: boolean)

Applies a force at a world point. Off the center of mass it also produces a torque.

Parameters

  • force: Vector3 — The world force, usually in N.
  • point: Vector3 — The world position where it applies.
  • wake: boolean — true also wakes the body.

Body.ApplyForceToCenter(force: Vector3, wake: boolean)

Applies a force to the center of mass.

Parameters

  • force: Vector3 — The world force, usually in N.
  • wake: boolean — true also wakes the body.

Body.ApplyTorque(torque: number, wake: boolean)

Applies a torque. This changes the angular velocity but not the linear velocity of the center of mass.

Parameters

  • torque: number — The torque about the z-axis, usually in N-m.
  • wake: boolean — true also wakes the body.

Body.ApplyLinearImpulse(impulse: Vector3, point: Vector3, wake: boolean)

Applies an impulse at a world point. This changes the velocity at once, and the angular velocity if the point is off the center of mass.

Parameters

  • impulse: Vector3 — The world impulse, usually in N-s.
  • point: Vector3 — The world position where it applies.
  • wake: boolean — true also wakes the body.

Body.ApplyLinearImpulseToCenter(impulse: Vector3, wake: boolean)

Applies an impulse to the center of mass. This changes the velocity at once.

Parameters

  • impulse: Vector3 — The world impulse, usually in N-s.
  • wake: boolean — true also wakes the body.

Body.ApplyAngularImpulse(impulse: number, wake: boolean)

Applies an angular impulse.

Parameters

  • impulse: number — The angular impulse in kgmm/s.
  • wake: boolean — true also wakes the body.

Body.GetMass(): number

Gets the total mass.

Returns

  • number — The mass, usually in kilograms.

Body.GetInertia(): number

Gets the rotational inertia about the local origin.

Returns

  • number — The inertia, usually in kg-m^2.

Body.ResetMassData()

Resets the mass properties to the sum of the fixtures' mass properties. Needed only after {@link Body.SetMassData} overrode them.

Body.GetMassData(): MassData

Gets the mass data.

Returns

  • MassData — The mass, inertia and center of the body.

Body.SetMassData(data: MassData)

Overrides the mass properties of the fixtures. This moves the center of mass, and has no effect on a body that is not dynamic.

Parameters

  • data: MassData — The mass properties.

Body.GetWorldPoint(localPoint: Vector3): Vector3

Converts a local point to world coordinates.

Parameters

  • localPoint: Vector3 — A point relative to the body's origin.

Returns

  • Vector3 — The point in world coordinates.

Body.GetWorldVector(localVector: Vector3): Vector3

Converts a local vector to world coordinates.

Parameters

  • localVector: Vector3 — A vector fixed in the body.

Returns

  • Vector3 — The vector in world coordinates.

Body.GetLocalPoint(worldPoint: Vector3): Vector3

Converts a world point to a point relative to the body's origin.

Parameters

  • worldPoint: Vector3 — A point in world coordinates.

Returns

  • Vector3 — The local point.

Body.GetLocalVector(worldVector: Vector3): Vector3

Converts a world vector to a local vector.

Parameters

  • worldVector: Vector3 — A vector in world coordinates.

Returns

  • Vector3 — The local vector.

Body.GetLinearVelocityFromLocalPoint(localPoint: Vector3): Vector3

Gets the world velocity of a local point.

Parameters

  • localPoint: Vector3 — A point in local coordinates.

Returns

  • Vector3 — The world velocity of the point.

Body.GetLinearVelocityFromWorldPoint(worldPoint: Vector3): Vector3

Gets the world velocity of a world point attached to this body.

Parameters

  • worldPoint: Vector3 — A point in world coordinates.

Returns

  • Vector3 — The world velocity of the point.

Body.SetLinearDamping(linearDamping: number)

Sets the linear damping.

Parameters

  • linearDamping: number — The damping.

Body.GetLinearDamping(): number

Gets the linear damping.

Returns

  • number — The damping.

Body.SetAngularDamping(angularDamping: number)

Sets the angular damping.

Parameters

  • angularDamping: number — The damping.

Body.GetAngularDamping(): number

Gets the angular damping.

Returns

  • number — The damping.

Body.SetGravityScale(scale: number)

Sets the gravity scale.

Parameters

  • scale: number — The scale.

Body.GetGravityScale(): number

Gets the gravity scale.

Returns

  • number — The scale.

Body.SetType(type: BodyType)

Sets the body type. This may change the mass and velocity.

Parameters

  • type: BodyType — A {@link b2BodyType} value.

Body.GetType(): BodyType

Gets the body type.

Returns

  • BodyType — A {@link b2BodyType} value.

Body.SetBullet(flag: boolean)

Sets whether the body is treated like a bullet for continuous collision detection.

Parameters

  • flag: boolean — true makes it a bullet.

Body.IsBullet(): boolean

Whether the body is treated like a bullet for continuous collision detection.

Returns

  • boolean — true if it is a bullet.

Body.SetSleepingAllowed(flag: boolean)

Sets whether the body may sleep. Disallowing sleep wakes the body.

Parameters

  • flag: boolean — false keeps the body awake.

Body.IsSleepingAllowed(): boolean

Whether the body may sleep.

Returns

  • boolean — true if sleep is allowed.

Body.SetAwake(flag: boolean)

Wakes the body or puts it to sleep. A sleeping body costs very little CPU.

Parameters

  • flag: boolean — true wakes the body, false puts it to sleep.

Body.IsAwake(): boolean

Whether the body is awake.

Returns

  • boolean — true if the body is awake.

Body.SetEnabled(flag: boolean)

Enables or disables the body. A disabled body is not simulated, cannot be collided with or woken, and stays in the world. Its fixtures leave the broad-phase and its contacts are destroyed; its joints are implicitly disabled.

Parameters

  • flag: boolean — true enables the body.

Body.IsEnabled(): boolean

Whether the body is enabled.

Returns

  • boolean — true if the body is enabled.

Body.SetFixedRotation(flag: boolean)

Sets whether the body has fixed rotation. This resets the mass.

Parameters

  • flag: boolean — true fixes the rotation.

Body.IsFixedRotation(): boolean

Whether the body has fixed rotation.

Returns

  • boolean — true if the rotation is fixed.

Body.GetNext(): Body | undefined

Gets the next body in the world's body list.

Returns

  • Body | undefined — The next body, or nil at the end of the list.

Body.GetFixtureList(): Fixture | undefined

Gets the first fixture attached to this body. Use {@link Fixture.GetNext} for the rest.

Returns

  • Fixture | undefined — The first fixture, or nil if the body has none.

Body.GetContactList(): Contact[]

Gets the contacts attached to this body. The list changes during the time step, so use a {@link ContactListener} not to miss collisions.

⚠️ The list is the body's own table, filled from index 1; a contact from an earlier, longer call stays past the end of the current list.

Returns

  • Contact[] — The contacts.

Body.GetJointList(): Joint[]

Gets the joints attached to this body.

⚠️ The list is the body's own table, filled from index 1; a joint from an earlier, longer call stays past the end of the current list.

Returns

  • Joint[] — The joints.

Body.GetUserData(): object | undefined

Gets the application data.

Returns

  • object | undefined — The table, or nil if none is set.

Body.SetUserData(data: object | undefined)

Sets the application data.

Parameters

  • data: object | undefined — A table, or nil to clear it.

Body.GetWorld(): World

Gets the world this body belongs to.

Returns

  • World — The world.

Body.Dump()

Dumps this body to the log.

FixtureDef

FixtureDef.shape: Shape | ShapeTable

The shape. The fixture gets a copy.

FixtureDef.userData?: object

Application data. Must be a table.

FixtureDef.friction?: number

The friction coefficient, usually from 0 to 1. Default is 0.2.

FixtureDef.restitution?: number

The restitution (elasticity), usually from 0 to 1. Default is 0.

FixtureDef.restitutionThreshold?: number

Collisions above this speed, in meters per second, bounce. Default is 1.

FixtureDef.density?: number

The density, usually in kilograms per square meter. Default is 0.

FixtureDef.isSensor?: boolean

A sensor collects contact information but never generates a collision response.

FixtureDef.filter?: Filter

Contact filtering data.

CircleShapeTable

CircleShapeTable.shape: typeof b2Shape.e_circle

CircleShapeTable.circle_radius: number

CircleShapeTable.circle_position?: Vector3

The center relative to the body origin. Default is the origin.

OneSidedEdgeShapeTable

OneSidedEdgeShapeTable.shape: typeof b2Shape.e_edge

OneSidedEdgeShapeTable.edge_two_sided?: false

OneSidedEdgeShapeTable.edge_v0: Vector3

The vertex that precedes the edge.

OneSidedEdgeShapeTable.edge_v1: Vector3

OneSidedEdgeShapeTable.edge_v2: Vector3

OneSidedEdgeShapeTable.edge_v3: Vector3

The vertex that follows the edge.

TwoSidedEdgeShapeTable

TwoSidedEdgeShapeTable.shape: typeof b2Shape.e_edge

TwoSidedEdgeShapeTable.edge_two_sided: true

TwoSidedEdgeShapeTable.edge_v1: Vector3

TwoSidedEdgeShapeTable.edge_v2: Vector3

AxisAlignedBoxShapeTable

AxisAlignedBoxShapeTable.shape: typeof b2Shape.e_polygon

AxisAlignedBoxShapeTable.box: true

AxisAlignedBoxShapeTable.box_hx: number

The half-width.

AxisAlignedBoxShapeTable.box_hy: number

The half-height.

AxisAlignedBoxShapeTable.box_center?: never

AxisAlignedBoxShapeTable.box_angle?: never

OrientedBoxShapeTable

OrientedBoxShapeTable.shape: typeof b2Shape.e_polygon

OrientedBoxShapeTable.box: true

OrientedBoxShapeTable.box_hx: number

The half-width.

OrientedBoxShapeTable.box_hy: number

The half-height.

OrientedBoxShapeTable.box_center: Vector3

The center in local coordinates.

OrientedBoxShapeTable.box_angle: number

The rotation in radians.

PolygonShapeTable

PolygonShapeTable.shape: typeof b2Shape.e_polygon

PolygonShapeTable.box?: false

PolygonShapeTable.polygon_vertices: Vector3[]

From 3 to 8 points; their convex hull is used.

LoopChainShapeTable

LoopChainShapeTable.shape: typeof b2Shape.e_chain

LoopChainShapeTable.chain_vertices: Vector3[]

LoopChainShapeTable.chain_loop: true

Closes the chain into a loop.

OpenChainShapeTable

OpenChainShapeTable.shape: typeof b2Shape.e_chain

OpenChainShapeTable.chain_vertices: Vector3[]

OpenChainShapeTable.chain_loop?: false

OpenChainShapeTable.chain_prev_vertex: Vector3

The vertex that connects to the start.

OpenChainShapeTable.chain_next_vertex: Vector3

The vertex that connects to the end.

Contact

Contact.GetNext(): Contact | undefined

Gets the next contact in the world's contact list.

Returns

  • Contact | undefined — The next contact, or nil at the end of the list.

Contact.GetManifold(): Manifold

Gets the local manifold.

Returns

  • Manifold — The manifold.

Contact.GetWorldManifold(): WorldManifold

Gets the world manifold.

Returns

  • WorldManifold — The manifold in world coordinates.

Contact.IsTouching(): boolean

Whether this contact is touching.

Returns

  • boolean — true if the fixtures touch.

Contact.SetEnabled(flag: boolean)

Enables or disables this contact for the current time step (or sub-step in continuous collisions). Use it inside PreSolve.

Parameters

  • flag: boolean — false disables the contact.

Contact.IsEnabled(): boolean

Whether this contact is enabled.

Returns

  • boolean — true if the contact is enabled.

Contact.GetFixtureA(): Fixture

Gets fixture A.

Returns

  • Fixture — The fixture.

Contact.GetChildIndexA(): number

Gets the child primitive index for fixture A.

Returns

  • number — The index. 0️⃣ 0-based; passed to box2d unchanged.

Contact.GetFixtureB(): Fixture

Gets fixture B.

Returns

  • Fixture — The fixture.

Contact.GetChildIndexB(): number

Gets the child primitive index for fixture B.

Returns

  • number — The index. 0️⃣ 0-based; passed to box2d unchanged.

Contact.SetFriction(friction: number)

Overrides the default friction mixture. Call it in PreSolve; the value persists until it is set or reset.

Parameters

  • friction: number — The friction.

Contact.GetFriction(): number

Gets the friction.

Returns

  • number — The friction.

Contact.ResetFriction()

Resets the friction mixture to the default value.

Contact.SetRestitution(restitution: number)

Overrides the default restitution mixture. Call it in PreSolve; the value persists until it is set or reset.

Parameters

  • restitution: number — The restitution.

Contact.GetRestitution(): number

Gets the restitution.

Returns

  • number — The restitution.

Contact.ResetRestitution()

Resets the restitution to the default value.

Contact.SetRestitutionThreshold(threshold: number)

Overrides the default restitution velocity threshold mixture. Call it in PreSolve; the value persists until it is set or reset.

Parameters

  • threshold: number — The threshold.

Contact.GetRestitutionThreshold(): number

Gets the restitution threshold.

Returns

  • number — The threshold.

Contact.ResetRestitutionThreshold()

Resets the restitution threshold to the default value.

Contact.SetTangentSpeed(speed: number)

Sets the desired tangent speed for a conveyor belt, in meters per second.

Parameters

  • speed: number — The speed.

Contact.GetTangentSpeed(): number

Gets the desired tangent speed, in meters per second.

Returns

  • number — The speed.

Manifold

Manifold.type: ManifoldType

Manifold.localPoint: Vector3

Usage depends on the manifold type.

Manifold.localNormal: Vector3

Not used for e_circles.

Manifold.pointCount: number

The number of manifold points.

Manifold.points: ManifoldPoint[]

The points of contact.

ManifoldPoint

ManifoldPoint.localPoint: Vector3

Usage depends on the manifold type.

ManifoldPoint.normalImpulse: number

The non-penetration impulse.

ManifoldPoint.tangentImpulse: number

The friction impulse.

ManifoldPoint.id: ContactID

Identifies the contact point between the two shapes.

ContactID

ContactID.cf: ContactFeature

ContactID.key: number

Used to compare contact ids quickly.

ContactFeature

ContactFeature.indexA: number

Feature index on shape A.

ContactFeature.indexB: number

Feature index on shape B.

ContactFeature.typeA: number

The feature type on shape A: 0 for a vertex, 1 for a face.

ContactFeature.typeB: number

The feature type on shape B: 0 for a vertex, 1 for a face.

WorldManifold

WorldManifold.normal: Vector3

World vector pointing from A to B.

WorldManifold.points: Vector3[]

World contact points.

WorldManifold.separations: number[]

A negative value indicates overlap, in meters.

Joint

Joint.GetType(): JointType

Gets the joint type.

Returns

  • JointType — A {@link b2JointType} value.

Joint.GetBodyA(): Body

Gets the first attached body.

Returns

  • Body — bodyA.

Joint.GetBodyB(): Body

Gets the second attached body.

Returns

  • Body — bodyB.

Joint.GetAnchorA(): Vector3

Gets the anchor on bodyA in world coordinates.

Returns

  • Vector3 — The anchor.

Joint.GetAnchorB(): Vector3

Gets the anchor on bodyB in world coordinates.

Returns

  • Vector3 — The anchor.

Joint.GetReactionForce(inv_dt: number): Vector3

Gets the reaction force on bodyB at the joint anchor.

Parameters

  • inv_dt: number — The inverse time step.

Returns

  • Vector3 — The force in N.

Joint.GetReactionTorque(inv_dt: number): number

Gets the reaction torque on bodyB.

Parameters

  • inv_dt: number — The inverse time step.

Returns

  • number — The torque in N*m.

Joint.GetNext(): Joint | undefined

Gets the next joint in the world's joint list.

Returns

  • Joint | undefined — The next joint, or nil at the end of the list.

Joint.GetUserData(): object | undefined

Gets the application data.

Returns

  • object | undefined — The table, or nil if none is set.

Joint.SetUserData(userdata: object | undefined)

Sets the application data. This is the only way to attach it to a joint, since a joint definition carries none.

Parameters

  • userdata: object | undefined — A table, or nil to clear it.

Joint.IsEnabled(): boolean

Whether either attached body is enabled.

Returns

  • boolean — true if one is.

Joint.GetCollideConnected(): boolean

Whether the attached bodies collide. Changing it has no effect on fixtures that already overlap.

Returns

  • boolean — true if they collide.

Joint.Dump()

Dumps this joint to the log.

Joint.ShiftOrigin(newOrigin: Vector3)

Shifts the origin of any points stored in world coordinates.

Parameters

  • newOrigin: Vector3 — The new origin relative to the old one.

ContactListener

ContactListener.BeginContact?: (this: void, contact: Contact) => void

Called when two fixtures begin to touch.

ContactListener.EndContact?: (this: void, contact: Contact) => void

Called when two fixtures stop touching.

ContactListener.PreSolve?: (this: void, contact: Contact, oldManifold: Manifold) => void

Called after a contact is updated and before it goes to the solver.

ContactListener.PostSolve?: (this: void, contact: Contact, impulse: ContactImpulse) => void

Called after the solver, with the impulses it applied.

ContactImpulse

ContactImpulse.normalImpulses: number[]

ContactImpulse.tangentImpulses: number[]

ContactImpulse.count: number

DebugDraw

DebugDraw.SetFlags(flags: number)

Sets the drawing flags.

Parameters

  • flags: number — A sum of {@link b2Draw} bits.

DebugDraw.GetFlags(): number

Gets the drawing flags.

Returns

  • number — A sum of {@link b2Draw} bits.

DebugDraw.ClearFlags(flags: number)

Clears flags from the current flags.

Parameters

  • flags: number — A sum of {@link b2Draw} bits.

DebugDraw.Destroy()

Frees the debug draw.

BodyDef

BodyDef.type?: BodyType

The body type. Default is b2_staticBody. A dynamic body with zero mass gets a mass of one.

BodyDef.position?: Vector3

The world position. Avoid creating bodies at the origin, where shapes overlap.

BodyDef.angle?: number

The world angle in radians.

BodyDef.linearVelocity?: Vector3

The linear velocity of the body's origin in world coordinates.

BodyDef.angularVelocity?: number

The angular velocity.

BodyDef.linearDamping?: number

Reduces the linear velocity. Units are 1/time.

BodyDef.angularDamping?: number

Reduces the angular velocity. Units are 1/time.

BodyDef.allowSleep?: boolean

false keeps the body from sleeping, at a CPU cost. Default is true.

BodyDef.awake?: boolean

Whether the body starts awake. Default is true.

BodyDef.fixedRotation?: boolean

Prevents rotation. Useful for characters.

BodyDef.bullet?: boolean

Prevents a fast dynamic body from tunneling through other moving bodies. Use it sparingly; it costs processing time.

BodyDef.enabled?: boolean

Whether the body starts enabled. Default is true.

BodyDef.userData?: object

Application data. Must be a table.

BodyDef.gravityScale?: number

Scales the gravity applied to this body. Default is 1.

RevoluteJointDef

interface RevoluteJointDef extends JointDefBase

RevoluteJointDef.type: typeof b2JointType.e_revoluteJoint

RevoluteJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

RevoluteJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

RevoluteJointDef.referenceAngle?: number

bodyB's angle minus bodyA's angle in the reference state, in radians.

RevoluteJointDef.enableLimit?: boolean

Enables the joint limit.

RevoluteJointDef.lowerAngle?: number

The lower angle limit in radians.

RevoluteJointDef.upperAngle?: number

The upper angle limit in radians.

RevoluteJointDef.enableMotor?: boolean

Enables the joint motor.

RevoluteJointDef.motorSpeed?: number

The desired motor speed, usually in radians per second.

RevoluteJointDef.maxMotorTorque?: number

The maximum motor torque, usually in N-m.

JointDefBase

JointDefBase.bodyA: Body

The first attached body.

JointDefBase.bodyB: Body

The second attached body.

JointDefBase.collideConnected?: boolean

true lets the attached bodies collide.

RevoluteJoint

interface RevoluteJoint extends Joint

RevoluteJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

RevoluteJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

RevoluteJoint.GetReferenceAngle(): number

Gets the reference angle.

Returns

  • number — The angle in radians.

RevoluteJoint.GetJointAngle(): number

Gets the current joint angle.

Returns

  • number — The angle in radians.

RevoluteJoint.GetJointSpeed(): number

Gets the current joint angular speed.

Returns

  • number — The speed in radians per second.

RevoluteJoint.IsLimitEnabled(): boolean

Whether the joint limit is enabled.

Returns

  • boolean — true if it is.

RevoluteJoint.EnableLimit(flag: boolean)

Enables or disables the joint limit.

Parameters

  • flag: boolean — true enables it.

RevoluteJoint.GetLowerLimit(): number

Gets the lower joint limit.

Returns

  • number — The limit in radians.

RevoluteJoint.GetUpperLimit(): number

Gets the upper joint limit.

Returns

  • number — The limit in radians.

RevoluteJoint.SetLimits(lower: number, upper: number)

Sets the joint limits.

Parameters

  • lower: number — The lower limit in radians.
  • upper: number — The upper limit in radians.

RevoluteJoint.IsMotorEnabled(): boolean

Whether the joint motor is enabled.

Returns

  • boolean — true if it is.

RevoluteJoint.EnableMotor(flag: boolean)

Enables or disables the joint motor.

Parameters

  • flag: boolean — true enables it.

RevoluteJoint.SetMotorSpeed(speed: number)

Sets the motor speed.

Parameters

  • speed: number — The speed in radians per second.

RevoluteJoint.GetMotorSpeed(): number

Gets the motor speed.

Returns

  • number — The speed in radians per second.

RevoluteJoint.SetMaxMotorTorque(torque: number)

Sets the maximum motor torque.

Parameters

  • torque: number — The torque, usually in N-m.

RevoluteJoint.GetMaxMotorTorque(): number

Gets the maximum motor torque.

Returns

  • number — The torque, usually in N-m.

RevoluteJoint.GetMotorTorque(inv_dt: number): number

Gets the current motor torque.

Parameters

  • inv_dt: number — The inverse time step.

Returns

  • number — The torque in N*m.

PrismaticJointDef

interface PrismaticJointDef extends JointDefBase

PrismaticJointDef.type: typeof b2JointType.e_prismaticJoint

PrismaticJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

PrismaticJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

PrismaticJointDef.localAxisA?: Vector3

The translation unit axis in bodyA.

PrismaticJointDef.referenceAngle?: number

bodyB's angle minus bodyA's angle, in radians.

PrismaticJointDef.enableLimit?: boolean

Enables the joint limit.

PrismaticJointDef.lowerTranslation?: number

The lower translation limit, usually in meters.

PrismaticJointDef.upperTranslation?: number

The upper translation limit, usually in meters.

PrismaticJointDef.enableMotor?: boolean

Enables the joint motor.

PrismaticJointDef.maxMotorForce?: number

The maximum motor force, usually in N.

PrismaticJointDef.motorSpeed?: number

The desired motor speed, usually in meters per second.

PrismaticJoint

interface PrismaticJoint extends Joint

PrismaticJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

PrismaticJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

PrismaticJoint.GetLocalAxisA(): Vector3

Gets the joint axis relative to bodyA.

Returns

  • Vector3 — The axis.

PrismaticJoint.GetReferenceAngle(): number

Gets the reference angle.

Returns

  • number — The angle in radians.

PrismaticJoint.GetJointTranslation(): number

Gets the current joint translation.

Returns

  • number — The translation, usually in meters.

PrismaticJoint.GetJointSpeed(): number

Gets the current joint translation speed.

Returns

  • number — The speed, usually in meters per second.

PrismaticJoint.IsLimitEnabled(): boolean

Whether the joint limit is enabled.

Returns

  • boolean — true if it is.

PrismaticJoint.EnableLimit(flag: boolean)

Enables or disables the joint limit.

Parameters

  • flag: boolean — true enables it.

PrismaticJoint.GetLowerLimit(): number

Gets the lower joint limit.

Returns

  • number — The limit, usually in meters.

PrismaticJoint.GetUpperLimit(): number

Gets the upper joint limit.

Returns

  • number — The limit, usually in meters.

PrismaticJoint.SetLimits(lower: number, upper: number)

Sets the joint limits.

Parameters

  • lower: number — The lower limit, usually in meters.
  • upper: number — The upper limit, usually in meters.

PrismaticJoint.IsMotorEnabled(): boolean

Whether the joint motor is enabled.

Returns

  • boolean — true if it is.

PrismaticJoint.EnableMotor(flag: boolean)

Enables or disables the joint motor.

Parameters

  • flag: boolean — true enables it.

PrismaticJoint.SetMotorSpeed(speed: number)

Sets the motor speed.

Parameters

  • speed: number — The speed, usually in meters per second.

PrismaticJoint.GetMotorSpeed(): number

Gets the motor speed.

Returns

  • number — The speed, usually in meters per second.

PrismaticJoint.SetMaxMotorForce(force: number)

Sets the maximum motor force.

Parameters

  • force: number — The force, usually in N.

PrismaticJoint.GetMaxMotorForce(): number

Gets the maximum motor force.

Returns

  • number — The force, usually in N.

PrismaticJoint.GetMotorForce(inv_dt: number): number

Gets the current motor force.

Parameters

  • inv_dt: number — The inverse time step.

Returns

  • number — The force, usually in N.

DistanceJointDef

interface DistanceJointDef extends JointDefBase

DistanceJointDef.type: typeof b2JointType.e_distanceJoint

DistanceJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

DistanceJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

DistanceJointDef.length?: number

The rest length.

DistanceJointDef.minLength?: number

The minimum length.

DistanceJointDef.maxLength?: number

The maximum length. Must be at least the minimum length.

DistanceJointDef.stiffness?: number

The linear stiffness in N/m.

DistanceJointDef.damping?: number

The linear damping in N*s/m.

DistanceJoint

interface DistanceJoint extends Joint

DistanceJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

DistanceJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

DistanceJoint.GetLength(): number

Gets the rest length.

Returns

  • number — The length.

DistanceJoint.SetLength(length: number)

Sets the rest length, which Box2D clamps to a stable minimum.

Parameters

  • length: number — The length.

DistanceJoint.GetMinLength(): number

Gets the minimum length.

Returns

  • number — The length.

DistanceJoint.SetMinLength(minLength: number)

Sets the minimum length, which Box2D clamps to a stable minimum.

Parameters

  • minLength: number — The length.

DistanceJoint.GetMaxLength(): number

Gets the maximum length.

Returns

  • number — The length.

DistanceJoint.SetMaxLength(maxLength: number)

Sets the maximum length.

Parameters

  • maxLength: number — The length.

DistanceJoint.GetCurrentLength(): number

Gets the current length.

Returns

  • number — The length.

DistanceJoint.SetStiffness(stiffness: number)

Sets the linear stiffness.

Parameters

  • stiffness: number — The stiffness in N/m.

DistanceJoint.GetStiffness(): number

Gets the linear stiffness.

Returns

  • number — The stiffness in N/m.

DistanceJoint.SetDamping(damping: number)

Sets the linear damping.

Parameters

  • damping: number — The damping in N*s/m.

DistanceJoint.GetDamping(): number

Gets the linear damping.

Returns

  • number — The damping in N*s/m.

PulleyJointDef

interface PulleyJointDef extends JointDefBase

PulleyJointDef.type: typeof b2JointType.e_pulleyJoint

PulleyJointDef.groundAnchorA?: Vector3

The first ground anchor in world coordinates. It never moves.

PulleyJointDef.groundAnchorB?: Vector3

The second ground anchor in world coordinates. It never moves.

PulleyJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

PulleyJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

PulleyJointDef.lengthA?: number

The reference length of the segment attached to bodyA.

PulleyJointDef.lengthB?: number

The reference length of the segment attached to bodyB.

PulleyJointDef.ratio?: number

The pulley ratio, used to simulate a block-and-tackle.

PulleyJoint

interface PulleyJoint extends Joint

PulleyJoint.GetGroundAnchorA(): Vector3

Gets the first ground anchor.

Returns

  • Vector3 — The anchor.

PulleyJoint.GetGroundAnchorB(): Vector3

Gets the second ground anchor.

Returns

  • Vector3 — The anchor.

PulleyJoint.GetLengthA(): number

Gets the reference length of the segment attached to bodyA.

Returns

  • number — The length.

PulleyJoint.GetLengthB(): number

Gets the reference length of the segment attached to bodyB.

Returns

  • number — The length.

PulleyJoint.GetRatio(): number

Gets the pulley ratio.

Returns

  • number — The ratio.

PulleyJoint.GetCurrentLengthA(): number

Gets the current length of the segment attached to bodyA.

Returns

  • number — The length.

PulleyJoint.GetCurrentLengthB(): number

Gets the current length of the segment attached to bodyB.

Returns

  • number — The length.

MouseJointDef

interface MouseJointDef extends JointDefBase

MouseJointDef.type: typeof b2JointType.e_mouseJoint

MouseJointDef.target?: Vector3

The initial world target point, assumed to coincide with the body anchor.

MouseJointDef.maxForce?: number

The maximum force used to move the body, usually a multiple of its weight.

MouseJointDef.stiffness?: number

The linear stiffness in N/m.

MouseJointDef.damping?: number

The linear damping in N*s/m.

MouseJoint

interface MouseJoint extends Joint

MouseJoint.SetTarget(target: Vector3)

Sets the target point.

Parameters

  • target: Vector3 — The world target.

MouseJoint.GetTarget(): Vector3

Gets the target point.

Returns

  • Vector3 — The world target.

MouseJoint.SetMaxForce(force: number)

Sets the maximum force.

Parameters

  • force: number — The force in N.

MouseJoint.GetMaxForce(): number

Gets the maximum force.

Returns

  • number — The force in N.

MouseJoint.SetStiffness(stiffness: number)

Sets the linear stiffness.

Parameters

  • stiffness: number — The stiffness in N/m.

MouseJoint.GetStiffness(): number

Gets the linear stiffness.

Returns

  • number — The stiffness in N/m.

MouseJoint.SetDamping(damping: number)

Sets the linear damping.

Parameters

  • damping: number — The damping in N*s/m.

MouseJoint.GetDamping(): number

Gets the linear damping.

Returns

  • number — The damping in N*s/m.

GearJointDef

interface GearJointDef extends JointDefBase

GearJointDef.type: typeof b2JointType.e_gearJoint

GearJointDef.joint1: RevoluteJoint | PrismaticJoint

The first revolute or prismatic joint.

GearJointDef.joint2: RevoluteJoint | PrismaticJoint

The second revolute or prismatic joint.

GearJointDef.ratio?: number

The gear ratio.

GearJoint

interface GearJoint extends Joint

GearJoint.GetJoint1(): Joint

Gets the first connected joint.

Returns

  • Joint — The joint.

GearJoint.GetJoint2(): Joint

Gets the second connected joint.

Returns

  • Joint — The joint.

GearJoint.SetRatio(ratio: number)

Sets the gear ratio.

Parameters

  • ratio: number — The ratio.

GearJoint.GetRatio(): number

Gets the gear ratio.

Returns

  • number — The ratio.

WheelJointDef

interface WheelJointDef extends JointDefBase

WheelJointDef.type: typeof b2JointType.e_wheelJoint

WheelJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

WheelJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

WheelJointDef.localAxisA?: Vector3

The translation axis in bodyA.

WheelJointDef.enableLimit?: boolean

Enables the joint limit.

WheelJointDef.lowerTranslation?: number

The lower translation limit, usually in meters.

WheelJointDef.upperTranslation?: number

The upper translation limit, usually in meters.

WheelJointDef.enableMotor?: boolean

Enables the joint motor.

WheelJointDef.maxMotorTorque?: number

The maximum motor torque, usually in N-m.

WheelJointDef.motorSpeed?: number

The desired motor speed in radians per second.

WheelJointDef.stiffness?: number

The suspension stiffness, typically in N/m.

WheelJointDef.damping?: number

The suspension damping, typically in N*s/m.

WheelJoint

interface WheelJoint extends Joint

WheelJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

WheelJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

WheelJoint.GetLocalAxisA(): Vector3

Gets the joint axis relative to bodyA.

Returns

  • Vector3 — The axis.

WheelJoint.GetJointTranslation(): number

Gets the current joint translation.

Returns

  • number — The translation, usually in meters.

WheelJoint.GetJointLinearSpeed(): number

Gets the current joint linear speed.

Returns

  • number — The speed, usually in meters per second.

WheelJoint.GetJointAngle(): number

Gets the current joint angle.

Returns

  • number — The angle in radians.

WheelJoint.GetJointAngularSpeed(): number

Gets the current joint angular speed.

Returns

  • number — The speed in radians per second.

WheelJoint.IsLimitEnabled(): boolean

Whether the joint limit is enabled.

Returns

  • boolean — true if it is.

WheelJoint.EnableLimit(flag: boolean)

Enables or disables the joint translation limit.

Parameters

  • flag: boolean — true enables it.

WheelJoint.GetLowerLimit(): number

Gets the lower joint translation limit.

Returns

  • number — The limit, usually in meters.

WheelJoint.GetUpperLimit(): number

Gets the upper joint translation limit.

Returns

  • number — The limit, usually in meters.

WheelJoint.SetLimits(lower: number, upper: number)

Sets the joint translation limits.

Parameters

  • lower: number — The lower limit, usually in meters.
  • upper: number — The upper limit, usually in meters.

WheelJoint.IsMotorEnabled(): boolean

Whether the joint motor is enabled.

Returns

  • boolean — true if it is.

WheelJoint.EnableMotor(flag: boolean)

Enables or disables the joint motor.

Parameters

  • flag: boolean — true enables it.

WheelJoint.SetMotorSpeed(speed: number)

Sets the motor speed.

Parameters

  • speed: number — The speed, usually in radians per second.

WheelJoint.GetMotorSpeed(): number

Gets the motor speed.

Returns

  • number — The speed, usually in radians per second.

WheelJoint.SetMaxMotorTorque(torque: number)

Sets the maximum motor torque.

Parameters

  • torque: number — The torque, usually in N-m.

WheelJoint.GetMaxMotorTorque(): number

Gets the maximum motor torque.

Returns

  • number — The torque, usually in N-m.

WheelJoint.GetMotorTorque(inv_dt: number): number

Gets the current motor torque.

Parameters

  • inv_dt: number — The inverse time step.

Returns

  • number — The torque, usually in N-m.

WheelJoint.SetStiffness(stiffness: number)

Sets the spring stiffness.

Parameters

  • stiffness: number — The stiffness, typically in N/m.

WheelJoint.GetStiffness(): number

Gets the spring stiffness.

Returns

  • number — The stiffness, typically in N/m.

WheelJoint.SetDamping(damping: number)

Sets the spring damping.

Parameters

  • damping: number — The damping, typically in N*s/m.

WheelJoint.GetDamping(): number

Gets the spring damping.

Returns

  • number — The damping, typically in N*s/m.

WeldJointDef

interface WeldJointDef extends JointDefBase

WeldJointDef.type: typeof b2JointType.e_weldJoint

WeldJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

WeldJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

WeldJointDef.referenceAngle?: number

bodyB's angle minus bodyA's angle in the reference state, in radians.

WeldJointDef.stiffness?: number

The rotational stiffness in N*m. 0 disables softness.

WeldJointDef.damping?: number

The rotational damping in Nms.

WeldJoint

interface WeldJoint extends Joint

WeldJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

WeldJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

WeldJoint.GetReferenceAngle(): number

Gets the reference angle.

Returns

  • number — The angle in radians.

WeldJoint.SetStiffness(stiffness: number)

Sets the stiffness.

Parameters

  • stiffness: number — The stiffness in N*m.

WeldJoint.GetStiffness(): number

Gets the stiffness.

Returns

  • number — The stiffness in N*m.

WeldJoint.SetDamping(damping: number)

Sets the damping.

Parameters

  • damping: number — The damping in Nms.

WeldJoint.GetDamping(): number

Gets the damping.

Returns

  • number — The damping in Nms.

FrictionJointDef

interface FrictionJointDef extends JointDefBase

FrictionJointDef.type: typeof b2JointType.e_frictionJoint

FrictionJointDef.localAnchorA?: Vector3

The anchor relative to bodyA's origin.

FrictionJointDef.localAnchorB?: Vector3

The anchor relative to bodyB's origin.

FrictionJointDef.maxForce?: number

The maximum friction force in N.

FrictionJointDef.maxTorque?: number

The maximum friction torque in N-m.

FrictionJoint

interface FrictionJoint extends Joint

FrictionJoint.GetLocalAnchorA(): Vector3

Gets the anchor relative to bodyA's origin.

Returns

  • Vector3 — The anchor.

FrictionJoint.GetLocalAnchorB(): Vector3

Gets the anchor relative to bodyB's origin.

Returns

  • Vector3 — The anchor.

FrictionJoint.SetMaxForce(force: number)

Sets the maximum friction force.

Parameters

  • force: number — The force in N.

FrictionJoint.GetMaxForce(): number

Gets the maximum friction force.

Returns

  • number — The force in N.

FrictionJoint.SetMaxTorque(torque: number)

Sets the maximum friction torque.

Parameters

  • torque: number — The torque in N*m.

FrictionJoint.GetMaxTorque(): number

Gets the maximum friction torque.

Returns

  • number — The torque in N*m.

MotorJointDef

interface MotorJointDef extends JointDefBase

MotorJointDef.type: typeof b2JointType.e_motorJoint

MotorJointDef.linearOffset?: Vector3

bodyB's position minus bodyA's position, in bodyA's frame, in meters.

MotorJointDef.angularOffset?: number

bodyB's angle minus bodyA's angle, in radians.

MotorJointDef.maxForce?: number

The maximum motor force in N.

MotorJointDef.maxTorque?: number

The maximum motor torque in N-m.

MotorJointDef.correctionFactor?: number

The position correction factor, from 0 to 1.

MotorJoint

interface MotorJoint extends Joint

MotorJoint.SetLinearOffset(linearOffset: Vector3)

Sets the target linear offset, in bodyA's frame.

Parameters

  • linearOffset: Vector3 — The offset in meters.

MotorJoint.GetLinearOffset(): Vector3

Gets the target linear offset, in bodyA's frame.

Returns

  • Vector3 — The offset in meters.

MotorJoint.SetAngularOffset(angularOffset: number)

Sets the target angular offset.

Parameters

  • angularOffset: number — The offset in radians.

MotorJoint.GetAngularOffset(): number

Gets the target angular offset.

Returns

  • number — The offset in radians.

MotorJoint.SetMaxForce(force: number)

Sets the maximum friction force.

Parameters

  • force: number — The force in N.

MotorJoint.GetMaxForce(): number

Gets the maximum friction force.

Returns

  • number — The force in N.

MotorJoint.SetMaxTorque(torque: number)

Sets the maximum friction torque.

Parameters

  • torque: number — The torque in N*m.

MotorJoint.GetMaxTorque(): number

Gets the maximum friction torque.

Returns

  • number — The torque in N*m.

MotorJoint.SetCorrectionFactor(factor: number)

Sets the position correction factor.

Parameters

  • factor: number — The factor, from 0 to 1.

MotorJoint.GetCorrectionFactor(): number

Gets the position correction factor.

Returns

  • number — The factor, from 0 to 1.

Profile

Profile.step: number

Profile.collide: number

Profile.solve: number

Profile.solveInit: number

Profile.solveVelocity: number

Profile.solvePosition: number

Profile.broadphase: number

Profile.solveTOI: number

DebugDrawCallbacks

DebugDrawCallbacks.flags?: number

What to draw: a sum of {@link b2Draw} bits.

DebugDrawCallbacks.DrawPolygon?: (this: void, vertices: Vec2[], color: Color) => void

Draws a closed polygon outline.

DebugDrawCallbacks.DrawSolidPolygon?: (this: void, vertices: Vec2[], color: Color) => void

Draws a filled polygon.

DebugDrawCallbacks.DrawCircle?: (this: void, center: Vec2, radius: number, color: Color) => void

Draws a circle outline.

DebugDrawCallbacks.DrawSolidCircle?: (this: void, center: Vec2, radius: number, axis: Vec2, color: Color) => void

Draws a filled circle, with axis marking its rotation.

DebugDrawCallbacks.DrawSegment?: (this: void, p1: Vec2, p2: Vec2, color: Color) => void

Draws a line segment.

DebugDrawCallbacks.DrawTransform?: (this: void, xf: Transform) => void

Draws a transform frame.

DebugDrawCallbacks.DrawPoint?: (this: void) => void

Accepted, but never called: the extension's Draw::DrawPoint has an empty body.

Color

Color.r: number

Color.g: number

Color.b: number

Color.a: number

PolygonShape

interface PolygonShape extends Shape

PolygonShape.Clone(): PolygonShape

Copies the shape.

Returns

  • PolygonShape — A new polygon shape.

PolygonShape.Set(points: Vector3[])

Creates a convex hull from local points. The points may be reordered, and collinear points are kept, which can lead to poor stacking.

Parameters

  • points: Vector3[] — From 3 to 8 points.

PolygonShape.SetAsBox(hx: number, hy: number)

Makes an axis-aligned box centered on the local origin.

Parameters

  • hx: number — The half-width.
  • hy: number — The half-height.

PolygonShape.SetAsBox(hx: number, hy: number, center: Vector3, angle: number)

Makes an oriented box.

Parameters

  • hx: number — The half-width.
  • hy: number — The half-height.
  • center: Vector3 — The center of the box in local coordinates.
  • angle: number — The rotation of the box in radians.

PolygonShape.Validate(): boolean

Validates convexity. This is a very time consuming operation.

Returns

  • boolean — true if the polygon is valid.

PolygonShape.GetCentroid(): Vector3

Gets the centroid.

Returns

  • Vector3 — The centroid.

PolygonShape.GetVertices(): Vector3[]

Gets the vertices.

Returns

  • Vector3[] — The vertices.

PolygonShape.GetNormals(): Vector3[]

Gets the edge normals.

Returns

  • Vector3[] — The normals.

PolygonShape.GetCount(): number

Gets the number of vertices.

Returns

  • number — The vertex count.

CircleShape

interface CircleShape extends Shape

CircleShape.Clone(): CircleShape

Copies the shape.

Returns

  • CircleShape — A new circle shape.

CircleShape.SetPosition(position: Vector3)

Sets the center relative to the body origin.

Parameters

  • position: Vector3 — The center.

CircleShape.GetPosition(): Vector3

Gets the center relative to the body origin.

Returns

  • Vector3 — The center.

ChainShape

interface ChainShape extends Shape

ChainShape.Clone(): ChainShape

Copies the shape.

Returns

  • ChainShape — A new chain shape.

ChainShape.RayCast(input: RayCastInput, transform: Transform, childIndex: number): RayCastOutput | undefined

Casts a ray against one segment of the chain.

Parameters

  • input: RayCastInput — The ray-cast input parameters.
  • transform: Transform — The transform applied to the shape.
  • childIndex: number — The segment index. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • RayCastOutput | undefined — The hit, or nil if the ray misses.

ChainShape.ComputeAABB(xf: Transform, childIndex: number): AABB

Computes the axis-aligned bounding box of one segment of the chain.

Parameters

  • xf: Transform — The world transform of the shape.
  • childIndex: number — The segment index. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • AABB — The box.

ChainShape.Clear()

Clears all vertices.

ChainShape.CreateLoop(vertices: Vector3[])

Creates a loop, connecting the last vertex to the first.

Parameters

  • vertices: Vector3[] — The vertices, which are copied.

ChainShape.CreateChain(vertices: Vector3[], prevVertex: Vector3, nextVertex: Vector3)

Creates a chain with ghost vertices that connect it to other chains.

Parameters

  • vertices: Vector3[] — The vertices, which are copied.
  • prevVertex: Vector3 — The vertex of the previous chain that connects to the start.
  • nextVertex: Vector3 — The vertex of the next chain that connects to the end.

ChainShape.GetChildEdge(index: number): EdgeShape

Gets one segment of the chain as an edge.

Parameters

  • index: number — The segment index. 0️⃣ 0-based; passed to box2d unchanged.

Returns

  • EdgeShape — The segment.

ChainShape.GetVertices(): Vector3[]

Gets the vertices.

Returns

  • Vector3[] — The vertices.

ChainShape.GetNextVertex(): Vector3

Gets the ghost vertex after the end.

Returns

  • Vector3 — The vertex.

ChainShape.GetPrevVertex(): Vector3

Gets the ghost vertex before the start.

Returns

  • Vector3 — The vertex.

ChainShape.GetCount(): number

Gets the number of vertices.

Returns

  • number — The vertex count.

EdgeShape

interface EdgeShape extends Shape

EdgeShape.Clone(): EdgeShape

Copies the shape.

Returns

  • EdgeShape — A new edge shape.

EdgeShape.SetOneSided(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3)

Makes the edge part of a sequence. v0 precedes the edge and v3 follows it; they smooth movement across junctions. The collision becomes one-sided, with the normal pointing right when looking from v1 to v2.

Parameters

  • v0: Vector3 — The vertex before the edge.
  • v1: Vector3 — The edge start.
  • v2: Vector3 — The edge end.
  • v3: Vector3 — The vertex after the edge.

EdgeShape.SetTwoSided(v1: Vector3, v2: Vector3)

Makes the edge isolated. The collision is two-sided.

Parameters

  • v1: Vector3 — The edge start.
  • v2: Vector3 — The edge end.

EdgeShape.GetVertex0(): Vector3

Gets the vertex before the edge.

Returns

  • Vector3 — The vertex.

EdgeShape.GetVertex1(): Vector3

Gets the edge start.

Returns

  • Vector3 — The vertex.

EdgeShape.GetVertex2(): Vector3

Gets the edge end.

Returns

  • Vector3 — The vertex.

EdgeShape.GetVertex3(): Vector3

Gets the vertex after the edge.

Returns

  • Vector3 — The vertex.

EdgeShape.IsOneSided(): boolean

Whether the edge collides on one side only.

Returns

  • boolean — true if the edge is one-sided.

On this page

FunctionsNewWorld(gravity?: Vector3): WorldNewDebugDraw(data: DebugDrawCallbacks): DebugDrawNewPolygonShape(): PolygonShapeNewCircleShape(): CircleShapeNewChainShape(): ChainShapeNewEdgeShape(): EdgeShapeb2LinearStiffness(frequencyHertz: number, dampingRatio: number, bodyA: Body, bodyB: Body): LuaMultiReturn<[ stiffness: number, damping: number ]>b2AngularStiffness(frequencyHertz: number, dampingRatio: number, bodyA: Body, bodyB: Body): LuaMultiReturn<[ stiffness: number, damping: number ]>InitializeRevoluteJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): RevoluteJointDefInitializePrismaticJointDef(bodyA: Body, bodyB: Body, anchor: Vector3, axis: Vector3): PrismaticJointDefInitializeDistanceJointDef(bodyA: Body, bodyB: Body, anchorA: Vector3, anchorB: Vector3): DistanceJointDefInitializePulleyJointDef(bodyA: Body, bodyB: Body, groundAnchorA: Vector3, groundAnchorB: Vector3, anchorA: Vector3, anchorB: Vector3, ratio: number): PulleyJointDefInitializeMouseJointDef(bodyA: Body, bodyB: Body): MouseJointDefInitializeGearJointDef(bodyA: Body, bodyB: Body, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint): GearJointDefInitializeWheelJointDef(bodyA: Body, bodyB: Body, anchor: Vector3, axis: Vector3): WheelJointDefInitializeWeldJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): WeldJointDefInitializeFrictionJointDef(bodyA: Body, bodyB: Body, anchor: Vector3): FrictionJointDefInitializeMotorJointDef(bodyA: Body, bodyB: Body): MotorJointDefVariablesb2Shape.e_circle: 0b2Shape.e_edge: 1b2Shape.e_polygon: 2b2Shape.e_chain: 3b2BodyType.b2_staticBody: 0b2BodyType.b2_kinematicBody: 1b2BodyType.b2_dynamicBody: 2b2JointType.e_unknownJoint: 0b2JointType.e_revoluteJoint: 1b2JointType.e_prismaticJoint: 2b2JointType.e_distanceJoint: 3b2JointType.e_pulleyJoint: 4b2JointType.e_mouseJoint: 5b2JointType.e_gearJoint: 6b2JointType.e_wheelJoint: 7b2JointType.e_weldJoint: 8b2JointType.e_frictionJoint: 9b2JointType.e_ropeJoint: 10b2JointType.e_motorJoint: 11b2Draw.e_shapeBit: 1b2Draw.e_jointBit: 2b2Draw.e_aabbBit: 4b2Draw.e_pairBit: 8b2Draw.e_centerOfMassBit: 16b2Manifold_Type.e_circles: 0b2Manifold_Type.e_faceA: 1b2Manifold_Type.e_faceB: 2Typestype ShapeType = typeof b2Shape.e_circle | typeof b2Shape.e_edge | typeof b2Shape.e_polygon | typeof b2Shape.e_chaintype ShapeTable = CircleShapeTable | OneSidedEdgeShapeTable | TwoSidedEdgeShapeTable | BoxShapeTable | PolygonShapeTable | ChainShapeTabletype BoxShapeTable = AxisAlignedBoxShapeTable | OrientedBoxShapeTabletype ChainShapeTable = LoopChainShapeTable | OpenChainShapeTabletype BodyType = typeof b2BodyType.b2_staticBody | typeof b2BodyType.b2_kinematicBody | typeof b2BodyType.b2_dynamicBodytype ManifoldType = typeof b2Manifold_Type.e_circles | typeof b2Manifold_Type.e_faceA | typeof b2Manifold_Type.e_faceBtype JointType = typeof b2JointType.e_unknownJoint | typeof b2JointType.e_revoluteJoint | typeof b2JointType.e_prismaticJoint | typeof b2JointType.e_distanceJoint | typeof b2JointType.e_pulleyJoint | typeof b2JointType.e_mouseJoint | typeof b2JointType.e_gearJoint | typeof b2JointType.e_wheelJoint | typeof b2JointType.e_weldJoint | typeof b2JointType.e_frictionJoint | typeof b2JointType.e_ropeJoint | typeof b2JointType.e_motorJointtype JointDef = RevoluteJointDef | PrismaticJointDef | DistanceJointDef | PulleyJointDef | MouseJointDef | GearJointDef | WheelJointDef | WeldJointDef | FrictionJointDef | MotorJointDefWorldWorld.SetDestructionListener(listener: DestructionListener | undefined)World.SetContactListener(listener: ContactListener | undefined)World.SetDebugDraw(draw: DebugDraw | undefined)World.CreateBody(bodyDef?: BodyDef): BodyWorld.DestroyBody(body: Body)World.CreateJoint(def: RevoluteJointDef): RevoluteJointWorld.CreateJoint(def: PrismaticJointDef): PrismaticJointWorld.CreateJoint(def: DistanceJointDef): DistanceJointWorld.CreateJoint(def: PulleyJointDef): PulleyJointWorld.CreateJoint(def: MouseJointDef): MouseJointWorld.CreateJoint(def: GearJointDef): GearJointWorld.CreateJoint(def: WheelJointDef): WheelJointWorld.CreateJoint(def: WeldJointDef): WeldJointWorld.CreateJoint(def: FrictionJointDef): FrictionJointWorld.CreateJoint(def: MotorJointDef): MotorJointWorld.CreateJoint(def: JointDef): JointWorld.DestroyJoint(joint: Joint)World.Step(timeStep: number, velocityIterations: number, positionIterations: number)World.ClearForces()World.DebugDraw()World.RayCast(callback: (this: void, fixture: Fixture, point: Vector3, normal: Vector3, fraction: number) => number, point1: Vector3, point2: Vector3)World.QueryAABB(callback: (this: void, fixture: Fixture) => boolean, aabb: AABB)World.GetBodyList(): Body | undefinedWorld.GetContactList(): Contact | undefinedWorld.GetJointList(): Joint | undefinedWorld.SetAllowSleeping(flag: boolean)World.GetAllowSleeping(): booleanWorld.SetWarmStarting(flag: boolean)World.GetWarmStarting(): booleanWorld.SetContinuousPhysics(flag: boolean)World.GetContinuousPhysics(): booleanWorld.SetSubStepping(flag: boolean)World.GetSubStepping(): booleanWorld.GetProxyCount(): numberWorld.GetBodyCount(): numberWorld.GetJointCount(): numberWorld.GetContactCount(): numberWorld.GetTreeHeight(): numberWorld.GetTreeBalance(): numberWorld.GetTreeQuality(): numberWorld.SetGravity(gravity: Vector3)World.GetGravity(): Vector3World.IsLocked(): booleanWorld.SetAutoClearForces(flag: boolean)World.GetAutoClearForces(): booleanWorld.ShiftOrigin(newOrigin: Vector3)World.GetProfile(): ProfileWorld.Dump()World.Destroy()DestructionListenerDestructionListener.SayGoodbyeFixture?: (this: void, fixture: Fixture) => voidDestructionListener.SayGoodbyeJoint?: (this: void, joint: Joint) => voidFixtureFixture.GetType(): ShapeTypeFixture.GetShape(): ShapeFixture.SetSensor(sensor: boolean)Fixture.IsSensor(): booleanFixture.SetFilterData(filter: Filter)Fixture.GetFilterData(): FilterFixture.Refilter()Fixture.GetBody(): BodyFixture.GetNext(): Fixture | undefinedFixture.GetUserData(): object | undefinedFixture.SetUserData(userdata: object | undefined)Fixture.TestPoint(point: Vector3): booleanFixture.RayCast(input: RayCastInput, childIndex: number): RayCastOutput | undefinedFixture.GetMassData(): MassDataFixture.GetDensity(): numberFixture.SetDensity(density: number)Fixture.GetFriction(): numberFixture.SetFriction(friction: number)Fixture.GetRestitution(): numberFixture.SetRestitution(restitution: number)Fixture.GetRestitutionThreshold(): numberFixture.SetRestitutionThreshold(threshold: number)Fixture.GetAABB(childIndex: number): AABBFixture.Dump(bodyIndex: number)ShapeShape.Clone(): ShapeShape.GetType(): ShapeTypeShape.GetChildCount(): numberShape.TestPoint(xf: Transform, p: Vector3): booleanShape.RayCast(input: RayCastInput, transform: Transform, childIndex?: number): RayCastOutput | undefinedShape.ComputeAABB(xf: Transform, childIndex?: number): AABBShape.ComputeMass(density: number): MassDataShape.GetRadius(): numberShape.SetRadius(radius: number)TransformTransform.p: Vector3Transform.q: numberRayCastInputRayCastInput.p1: Vector3RayCastInput.p2: Vector3RayCastInput.maxFraction: numberRayCastOutputRayCastOutput.normal: Vector3RayCastOutput.fraction: numberAABBAABB.lowerBound: Vector3AABB.upperBound: Vector3MassDataMassData.mass: numberMassData.center: Vec2MassData.I: numberVec2Vec2.x: numberVec2.y: numberFilterFilter.categoryBits: numberFilter.maskBits: numberFilter.groupIndex: numberBodyBody.CreateFixture(def: FixtureDef): FixtureBody.CreateFixture(shape: Shape | ShapeTable, density: number): FixtureBody.DestroyFixture(fixture: Fixture)Body.SetTransform(position: Vector3, angle?: number)Body.GetTransform(): TransformBody.GetPosition(): Vector3Body.GetPositionRaw(): LuaMultiReturn<[ number, number ]>Body.GetAngle(): numberBody.GetWorldCenter(): Vector3Body.GetLocalCenter(): Vector3Body.SetLinearVelocity(velocity: Vector3)Body.GetLinearVelocity(): Vector3Body.SetAngularVelocity(omega: number)Body.GetAngularVelocity(): numberBody.ApplyForce(force: Vector3, point: Vector3, wake: boolean)Body.ApplyForceToCenter(force: Vector3, wake: boolean)Body.ApplyTorque(torque: number, wake: boolean)Body.ApplyLinearImpulse(impulse: Vector3, point: Vector3, wake: boolean)Body.ApplyLinearImpulseToCenter(impulse: Vector3, wake: boolean)Body.ApplyAngularImpulse(impulse: number, wake: boolean)Body.GetMass(): numberBody.GetInertia(): numberBody.ResetMassData()Body.GetMassData(): MassDataBody.SetMassData(data: MassData)Body.GetWorldPoint(localPoint: Vector3): Vector3Body.GetWorldVector(localVector: Vector3): Vector3Body.GetLocalPoint(worldPoint: Vector3): Vector3Body.GetLocalVector(worldVector: Vector3): Vector3Body.GetLinearVelocityFromLocalPoint(localPoint: Vector3): Vector3Body.GetLinearVelocityFromWorldPoint(worldPoint: Vector3): Vector3Body.SetLinearDamping(linearDamping: number)Body.GetLinearDamping(): numberBody.SetAngularDamping(angularDamping: number)Body.GetAngularDamping(): numberBody.SetGravityScale(scale: number)Body.GetGravityScale(): numberBody.SetType(type: BodyType)Body.GetType(): BodyTypeBody.SetBullet(flag: boolean)Body.IsBullet(): booleanBody.SetSleepingAllowed(flag: boolean)Body.IsSleepingAllowed(): booleanBody.SetAwake(flag: boolean)Body.IsAwake(): booleanBody.SetEnabled(flag: boolean)Body.IsEnabled(): booleanBody.SetFixedRotation(flag: boolean)Body.IsFixedRotation(): booleanBody.GetNext(): Body | undefinedBody.GetFixtureList(): Fixture | undefinedBody.GetContactList(): Contact[]Body.GetJointList(): Joint[]Body.GetUserData(): object | undefinedBody.SetUserData(data: object | undefined)Body.GetWorld(): WorldBody.Dump()FixtureDefFixtureDef.shape: Shape | ShapeTableFixtureDef.userData?: objectFixtureDef.friction?: numberFixtureDef.restitution?: numberFixtureDef.restitutionThreshold?: numberFixtureDef.density?: numberFixtureDef.isSensor?: booleanFixtureDef.filter?: FilterCircleShapeTableCircleShapeTable.shape: typeof b2Shape.e_circleCircleShapeTable.circle_radius: numberCircleShapeTable.circle_position?: Vector3OneSidedEdgeShapeTableOneSidedEdgeShapeTable.shape: typeof b2Shape.e_edgeOneSidedEdgeShapeTable.edge_two_sided?: falseOneSidedEdgeShapeTable.edge_v0: Vector3OneSidedEdgeShapeTable.edge_v1: Vector3OneSidedEdgeShapeTable.edge_v2: Vector3OneSidedEdgeShapeTable.edge_v3: Vector3TwoSidedEdgeShapeTableTwoSidedEdgeShapeTable.shape: typeof b2Shape.e_edgeTwoSidedEdgeShapeTable.edge_two_sided: trueTwoSidedEdgeShapeTable.edge_v1: Vector3TwoSidedEdgeShapeTable.edge_v2: Vector3AxisAlignedBoxShapeTableAxisAlignedBoxShapeTable.shape: typeof b2Shape.e_polygonAxisAlignedBoxShapeTable.box: trueAxisAlignedBoxShapeTable.box_hx: numberAxisAlignedBoxShapeTable.box_hy: numberAxisAlignedBoxShapeTable.box_center?: neverAxisAlignedBoxShapeTable.box_angle?: neverOrientedBoxShapeTableOrientedBoxShapeTable.shape: typeof b2Shape.e_polygonOrientedBoxShapeTable.box: trueOrientedBoxShapeTable.box_hx: numberOrientedBoxShapeTable.box_hy: numberOrientedBoxShapeTable.box_center: Vector3OrientedBoxShapeTable.box_angle: numberPolygonShapeTablePolygonShapeTable.shape: typeof b2Shape.e_polygonPolygonShapeTable.box?: falsePolygonShapeTable.polygon_vertices: Vector3[]LoopChainShapeTableLoopChainShapeTable.shape: typeof b2Shape.e_chainLoopChainShapeTable.chain_vertices: Vector3[]LoopChainShapeTable.chain_loop: trueOpenChainShapeTableOpenChainShapeTable.shape: typeof b2Shape.e_chainOpenChainShapeTable.chain_vertices: Vector3[]OpenChainShapeTable.chain_loop?: falseOpenChainShapeTable.chain_prev_vertex: Vector3OpenChainShapeTable.chain_next_vertex: Vector3ContactContact.GetNext(): Contact | undefinedContact.GetManifold(): ManifoldContact.GetWorldManifold(): WorldManifoldContact.IsTouching(): booleanContact.SetEnabled(flag: boolean)Contact.IsEnabled(): booleanContact.GetFixtureA(): FixtureContact.GetChildIndexA(): numberContact.GetFixtureB(): FixtureContact.GetChildIndexB(): numberContact.SetFriction(friction: number)Contact.GetFriction(): numberContact.ResetFriction()Contact.SetRestitution(restitution: number)Contact.GetRestitution(): numberContact.ResetRestitution()Contact.SetRestitutionThreshold(threshold: number)Contact.GetRestitutionThreshold(): numberContact.ResetRestitutionThreshold()Contact.SetTangentSpeed(speed: number)Contact.GetTangentSpeed(): numberManifoldManifold.type: ManifoldTypeManifold.localPoint: Vector3Manifold.localNormal: Vector3Manifold.pointCount: numberManifold.points: ManifoldPoint[]ManifoldPointManifoldPoint.localPoint: Vector3ManifoldPoint.normalImpulse: numberManifoldPoint.tangentImpulse: numberManifoldPoint.id: ContactIDContactIDContactID.cf: ContactFeatureContactID.key: numberContactFeatureContactFeature.indexA: numberContactFeature.indexB: numberContactFeature.typeA: numberContactFeature.typeB: numberWorldManifoldWorldManifold.normal: Vector3WorldManifold.points: Vector3[]WorldManifold.separations: number[]JointJoint.GetType(): JointTypeJoint.GetBodyA(): BodyJoint.GetBodyB(): BodyJoint.GetAnchorA(): Vector3Joint.GetAnchorB(): Vector3Joint.GetReactionForce(inv_dt: number): Vector3Joint.GetReactionTorque(inv_dt: number): numberJoint.GetNext(): Joint | undefinedJoint.GetUserData(): object | undefinedJoint.SetUserData(userdata: object | undefined)Joint.IsEnabled(): booleanJoint.GetCollideConnected(): booleanJoint.Dump()Joint.ShiftOrigin(newOrigin: Vector3)ContactListenerContactListener.BeginContact?: (this: void, contact: Contact) => voidContactListener.EndContact?: (this: void, contact: Contact) => voidContactListener.PreSolve?: (this: void, contact: Contact, oldManifold: Manifold) => voidContactListener.PostSolve?: (this: void, contact: Contact, impulse: ContactImpulse) => voidContactImpulseContactImpulse.normalImpulses: number[]ContactImpulse.tangentImpulses: number[]ContactImpulse.count: numberDebugDrawDebugDraw.SetFlags(flags: number)DebugDraw.GetFlags(): numberDebugDraw.ClearFlags(flags: number)DebugDraw.Destroy()BodyDefBodyDef.type?: BodyTypeBodyDef.position?: Vector3BodyDef.angle?: numberBodyDef.linearVelocity?: Vector3BodyDef.angularVelocity?: numberBodyDef.linearDamping?: numberBodyDef.angularDamping?: numberBodyDef.allowSleep?: booleanBodyDef.awake?: booleanBodyDef.fixedRotation?: booleanBodyDef.bullet?: booleanBodyDef.enabled?: booleanBodyDef.userData?: objectBodyDef.gravityScale?: numberRevoluteJointDefinterface RevoluteJointDef extends JointDefBaseRevoluteJointDef.type: typeof b2JointType.e_revoluteJointRevoluteJointDef.localAnchorA?: Vector3RevoluteJointDef.localAnchorB?: Vector3RevoluteJointDef.referenceAngle?: numberRevoluteJointDef.enableLimit?: booleanRevoluteJointDef.lowerAngle?: numberRevoluteJointDef.upperAngle?: numberRevoluteJointDef.enableMotor?: booleanRevoluteJointDef.motorSpeed?: numberRevoluteJointDef.maxMotorTorque?: numberJointDefBaseJointDefBase.bodyA: BodyJointDefBase.bodyB: BodyJointDefBase.collideConnected?: booleanRevoluteJointinterface RevoluteJoint extends JointRevoluteJoint.GetLocalAnchorA(): Vector3RevoluteJoint.GetLocalAnchorB(): Vector3RevoluteJoint.GetReferenceAngle(): numberRevoluteJoint.GetJointAngle(): numberRevoluteJoint.GetJointSpeed(): numberRevoluteJoint.IsLimitEnabled(): booleanRevoluteJoint.EnableLimit(flag: boolean)RevoluteJoint.GetLowerLimit(): numberRevoluteJoint.GetUpperLimit(): numberRevoluteJoint.SetLimits(lower: number, upper: number)RevoluteJoint.IsMotorEnabled(): booleanRevoluteJoint.EnableMotor(flag: boolean)RevoluteJoint.SetMotorSpeed(speed: number)RevoluteJoint.GetMotorSpeed(): numberRevoluteJoint.SetMaxMotorTorque(torque: number)RevoluteJoint.GetMaxMotorTorque(): numberRevoluteJoint.GetMotorTorque(inv_dt: number): numberPrismaticJointDefinterface PrismaticJointDef extends JointDefBasePrismaticJointDef.type: typeof b2JointType.e_prismaticJointPrismaticJointDef.localAnchorA?: Vector3PrismaticJointDef.localAnchorB?: Vector3PrismaticJointDef.localAxisA?: Vector3PrismaticJointDef.referenceAngle?: numberPrismaticJointDef.enableLimit?: booleanPrismaticJointDef.lowerTranslation?: numberPrismaticJointDef.upperTranslation?: numberPrismaticJointDef.enableMotor?: booleanPrismaticJointDef.maxMotorForce?: numberPrismaticJointDef.motorSpeed?: numberPrismaticJointinterface PrismaticJoint extends JointPrismaticJoint.GetLocalAnchorA(): Vector3PrismaticJoint.GetLocalAnchorB(): Vector3PrismaticJoint.GetLocalAxisA(): Vector3PrismaticJoint.GetReferenceAngle(): numberPrismaticJoint.GetJointTranslation(): numberPrismaticJoint.GetJointSpeed(): numberPrismaticJoint.IsLimitEnabled(): booleanPrismaticJoint.EnableLimit(flag: boolean)PrismaticJoint.GetLowerLimit(): numberPrismaticJoint.GetUpperLimit(): numberPrismaticJoint.SetLimits(lower: number, upper: number)PrismaticJoint.IsMotorEnabled(): booleanPrismaticJoint.EnableMotor(flag: boolean)PrismaticJoint.SetMotorSpeed(speed: number)PrismaticJoint.GetMotorSpeed(): numberPrismaticJoint.SetMaxMotorForce(force: number)PrismaticJoint.GetMaxMotorForce(): numberPrismaticJoint.GetMotorForce(inv_dt: number): numberDistanceJointDefinterface DistanceJointDef extends JointDefBaseDistanceJointDef.type: typeof b2JointType.e_distanceJointDistanceJointDef.localAnchorA?: Vector3DistanceJointDef.localAnchorB?: Vector3DistanceJointDef.length?: numberDistanceJointDef.minLength?: numberDistanceJointDef.maxLength?: numberDistanceJointDef.stiffness?: numberDistanceJointDef.damping?: numberDistanceJointinterface DistanceJoint extends JointDistanceJoint.GetLocalAnchorA(): Vector3DistanceJoint.GetLocalAnchorB(): Vector3DistanceJoint.GetLength(): numberDistanceJoint.SetLength(length: number)DistanceJoint.GetMinLength(): numberDistanceJoint.SetMinLength(minLength: number)DistanceJoint.GetMaxLength(): numberDistanceJoint.SetMaxLength(maxLength: number)DistanceJoint.GetCurrentLength(): numberDistanceJoint.SetStiffness(stiffness: number)DistanceJoint.GetStiffness(): numberDistanceJoint.SetDamping(damping: number)DistanceJoint.GetDamping(): numberPulleyJointDefinterface PulleyJointDef extends JointDefBasePulleyJointDef.type: typeof b2JointType.e_pulleyJointPulleyJointDef.groundAnchorA?: Vector3PulleyJointDef.groundAnchorB?: Vector3PulleyJointDef.localAnchorA?: Vector3PulleyJointDef.localAnchorB?: Vector3PulleyJointDef.lengthA?: numberPulleyJointDef.lengthB?: numberPulleyJointDef.ratio?: numberPulleyJointinterface PulleyJoint extends JointPulleyJoint.GetGroundAnchorA(): Vector3PulleyJoint.GetGroundAnchorB(): Vector3PulleyJoint.GetLengthA(): numberPulleyJoint.GetLengthB(): numberPulleyJoint.GetRatio(): numberPulleyJoint.GetCurrentLengthA(): numberPulleyJoint.GetCurrentLengthB(): numberMouseJointDefinterface MouseJointDef extends JointDefBaseMouseJointDef.type: typeof b2JointType.e_mouseJointMouseJointDef.target?: Vector3MouseJointDef.maxForce?: numberMouseJointDef.stiffness?: numberMouseJointDef.damping?: numberMouseJointinterface MouseJoint extends JointMouseJoint.SetTarget(target: Vector3)MouseJoint.GetTarget(): Vector3MouseJoint.SetMaxForce(force: number)MouseJoint.GetMaxForce(): numberMouseJoint.SetStiffness(stiffness: number)MouseJoint.GetStiffness(): numberMouseJoint.SetDamping(damping: number)MouseJoint.GetDamping(): numberGearJointDefinterface GearJointDef extends JointDefBaseGearJointDef.type: typeof b2JointType.e_gearJointGearJointDef.joint1: RevoluteJoint | PrismaticJointGearJointDef.joint2: RevoluteJoint | PrismaticJointGearJointDef.ratio?: numberGearJointinterface GearJoint extends JointGearJoint.GetJoint1(): JointGearJoint.GetJoint2(): JointGearJoint.SetRatio(ratio: number)GearJoint.GetRatio(): numberWheelJointDefinterface WheelJointDef extends JointDefBaseWheelJointDef.type: typeof b2JointType.e_wheelJointWheelJointDef.localAnchorA?: Vector3WheelJointDef.localAnchorB?: Vector3WheelJointDef.localAxisA?: Vector3WheelJointDef.enableLimit?: booleanWheelJointDef.lowerTranslation?: numberWheelJointDef.upperTranslation?: numberWheelJointDef.enableMotor?: booleanWheelJointDef.maxMotorTorque?: numberWheelJointDef.motorSpeed?: numberWheelJointDef.stiffness?: numberWheelJointDef.damping?: numberWheelJointinterface WheelJoint extends JointWheelJoint.GetLocalAnchorA(): Vector3WheelJoint.GetLocalAnchorB(): Vector3WheelJoint.GetLocalAxisA(): Vector3WheelJoint.GetJointTranslation(): numberWheelJoint.GetJointLinearSpeed(): numberWheelJoint.GetJointAngle(): numberWheelJoint.GetJointAngularSpeed(): numberWheelJoint.IsLimitEnabled(): booleanWheelJoint.EnableLimit(flag: boolean)WheelJoint.GetLowerLimit(): numberWheelJoint.GetUpperLimit(): numberWheelJoint.SetLimits(lower: number, upper: number)WheelJoint.IsMotorEnabled(): booleanWheelJoint.EnableMotor(flag: boolean)WheelJoint.SetMotorSpeed(speed: number)WheelJoint.GetMotorSpeed(): numberWheelJoint.SetMaxMotorTorque(torque: number)WheelJoint.GetMaxMotorTorque(): numberWheelJoint.GetMotorTorque(inv_dt: number): numberWheelJoint.SetStiffness(stiffness: number)WheelJoint.GetStiffness(): numberWheelJoint.SetDamping(damping: number)WheelJoint.GetDamping(): numberWeldJointDefinterface WeldJointDef extends JointDefBaseWeldJointDef.type: typeof b2JointType.e_weldJointWeldJointDef.localAnchorA?: Vector3WeldJointDef.localAnchorB?: Vector3WeldJointDef.referenceAngle?: numberWeldJointDef.stiffness?: numberWeldJointDef.damping?: numberWeldJointinterface WeldJoint extends JointWeldJoint.GetLocalAnchorA(): Vector3WeldJoint.GetLocalAnchorB(): Vector3WeldJoint.GetReferenceAngle(): numberWeldJoint.SetStiffness(stiffness: number)WeldJoint.GetStiffness(): numberWeldJoint.SetDamping(damping: number)WeldJoint.GetDamping(): numberFrictionJointDefinterface FrictionJointDef extends JointDefBaseFrictionJointDef.type: typeof b2JointType.e_frictionJointFrictionJointDef.localAnchorA?: Vector3FrictionJointDef.localAnchorB?: Vector3FrictionJointDef.maxForce?: numberFrictionJointDef.maxTorque?: numberFrictionJointinterface FrictionJoint extends JointFrictionJoint.GetLocalAnchorA(): Vector3FrictionJoint.GetLocalAnchorB(): Vector3FrictionJoint.SetMaxForce(force: number)FrictionJoint.GetMaxForce(): numberFrictionJoint.SetMaxTorque(torque: number)FrictionJoint.GetMaxTorque(): numberMotorJointDefinterface MotorJointDef extends JointDefBaseMotorJointDef.type: typeof b2JointType.e_motorJointMotorJointDef.linearOffset?: Vector3MotorJointDef.angularOffset?: numberMotorJointDef.maxForce?: numberMotorJointDef.maxTorque?: numberMotorJointDef.correctionFactor?: numberMotorJointinterface MotorJoint extends JointMotorJoint.SetLinearOffset(linearOffset: Vector3)MotorJoint.GetLinearOffset(): Vector3MotorJoint.SetAngularOffset(angularOffset: number)MotorJoint.GetAngularOffset(): numberMotorJoint.SetMaxForce(force: number)MotorJoint.GetMaxForce(): numberMotorJoint.SetMaxTorque(torque: number)MotorJoint.GetMaxTorque(): numberMotorJoint.SetCorrectionFactor(factor: number)MotorJoint.GetCorrectionFactor(): numberProfileProfile.step: numberProfile.collide: numberProfile.solve: numberProfile.solveInit: numberProfile.solveVelocity: numberProfile.solvePosition: numberProfile.broadphase: numberProfile.solveTOI: numberDebugDrawCallbacksDebugDrawCallbacks.flags?: numberDebugDrawCallbacks.DrawPolygon?: (this: void, vertices: Vec2[], color: Color) => voidDebugDrawCallbacks.DrawSolidPolygon?: (this: void, vertices: Vec2[], color: Color) => voidDebugDrawCallbacks.DrawCircle?: (this: void, center: Vec2, radius: number, color: Color) => voidDebugDrawCallbacks.DrawSolidCircle?: (this: void, center: Vec2, radius: number, axis: Vec2, color: Color) => voidDebugDrawCallbacks.DrawSegment?: (this: void, p1: Vec2, p2: Vec2, color: Color) => voidDebugDrawCallbacks.DrawTransform?: (this: void, xf: Transform) => voidDebugDrawCallbacks.DrawPoint?: (this: void) => voidColorColor.r: numberColor.g: numberColor.b: numberColor.a: numberPolygonShapeinterface PolygonShape extends ShapePolygonShape.Clone(): PolygonShapePolygonShape.Set(points: Vector3[])PolygonShape.SetAsBox(hx: number, hy: number)PolygonShape.SetAsBox(hx: number, hy: number, center: Vector3, angle: number)PolygonShape.Validate(): booleanPolygonShape.GetCentroid(): Vector3PolygonShape.GetVertices(): Vector3[]PolygonShape.GetNormals(): Vector3[]PolygonShape.GetCount(): numberCircleShapeinterface CircleShape extends ShapeCircleShape.Clone(): CircleShapeCircleShape.SetPosition(position: Vector3)CircleShape.GetPosition(): Vector3ChainShapeinterface ChainShape extends ShapeChainShape.Clone(): ChainShapeChainShape.RayCast(input: RayCastInput, transform: Transform, childIndex: number): RayCastOutput | undefinedChainShape.ComputeAABB(xf: Transform, childIndex: number): AABBChainShape.Clear()ChainShape.CreateLoop(vertices: Vector3[])ChainShape.CreateChain(vertices: Vector3[], prevVertex: Vector3, nextVertex: Vector3)ChainShape.GetChildEdge(index: number): EdgeShapeChainShape.GetVertices(): Vector3[]ChainShape.GetNextVertex(): Vector3ChainShape.GetPrevVertex(): Vector3ChainShape.GetCount(): numberEdgeShapeinterface EdgeShape extends ShapeEdgeShape.Clone(): EdgeShapeEdgeShape.SetOneSided(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3)EdgeShape.SetTwoSided(v1: Vector3, v2: Vector3)EdgeShape.GetVertex0(): Vector3EdgeShape.GetVertex1(): Vector3EdgeShape.GetVertex2(): Vector3EdgeShape.GetVertex3(): Vector3EdgeShape.IsOneSided(): boolean