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

12 KiB
Raw Permalink Blame History

Planck.js API Doc › Globals › MotorJoint

Class: MotorJoint

A motor joint is used to control the relative motion between two bodies. A typical usage is to control the movement of a dynamic body with respect to the ground.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new MotorJoint(def: MotorJointDef): MotorJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/MotorJoint.ts:104

Parameters:

Name Type
def MotorJointDef

Returns: MotorJoint

+ new MotorJoint(def: MotorJointOpt, bodyA: Body, bodyB: Body): MotorJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/MotorJoint.ts:106

Parameters:

Name Type
def MotorJointOpt
bodyA Body
bodyB Body

Returns: MotorJoint

Properties

Static TYPE

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

Defined in src/dynamics/joint/MotorJoint.ts:82

Methods

getAnchorA

▸ getAnchorA(): Vec2

Overrides Joint.getAnchorA

Defined in src/dynamics/joint/MotorJoint.ts:254

Get the anchor point on bodyA in world coordinates.

Returns: Vec2


getAnchorB

▸ getAnchorB(): Vec2

Overrides Joint.getAnchorB

Defined in src/dynamics/joint/MotorJoint.ts:261

Get the anchor point on bodyB in world coordinates.

Returns: Vec2


getAngularOffset

▸ getAngularOffset(): number

Defined in src/dynamics/joint/MotorJoint.ts:247

Returns: number


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


getCorrectionFactor

▸ getCorrectionFactor(): number

Defined in src/dynamics/joint/MotorJoint.ts:216

Get the position correction factor in the range [0,1].

Returns: number


getLinearOffset

▸ getLinearOffset(): Vec2

Defined in src/dynamics/joint/MotorJoint.ts:232

Returns: Vec2


getMaxForce

▸ getMaxForce(): number

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

Get the maximum friction force in N.

Returns: number


getMaxTorque

▸ getMaxTorque(): number

Defined in src/dynamics/joint/MotorJoint.ts:201

Get the maximum friction torque in N*m.

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/MotorJoint.ts:268

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/MotorJoint.ts:275

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/MotorJoint.ts:279

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


setAngularOffset

▸ setAngularOffset(angularOffset: number): void

Defined in src/dynamics/joint/MotorJoint.ts:239

Set/get the target angular offset, in radians.

Parameters:

Name Type
angularOffset number

Returns: void


setCorrectionFactor

▸ setCorrectionFactor(factor: number): void

Defined in src/dynamics/joint/MotorJoint.ts:208

Set the position correction factor in the range [0,1].

Parameters:

Name Type
factor number

Returns: void


setLinearOffset

▸ setLinearOffset(linearOffset: Vec2): void

Defined in src/dynamics/joint/MotorJoint.ts:223

Set/get the target linear offset, in frame A, in meters.

Parameters:

Name Type
linearOffset Vec2

Returns: void


setMaxForce

▸ setMaxForce(force: number): void

Defined in src/dynamics/joint/MotorJoint.ts:178

Set the maximum friction force in N.

Parameters:

Name Type
force number

Returns: void


setMaxTorque

▸ setMaxTorque(torque: number): void

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

Set the maximum friction torque in N*m.

Parameters:

Name Type
torque 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/MotorJoint.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/MotorJoint.ts:362

Parameters:

Name Type
step TimeStep

Returns: void