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

12 KiB
Raw Permalink Blame History

Planck.js API Doc › Globals › MouseJoint

Class: MouseJoint

A mouse joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces.

NOTE: this joint is not documented in the manual because it was developed to be used in the testbed. If you want to learn how to use the mouse joint, look at the testbed.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new MouseJoint(def: MouseJointDef): MouseJoint

Overrides Joint.constructor

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

Parameters:

Name Type
def MouseJointDef

Returns: MouseJoint

+ new MouseJoint(def: MouseJointOpt, bodyA: Body, bodyB: Body, target: Vec2): MouseJoint

Overrides Joint.constructor

Defined in src/dynamics/joint/MouseJoint.ts:108

Parameters:

Name Type
def MouseJointOpt
bodyA Body
bodyB Body
target Vec2

Returns: MouseJoint

Properties

Static TYPE

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

Defined in src/dynamics/joint/MouseJoint.ts:89

Methods

getAnchorA

▸ getAnchorA(): Vec2

Overrides Joint.getAnchorA

Defined in src/dynamics/joint/MouseJoint.ts:246

Get the anchor point on bodyA in world coordinates.

Returns: Vec2


getAnchorB

▸ getAnchorB(): Vec2

Overrides Joint.getAnchorB

Defined in src/dynamics/joint/MouseJoint.ts:253

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


getDampingRatio

▸ getDampingRatio(): number

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

Get the damping ratio (dimensionless).

Returns: number


getFrequency

▸ getFrequency(): number

Defined in src/dynamics/joint/MouseJoint.ts:225

Get the frequency in Hertz.

Returns: number


getMaxForce

▸ getMaxForce(): number

Defined in src/dynamics/joint/MouseJoint.ts:211

Get the maximum force in Newtons.

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/MouseJoint.ts:260

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/MouseJoint.ts:267

Get the reaction torque on bodyB in N*m.

Parameters:

Name Type
inv_dt number

Returns: number


getTarget

▸ getTarget(): Vec2

Defined in src/dynamics/joint/MouseJoint.ts:197

Returns: Vec2


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/MouseJoint.ts:278

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


setDampingRatio

▸ setDampingRatio(ratio: number): void

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

Set the damping ratio (dimensionless).

Parameters:

Name Type
ratio number

Returns: void


setFrequency

▸ setFrequency(hz: number): void

Defined in src/dynamics/joint/MouseJoint.ts:218

Set the frequency in Hertz.

Parameters:

Name Type
hz number

Returns: void


setMaxForce

▸ setMaxForce(force: number): void

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

Set the maximum force in Newtons.

Parameters:

Name Type
force number

Returns: void


setTarget

▸ setTarget(target: Vec2): void

Defined in src/dynamics/joint/MouseJoint.ts:190

Use this to update the target point.

Parameters:

Name Type
target Vec2

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

Overrides Joint.shiftOrigin

Defined in src/dynamics/joint/MouseJoint.ts:274

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/MouseJoint.ts:384

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/MouseJoint.ts:353

Parameters:

Name Type
step TimeStep

Returns: void