2021-05-11 18:30:36 -07:00

10 KiB
Raw Permalink Blame History

Planck.js API Doc › Globals › RopeJoint

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.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new RopeJoint(def: RopeJointDef): RopeJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/RopeJoint.ts:105

Parameters:

Name Type
def RopeJointDef

Returns: RopeJoint

+ new RopeJoint(def: RopeJointOpt, bodyA: Body, bodyB: Body, anchor: Vec2): RopeJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/RopeJoint.ts:107

Parameters:

Name Type
def RopeJointOpt
bodyA Body
bodyB Body
anchor Vec2

Returns: RopeJoint

Properties

Static TYPE

▪ TYPE: "rope-joint" = 'rope-joint' as 'rope-joint'

Defined in src/dynamics/joint/RopeJoint.ts:83

Methods

getAnchorA

▸ getAnchorA(): Vec2

Overrides Joint.getAnchorA

Defined in src/dynamics/joint/RopeJoint.ts:212

Get the anchor point on bodyA in world coordinates.

Returns: Vec2


getAnchorB

▸ getAnchorB(): Vec2

Overrides Joint.getAnchorB

Defined in src/dynamics/joint/RopeJoint.ts:219

Get the anchor point on bodyB in world coordinates.

Returns: Vec2


getBodyA

▸ getBodyA(): Body

Inherited from Joint.getBodyA

Defined in src/dynamics/Joint.ts:159

Get the first body attached to this joint.

Returns: Body


getBodyB

▸ getBodyB(): Body

Inherited from Joint.getBodyB

Defined in src/dynamics/Joint.ts:166

Get the second body attached to this joint.

Returns: Body


getCollideConnected

▸ getCollideConnected(): boolean

Inherited from Joint.getCollideConnected

Defined in src/dynamics/Joint.ts:190

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


getLimitState

▸ getLimitState(): number

Defined in src/dynamics/joint/RopeJoint.ts:204

Returns: number


getLocalAnchorA

▸ getLocalAnchorA(): Vec2

Defined in src/dynamics/joint/RopeJoint.ts:179

The local anchor point relative to bodyA's origin.

Returns: Vec2


getLocalAnchorB

▸ getLocalAnchorB(): Vec2

Defined in src/dynamics/joint/RopeJoint.ts:186

The local anchor point relative to bodyB's origin.

Returns: Vec2


getMaxLength

▸ getMaxLength(): number

Defined in src/dynamics/joint/RopeJoint.ts:200

Get the maximum length of the rope.

Returns: number


getNext

▸ getNext(): Joint

Inherited from Joint.getNext

Defined in src/dynamics/Joint.ts:173

Get the next joint the world joint list.

Returns: Joint


getReactionForce

▸ getReactionForce(inv_dt: number): Vec2

Overrides Joint.getReactionForce

Defined in src/dynamics/joint/RopeJoint.ts:226

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

Parameters:

Name Type
inv_dt number

Returns: Vec2


getReactionTorque

▸ getReactionTorque(inv_dt: number): number

Overrides Joint.getReactionTorque

Defined in src/dynamics/joint/RopeJoint.ts:233

Get the reaction torque on bodyB in N*m.

Parameters:

Name Type
inv_dt number

Returns: number


getType

▸ getType(): string

Inherited from Joint.getType

Defined in src/dynamics/Joint.ts:152

Get the type of the concrete joint.

Returns: string


getUserData

▸ getUserData(): unknown

Inherited from Joint.getUserData

Defined in src/dynamics/Joint.ts:177

Returns: unknown


initVelocityConstraints

▸ initVelocityConstraints(step: TimeStep): void

Overrides Joint.initVelocityConstraints

Defined in src/dynamics/joint/RopeJoint.ts:237

Parameters:

Name Type
step TimeStep

Returns: void


isActive

▸ isActive(): boolean

Inherited from Joint.isActive

Defined in src/dynamics/Joint.ts:145

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

Returns: boolean


setMaxLength

▸ setMaxLength(length: number): void

Defined in src/dynamics/joint/RopeJoint.ts:193

Set the maximum length of the rope.

Parameters:

Name Type
length number

Returns: void


setUserData

▸ setUserData(data: unknown): void

Inherited from Joint.setUserData

Defined in src/dynamics/Joint.ts:181

Parameters:

Name Type
data unknown

Returns: void


shiftOrigin

▸ shiftOrigin(newOrigin: Vec2): void

Inherited from Joint.shiftOrigin

Defined in src/dynamics/Joint.ts:217

Shift the origin for any points stored in world coordinates.

Parameters:

Name Type
newOrigin Vec2

Returns: void


solvePositionConstraints

▸ solvePositionConstraints(step: TimeStep): boolean

Overrides Joint.solvePositionConstraints

Defined in src/dynamics/joint/RopeJoint.ts:349

This returns true if the position errors are within tolerance.

Parameters:

Name Type
step TimeStep

Returns: boolean


solveVelocityConstraints

▸ solveVelocityConstraints(step: TimeStep): void

Overrides Joint.solveVelocityConstraints

Defined in src/dynamics/joint/RopeJoint.ts:312

Parameters:

Name Type
step TimeStep

Returns: void