Skip to content

Class: RopeJoint ​

A rope joint enforces a maximum distance between two points on two bodies. It has no other effect.

Warning: if you attempt to change the maximum length during the simulation you will get some non-physical behavior.

A model that would allow you to dynamically modify the length would have some sponginess, so I chose not to implement it that way. See DistanceJoint if you want to dynamically control length.

Extends ​

Constructors ​

Constructor ​

new RopeJoint(def): RopeJoint

Parameters ​

def ​

RopeJointDef

Returns ​

RopeJoint

Overrides ​

Joint.constructor

Constructor ​

new RopeJoint(def, bodyA, bodyB, anchor?): RopeJoint

Parameters ​

def ​

RopeJointOpt

bodyA ​

Body

bodyB ​

Body

anchor? ​

Vec2Value

Returns ​

RopeJoint

Overrides ​

Joint.constructor

Properties ​

style ​

style: Style = {}

Styling for dev-tools.

Inherited from ​

Joint.style


TYPE ​

static TYPE: "rope-joint"

Methods ​

getAnchorA() ​

getAnchorA(): Vec2

Get the anchor point on bodyA in world coordinates.

Returns ​

Vec2

Overrides ​

Joint.getAnchorA


getAnchorB() ​

getAnchorB(): Vec2

Get the anchor point on bodyB in world coordinates.

Returns ​

Vec2

Overrides ​

Joint.getAnchorB


getBodyA() ​

getBodyA(): Body

Get the first body attached to this joint.

Returns ​

Body

Inherited from ​

Joint.getBodyA


getBodyB() ​

getBodyB(): Body

Get the second body attached to this joint.

Returns ​

Body

Inherited from ​

Joint.getBodyB


getCollideConnected() ​

getCollideConnected(): boolean

Get collide connected. Note: modifying the collide connect flag won't work correctly because the flag is only checked when fixture AABBs begin to overlap.

Returns ​

boolean

Inherited from ​

Joint.getCollideConnected


getLimitState() ​

getLimitState(): number

Returns ​

number


getLocalAnchorA() ​

getLocalAnchorA(): Vec2

The local anchor point relative to bodyA's origin.

Returns ​

Vec2


getLocalAnchorB() ​

getLocalAnchorB(): Vec2

The local anchor point relative to bodyB's origin.

Returns ​

Vec2


getMaxLength() ​

getMaxLength(): number

Get the maximum length of the rope.

Returns ​

number


getNext() ​

getNext(): Joint

Get the next joint the world joint list.

Returns ​

Joint

Inherited from ​

Joint.getNext


getReactionForce() ​

getReactionForce(inv_dt): Vec2

Get the reaction force on bodyB at the joint anchor in Newtons.

Parameters ​

inv_dt ​

number

Returns ​

Vec2

Overrides ​

Joint.getReactionForce


getReactionTorque() ​

getReactionTorque(inv_dt): number

Get the reaction torque on bodyB in N*m.

Parameters ​

inv_dt ​

number

Returns ​

number

Overrides ​

Joint.getReactionTorque


getType() ​

getType(): string

Get the type of the concrete joint.

Returns ​

string

Inherited from ​

Joint.getType


getUserData() ​

getUserData(): unknown

Returns ​

unknown

Inherited from ​

Joint.getUserData


initVelocityConstraints() ​

initVelocityConstraints(step): void

Parameters ​

step ​

TimeStep

Returns ​

void

Overrides ​

Joint.initVelocityConstraints


isActive() ​

isActive(): boolean

Short-cut function to determine if either body is inactive.

Returns ​

boolean

Inherited from ​

Joint.isActive


setMaxLength() ​

setMaxLength(length): void

Set the maximum length of the rope.

Parameters ​

length ​

number

Returns ​

void


setUserData() ​

setUserData(data): void

Parameters ​

data ​

unknown

Returns ​

void

Inherited from ​

Joint.setUserData


shiftOrigin() ​

shiftOrigin(newOrigin): void

Shift the origin for any points stored in world coordinates.

Parameters ​

newOrigin ​

Vec2Value

Returns ​

void

Inherited from ​

Joint.shiftOrigin


solvePositionConstraints() ​

solvePositionConstraints(step): boolean

This returns true if the position errors are within tolerance.

Parameters ​

step ​

TimeStep

Returns ​

boolean

Overrides ​

Joint.solvePositionConstraints


solveVelocityConstraints() ​

solveVelocityConstraints(step): void

Parameters ​

step ​

TimeStep

Returns ​

void

Overrides ​

Joint.solveVelocityConstraints