Class: MouseConstraint
physics/constraints/mouse.MouseConstraint
Constrains an CollisionObject's position to the mouse's world position in the current Camera's view.
Hierarchy
โณ
MouseConstraint
Constructors
constructor
โข new MouseConstraint(obj)
Creates an MouseConstraint.
Parameters
| Name | Type | Description | 
|---|---|---|
obj | CollisionObject | The object to constrain | 
Overrides
Defined in
src/physics/constraints/mouse.ts:16
Properties
a
โข a: CollisionObject
Inherited from
Defined in
src/physics/constraints/constraint.ts:22
anchorA
โข anchorA: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:23
anchorB
โข anchorB: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:27
b
โข b: CollisionObject
Inherited from
Defined in
src/physics/constraints/constraint.ts:26
bias
โข bias: vec2
Inherited from
Defined in
src/physics/constraints/pivot.ts:18
errorBias
โข errorBias: number
Inherited from
Defined in
src/physics/constraints/constraint.ts:32
jAcc
โข jAcc: vec2
Inherited from
Defined in
src/physics/constraints/pivot.ts:19
k
โข k: mat2
Inherited from
Defined in
src/physics/constraints/pivot.ts:20
maxBias
โข maxBias: number = Infinity
Inherited from
Defined in
src/physics/constraints/constraint.ts:33
maxForce
โข maxForce: number = Infinity
Inherited from
Defined in
src/physics/constraints/constraint.ts:35
point
โข point: vec2
Inherited from
Defined in
src/physics/constraints/constraint.ts:30
rotA
โข rotA: number = 0
Inherited from
Defined in
src/physics/constraints/constraint.ts:24
rotB
โข rotB: number = 0
Inherited from
Defined in
src/physics/constraints/constraint.ts:28
Methods
applyImpulses
โธ Protected applyImpulses(impulse, direction): void
Parameters
| Name | Type | 
|---|---|
impulse | number | 
direction | vec2 | 
Returns
void
Inherited from
Defined in
src/physics/constraints/constraint.ts:111
โธ Protected applyImpulses(impulse): void
Parameters
| Name | Type | 
|---|---|
impulse | vec2 | 
Returns
void
Inherited from
Defined in
src/physics/constraints/constraint.ts:113
biasCoef
โธ Protected biasCoef(dt): number
Calculates the velocity bias coefficient.
Parameters
| Name | Type | Description | 
|---|---|---|
dt | number | The time since the last update | 
Returns
number
Inherited from
Defined in
src/physics/constraints/constraint.ts:182
calculateRelativeVelocity
โธ Protected calculateRelativeVelocity(pointA, pointB): vec2
Calculate the relative velocity of the bodies in the constraint.
Parameters
| Name | Type | Description | 
|---|---|---|
pointA | vec2 | The anchor point on body a | 
pointB | vec2 | The anchor point on body b | 
Returns
vec2
The relative velocity between body a and b or body a and the anchor point
Inherited from
PivotConstraint.calculateRelativeVelocity
Defined in
src/physics/constraints/constraint.ts:164
getMousePosition
โธ Private getMousePosition(): vec2
Gets the mouse's world position in the current camera's view.
Returns
vec2
Defined in
src/physics/constraints/mouse.ts:44
isBodyToPoint
โธ isBodyToPoint(): boolean
Determines wether or not the constraint is between a body and a point.
Returns
boolean
Wether or not the constraint is between a body and a point.
Inherited from
Defined in
src/physics/constraints/constraint.ts:107
kScalar
โธ Protected kScalar(n): number
Computes the k scalar value for the constraint.
Parameters
| Name | Type | Description | 
|---|---|---|
n | vec2 | The constraint's delta normal | 
Returns
number
The k scalar value for the constraint
Inherited from
Defined in
src/physics/constraints/constraint.ts:205
kScalarBody
โธ Protected kScalarBody(body, r, n): number
Computes the k scalar value for the given body.
Parameters
| Name | Type | Description | 
|---|---|---|
body | CollisionObject | The body to calculate for | 
r | vec2 | The anchor point on the body | 
n | vec2 | The constraint's delta normal | 
Returns
number
The k scalar value for the given body
Inherited from
Defined in
src/physics/constraints/constraint.ts:194
kTensor
โธ Protected kTensor(): mat2
Computes the k tensor matrix for the constraint.
Returns
mat2
k tensor matrix
Inherited from
Defined in
src/physics/constraints/constraint.ts:220
mouseListener
โธ Private mouseListener(): void
Returns
void
Defined in
src/physics/constraints/mouse.ts:36
postSolve
โธ postSolve(): void
Applies the cached impulse.
Returns
void
Inherited from
Defined in
src/physics/constraints/pivot.ts:119
preSolve
โธ preSolve(dt): void
Prepares for constraint solving.
Parameters
| Name | Type | 
|---|---|
dt | number | 
Returns
void
Inherited from
Defined in
src/physics/constraints/pivot.ts:65
remove
โธ remove(): void
Removes the mouse constraint's listeners from the canvas.
Returns
void
Defined in
src/physics/constraints/mouse.ts:32
solve
โธ solve(dt): void
Computes and applies the impulse to keep the bodies at the joint's length.
Parameters
| Name | Type | Description | 
|---|---|---|
dt | number | The time since the last update | 
Returns
void
Inherited from
Defined in
src/physics/constraints/pivot.ts:95
updateAnchors
โธ Protected updateAnchors(): void
Updates the constraint's anchor points to match the rotations of their bodies.
Returns
void
Inherited from
Defined in
src/physics/constraints/constraint.ts:141