7.0 KiB
Planck.js API Doc › Globals › Joint
Class: Joint
The base joint class. Joints are used to constraint two bodies together in various fashions. Some joints also feature limits and motors.
Hierarchy
-
Joint
Index
Constructors
Methods
- getAnchorA
- getAnchorB
- getBodyA
- getBodyB
- getCollideConnected
- getNext
- getReactionForce
- getReactionTorque
- getType
- getUserData
- initVelocityConstraints
- isActive
- setUserData
- shiftOrigin
- solvePositionConstraints
- solveVelocityConstraints
Constructors
constructor
+ new Joint(def: JointDef): Joint
Defined in src/dynamics/Joint.ts:110
Parameters:
| Name | Type |
|---|---|
def |
JointDef |
Returns: Joint
+ new Joint(def: JointOpt, bodyA: Body, bodyB: Body): Joint
Defined in src/dynamics/Joint.ts:112
Parameters:
| Name | Type |
|---|---|
def |
JointOpt |
bodyA |
Body |
bodyB |
Body |
Returns: Joint
Methods
Abstract getAnchorA
▸ getAnchorA(): Vec2
Defined in src/dynamics/Joint.ts:197
Get the anchor point on bodyA in world coordinates.
Returns: Vec2
Abstract getAnchorB
▸ getAnchorB(): Vec2
Defined in src/dynamics/Joint.ts:202
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
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
getNext
▸ getNext(): Joint
Defined in src/dynamics/Joint.ts:173
Get the next joint the world joint list.
Returns: Joint
Abstract getReactionForce
▸ getReactionForce(inv_dt: number): Vec2
Defined in src/dynamics/Joint.ts:207
Get the reaction force on bodyB at the joint anchor in Newtons.
Parameters:
| Name | Type |
|---|---|
inv_dt |
number |
Returns: Vec2
Abstract getReactionTorque
▸ getReactionTorque(inv_dt: number): number
Defined in src/dynamics/Joint.ts:212
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
Defined in src/dynamics/Joint.ts:177
Returns: unknown
Abstract initVelocityConstraints
▸ initVelocityConstraints(step: TimeStep): void
Defined in src/dynamics/Joint.ts:219
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
Defined in src/dynamics/Joint.ts:181
Parameters:
| Name | Type |
|---|---|
data |
unknown |
Returns: void
shiftOrigin
▸ shiftOrigin(newOrigin: Vec2): void
Defined in src/dynamics/Joint.ts:217
Shift the origin for any points stored in world coordinates.
Parameters:
| Name | Type |
|---|---|
newOrigin |
Vec2 |
Returns: void
Abstract solvePositionConstraints
▸ solvePositionConstraints(step: TimeStep): boolean
Defined in src/dynamics/Joint.ts:226
This returns true if the position errors are within tolerance.
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: boolean
Abstract solveVelocityConstraints
▸ solveVelocityConstraints(step: TimeStep): void
Defined in src/dynamics/Joint.ts:221
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void