11 KiB
Planck.js API Doc › Globals › Contact
Class: Contact
The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.
Hierarchy
- Contact
Index
Constructors
Methods
- evaluate
- flagForFiltering
- getChildIndexA
- getChildIndexB
- getFixtureA
- getFixtureB
- getFriction
- getManifold
- getNext
- getRestitution
- getTangentSpeed
- getWorldManifold
- initConstraint
- initVelocityConstraint
- isEnabled
- isTouching
- resetFriction
- resetRestitution
- setEnabled
- setFriction
- setRestitution
- setTangentSpeed
- solvePositionConstraint
- solvePositionConstraintTOI
- solveVelocityConstraint
- storeConstraintImpulses
- update
- warmStartConstraint
Constructors
constructor
+ new Contact(fA: Fixture, indexA: number, fB: Fixture, indexB: number, evaluateFcn: EvaluateFunction): Contact
Defined in src/dynamics/Contact.ts:196
Parameters:
| Name | Type |
|---|---|
fA |
Fixture |
indexA |
number |
fB |
Fixture |
indexB |
number |
evaluateFcn |
EvaluateFunction |
Returns: Contact
Methods
evaluate
▸ evaluate(manifold: Manifold, xfA: Transform, xfB: Transform): void
Defined in src/dynamics/Contact.ts:433
Called by Update method, and implemented by subclasses.
Parameters:
| Name | Type |
|---|---|
manifold |
Manifold |
xfA |
Transform |
xfB |
Transform |
Returns: void
flagForFiltering
▸ flagForFiltering(): void
Defined in src/dynamics/Contact.ts:365
Flag this contact for filtering. Filtering will occur the next time step.
Returns: void
getChildIndexA
▸ getChildIndexA(): number
Defined in src/dynamics/Contact.ts:351
Get the child primitive index for fixture A.
Returns: number
getChildIndexB
▸ getChildIndexB(): number
Defined in src/dynamics/Contact.ts:358
Get the child primitive index for fixture B.
Returns: number
getFixtureA
▸ getFixtureA(): Fixture
Defined in src/dynamics/Contact.ts:337
Get fixture A in this contact.
Returns: Fixture
getFixtureB
▸ getFixtureB(): Fixture
Defined in src/dynamics/Contact.ts:344
Get fixture B in this contact.
Returns: Fixture
getFriction
▸ getFriction(): number
Defined in src/dynamics/Contact.ts:380
Get the friction.
Returns: number
getManifold
▸ getManifold(): Manifold
Defined in src/dynamics/Contact.ts:287
Get the contact manifold. Do not modify the manifold unless you understand the internals of the library.
Returns: Manifold
getNext
▸ getNext(): Contact | null
Defined in src/dynamics/Contact.ts:330
Get the next contact in the world's contact list.
Returns: Contact | null
getRestitution
▸ getRestitution(): number
Defined in src/dynamics/Contact.ts:403
Get the restitution.
Returns: number
getTangentSpeed
▸ getTangentSpeed(): number
Defined in src/dynamics/Contact.ts:426
Get the desired tangent speed. In meters per second.
Returns: number
getWorldManifold
▸ getWorldManifold(worldManifold: WorldManifold | null | undefined): WorldManifold | undefined
Defined in src/dynamics/Contact.ts:294
Get the world manifold.
Parameters:
| Name | Type |
|---|---|
worldManifold |
WorldManifold | null | undefined |
Returns: WorldManifold | undefined
initConstraint
▸ initConstraint(step: TimeStep): void
Defined in src/dynamics/Contact.ts:215
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
initVelocityConstraint
▸ initVelocityConstraint(step: TimeStep): void
Defined in src/dynamics/Contact.ts:657
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
isEnabled
▸ isEnabled(): boolean
Defined in src/dynamics/Contact.ts:316
Has this contact been disabled?
Returns: boolean
isTouching
▸ isTouching(): boolean
Defined in src/dynamics/Contact.ts:323
Is this contact touching?
Returns: boolean
resetFriction
▸ resetFriction(): void
Defined in src/dynamics/Contact.ts:387
Reset the friction mixture to the default value.
Returns: void
resetRestitution
▸ resetRestitution(): void
Defined in src/dynamics/Contact.ts:410
Reset the restitution to the default value.
Returns: void
setEnabled
▸ setEnabled(flag: boolean): void
Defined in src/dynamics/Contact.ts:309
Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).
Parameters:
| Name | Type |
|---|---|
flag |
boolean |
Returns: void
setFriction
▸ setFriction(friction: number): void
Defined in src/dynamics/Contact.ts:373
Override the default friction mixture. You can call this in ContactListener.preSolve. This value persists until set or reset.
Parameters:
| Name | Type |
|---|---|
friction |
number |
Returns: void
setRestitution
▸ setRestitution(restitution: number): void
Defined in src/dynamics/Contact.ts:396
Override the default restitution mixture. You can call this in ContactListener.preSolve. The value persists until you set or reset.
Parameters:
| Name | Type |
|---|---|
restitution |
number |
Returns: void
setTangentSpeed
▸ setTangentSpeed(speed: number): void
Defined in src/dynamics/Contact.ts:419
Set the desired tangent speed for a conveyor belt behavior. In meters per second.
Parameters:
| Name | Type |
|---|---|
speed |
number |
Returns: void
solvePositionConstraint
▸ solvePositionConstraint(step: TimeStep): number
Defined in src/dynamics/Contact.ts:525
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: number
solvePositionConstraintTOI
▸ solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number
Defined in src/dynamics/Contact.ts:529
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
toiA |
Body |
toiB |
Body |
Returns: number
solveVelocityConstraint
▸ solveVelocityConstraint(step: TimeStep): void
Defined in src/dynamics/Contact.ts:825
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
storeConstraintImpulses
▸ storeConstraintImpulses(step: TimeStep): void
Defined in src/dynamics/Contact.ts:817
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void
update
▸ update(listener?: object): void
Defined in src/dynamics/Contact.ts:447
Updates the contact manifold and touching status.
Note: do not assume the fixture AABBs are overlapping or are valid.
Parameters:
▪Optional listener: object
| Name | Type | Description |
|---|---|---|
beginContact |
- | |
endContact |
- | |
preSolve |
Returns: void
warmStartConstraint
▸ warmStartConstraint(step: TimeStep): void
Defined in src/dynamics/Contact.ts:776
Parameters:
| Name | Type |
|---|---|
step |
TimeStep |
Returns: void