12 KiB
Planck.js API Doc › Globals › DistanceJoint
Class: DistanceJoint
A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.
param Anchor A in global coordination.
param Anchor B in global coordination.
Hierarchy
-
↳ DistanceJoint
Index
Constructors
Properties
Methods
- getAnchorA
- getAnchorB
- getBodyA
- getBodyB
- getCollideConnected
- getDampingRatio
- getFrequency
- getLength
- getLocalAnchorA
- getLocalAnchorB
- getNext
- getReactionForce
- getReactionTorque
- getType
- getUserData
- initVelocityConstraints
- isActive
- setDampingRatio
- setFrequency
- setLength
- setUserData
- shiftOrigin
- solvePositionConstraints
- solveVelocityConstraints
Constructors
constructor
+ new DistanceJoint(def: DistanceJointDef): DistanceJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/DistanceJoint.ts:108
Parameters:
| Name | Type |
|---|---|
def |
DistanceJointDef |
Returns: DistanceJoint
+ new DistanceJoint(def: DistanceJointOpt, bodyA: Body, bodyB: Body, anchorA: Vec2, anchorB: Vec2): DistanceJoint
Overrides Joint.constructor
Defined in src/dynamics/joint/DistanceJoint.ts:110
Parameters:
| Name | Type |
|---|---|
def |
DistanceJointOpt |
bodyA |
Body |
bodyB |
Body |
anchorA |
Vec2 |
anchorB |
Vec2 |
Returns: DistanceJoint
Properties
Static TYPE
▪ TYPE: "distance-joint" = 'distance-joint' as 'distance-joint'
Defined in src/dynamics/joint/DistanceJoint.ts:86
Methods
getAnchorA
▸ getAnchorA(): Vec2
Overrides Joint.getAnchorA
Defined in src/dynamics/joint/DistanceJoint.ts:281
Get the anchor point on bodyA in world coordinates.
Returns: Vec2
getAnchorB
▸ getAnchorB(): Vec2
Overrides Joint.getAnchorB
Defined in src/dynamics/joint/DistanceJoint.ts:288
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
getDampingRatio
▸ getDampingRatio(): number
Defined in src/dynamics/joint/DistanceJoint.ts:274
Returns: number
getFrequency
▸ getFrequency(): number
Defined in src/dynamics/joint/DistanceJoint.ts:266
Returns: number
getLength
▸ getLength(): number
Defined in src/dynamics/joint/DistanceJoint.ts:258
Get the natural length.
Returns: number
getLocalAnchorA
▸ getLocalAnchorA(): Vec2
Defined in src/dynamics/joint/DistanceJoint.ts:236
The local anchor point relative to bodyA's origin.
Returns: Vec2
getLocalAnchorB
▸ getLocalAnchorB(): Vec2
Defined in src/dynamics/joint/DistanceJoint.ts:243
The local anchor point relative to bodyB's origin.
Returns: Vec2
getNext
▸ getNext(): Joint
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/DistanceJoint.ts:295
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/DistanceJoint.ts:302
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/DistanceJoint.ts:306
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
setDampingRatio
▸ setDampingRatio(ratio: number): void
Defined in src/dynamics/joint/DistanceJoint.ts:270
Parameters:
| Name | Type |
|---|---|
ratio |
number |
Returns: void
setFrequency
▸ setFrequency(hz: number): void
Defined in src/dynamics/joint/DistanceJoint.ts:262
Parameters:
| Name | Type |
|---|---|
hz |
number |
Returns: void
setLength
▸ setLength(length: number): void
Defined in src/dynamics/joint/DistanceJoint.ts:251
Set the natural length. Manipulating the length can lead to non-physical behavior when the frequency is zero.
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/DistanceJoint.ts:424
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/DistanceJoint.ts:394
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void