12 KiB
Planck.js API Doc › Globals › PulleyJoint
Class: PulleyJoint
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 <= constant
Yes, the force transmitted is scaled by the ratio.
Warning: the pulley joint can get a bit squirrelly by itself. They often work better when combined with prismatic joints. You should also cover the the anchor points with static shapes to prevent one side from going to zero length.
Hierarchy
-
↳ PulleyJoint
Index
Constructors
Properties
Methods
- _serialize
- getAnchorA
- getAnchorB
- getBodyA
- getBodyB
- getCollideConnected
- getCurrentLengthA
- getCurrentLengthB
- getGroundAnchorA
- getGroundAnchorB
- getLengthA
- getLengthB
- getNext
- getRatio
- getReactionForce
- getReactionTorque
- getType
- getUserData
- initVelocityConstraints
- isActive
- setUserData
- shiftOrigin
- solvePositionConstraints
- solveVelocityConstraints
Constructors
constructor
+ new PulleyJoint(def: PulleyJointDef): PulleyJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/PulleyJoint.ts:121
Parameters:
| Name | Type |
|---|---|
def |
PulleyJointDef |
Returns: PulleyJoint
+ new PulleyJoint(def: PulleyJointOpt, bodyA: Body, bodyB: Body, groundA: Vec2, groundB: Vec2, anchorA: Vec2, anchorB: Vec2, ratio: number): PulleyJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/PulleyJoint.ts:123
Parameters:
| Name | Type |
|---|---|
def |
PulleyJointOpt |
bodyA |
Body |
bodyB |
Body |
groundA |
Vec2 |
groundB |
Vec2 |
anchorA |
Vec2 |
anchorB |
Vec2 |
ratio |
number |
Returns: PulleyJoint
Properties
Static MIN_PULLEY_LENGTH
▪ MIN_PULLEY_LENGTH: number = 2
Defined in src/dynamics/joint/PulleyJoint.ts:98
Static TYPE
▪ TYPE: "pulley-joint" = 'pulley-joint' as 'pulley-joint'
Defined in src/dynamics/joint/PulleyJoint.ts:97
Methods
_serialize
▸ _serialize(): object
Overrides void
Defined in src/dynamics/joint/PulleyJoint.ts:178
Returns: object
getAnchorA
▸ getAnchorA(): Vec2
Overrides Joint.getAnchorA
Defined in src/dynamics/joint/PulleyJoint.ts:271
Get the anchor point on bodyA in world coordinates.
Returns: Vec2
getAnchorB
▸ getAnchorB(): Vec2
Overrides Joint.getAnchorB
Defined in src/dynamics/joint/PulleyJoint.ts:278
Get the anchor point on bodyB in world coordinates.
Returns: Vec2
getBodyA
▸ getBodyA(): Body
Defined in src/dynamics/Joint.ts:159
Get the first body attached to this joint.
Returns: Body
getBodyB
▸ getBodyB(): Body
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
getCurrentLengthA
▸ getCurrentLengthA(): number
Defined in src/dynamics/joint/PulleyJoint.ts:243
Get the current length of the segment attached to bodyA.
Returns: number
getCurrentLengthB
▸ getCurrentLengthB(): number
Defined in src/dynamics/joint/PulleyJoint.ts:252
Get the current length of the segment attached to bodyB.
Returns: number
getGroundAnchorA
▸ getGroundAnchorA(): Vec2
Defined in src/dynamics/joint/PulleyJoint.ts:208
Get the first ground anchor.
Returns: Vec2
getGroundAnchorB
▸ getGroundAnchorB(): Vec2
Defined in src/dynamics/joint/PulleyJoint.ts:215
Get the second ground anchor.
Returns: Vec2
getLengthA
▸ getLengthA(): number
Defined in src/dynamics/joint/PulleyJoint.ts:222
Get the current length of the segment attached to bodyA.
Returns: number
getLengthB
▸ getLengthB(): number
Defined in src/dynamics/joint/PulleyJoint.ts:229
Get the current length of the segment attached to bodyB.
Returns: number
getNext
▸ getNext(): Joint
Defined in src/dynamics/Joint.ts:173
Get the next joint the world joint list.
Returns: Joint
getRatio
▸ getRatio(): number
Defined in src/dynamics/joint/PulleyJoint.ts:236
Get the pulley ratio.
Returns: number
getReactionForce
▸ getReactionForce(inv_dt: number): Vec2
Overrides Joint.getReactionForce
Defined in src/dynamics/joint/PulleyJoint.ts:285
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/PulleyJoint.ts:292
Get the reaction torque on bodyB in N*m.
Parameters:
| Name | Type |
|---|---|
inv_dt |
number |
Returns: number
getType
▸ getType(): string
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/PulleyJoint.ts:296
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
isActive
▸ isActive(): boolean
Defined in src/dynamics/Joint.ts:145
Short-cut function to determine if either body is inactive.
Returns: boolean
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
Overrides Joint.shiftOrigin
Defined in src/dynamics/joint/PulleyJoint.ts:263
Shift the origin for any points stored in world coordinates.
Parameters:
| Name | Type | Description |
|---|---|---|
newOrigin |
Vec2 |
Returns: void
solvePositionConstraints
▸ solvePositionConstraints(step: TimeStep): boolean
Overrides Joint.solvePositionConstraints
Defined in src/dynamics/joint/PulleyJoint.ts:406
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/PulleyJoint.ts:376
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void