Class: TouchConstraint
physics/constraints/touch.TouchConstraint
Constrains an CollisionObject's position to a BLZTouch's world position in the current Camera's view.
Hierarchy
โณ
TouchConstraint
Constructors
constructor
โข new TouchConstraint(obj
, touch
)
Creates an TouchConstraint.
Parameters
Name | Type | Description |
---|---|---|
obj | CollisionObject | The object to constrain |
touch | BLZTouch | The touch to constrain the object to |
Overrides
Defined in
src/physics/constraints/touch.ts:19
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
touch
โข touch: BLZTouch
Defined in
src/physics/constraints/touch.ts:11
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
getTouchPosition
โธ Private
getTouchPosition(): vec2
Gets the touch's world position in the current camera's view.
Returns
vec2
Defined in
src/physics/constraints/touch.ts:49
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
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 touch constraint's listeners from it's BLZTouch.
Returns
void
Defined in
src/physics/constraints/touch.ts:37
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
touchListener
โธ Private
touchListener(): void
Returns
void
Defined in
src/physics/constraints/touch.ts:41
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