437 lines
11 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [FrictionJoint](frictionjoint.md)
# Class: FrictionJoint
2021-04-16 17:10:15 +02:00
Friction joint. This is used for top-down friction. It provides 2D
translational friction and angular friction.
**`param`** Anchor in global coordination.
2020-07-28 20:21:55 -07:00
## Hierarchy
2020-07-28 20:21:55 -07:00
* [Joint](joint.md)
2021-04-16 17:10:15 +02:00
2020-07-28 20:21:55 -07:00
↳ **FrictionJoint**
## Index
### Constructors
* [constructor](frictionjoint.md#constructor)
### Properties
* [TYPE](frictionjoint.md#static-type)
### Methods
2021-04-16 17:10:15 +02:00
* [getAnchorA](frictionjoint.md#getanchora)
* [getAnchorB](frictionjoint.md#getanchorb)
* [getBodyA](frictionjoint.md#getbodya)
* [getBodyB](frictionjoint.md#getbodyb)
* [getCollideConnected](frictionjoint.md#getcollideconnected)
2020-07-28 20:21:55 -07:00
* [getLocalAnchorA](frictionjoint.md#getlocalanchora)
* [getLocalAnchorB](frictionjoint.md#getlocalanchorb)
* [getMaxForce](frictionjoint.md#getmaxforce)
* [getMaxTorque](frictionjoint.md#getmaxtorque)
2021-04-16 17:10:15 +02:00
* [getNext](frictionjoint.md#getnext)
* [getReactionForce](frictionjoint.md#getreactionforce)
* [getReactionTorque](frictionjoint.md#getreactiontorque)
* [getType](frictionjoint.md#gettype)
* [getUserData](frictionjoint.md#getuserdata)
* [initVelocityConstraints](frictionjoint.md#initvelocityconstraints)
* [isActive](frictionjoint.md#isactive)
2020-07-28 20:21:55 -07:00
* [setMaxForce](frictionjoint.md#setmaxforce)
* [setMaxTorque](frictionjoint.md#setmaxtorque)
2021-04-16 17:10:15 +02:00
* [setUserData](frictionjoint.md#setuserdata)
* [shiftOrigin](frictionjoint.md#shiftorigin)
* [solvePositionConstraints](frictionjoint.md#solvepositionconstraints)
* [solveVelocityConstraints](frictionjoint.md#solvevelocityconstraints)
2020-07-28 20:21:55 -07:00
## Constructors
### constructor
\+ **new FrictionJoint**(`def`: [FrictionJointDef](../interfaces/frictionjointdef.md)): *[FrictionJoint](frictionjoint.md)*
*Overrides [Joint](joint.md).[constructor](joint.md#constructor)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:99](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L99)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`def` | [FrictionJointDef](../interfaces/frictionjointdef.md) |
**Returns:** *[FrictionJoint](frictionjoint.md)*
\+ **new FrictionJoint**(`def`: [FrictionJointOpt](../interfaces/frictionjointopt.md), `bodyA`: [Body](body.md), `bodyB`: [Body](body.md), `anchor`: [Vec2](vec2.md)): *[FrictionJoint](frictionjoint.md)*
*Overrides [Joint](joint.md).[constructor](joint.md#constructor)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:101](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L101)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`def` | [FrictionJointOpt](../interfaces/frictionjointopt.md) |
`bodyA` | [Body](body.md) |
`bodyB` | [Body](body.md) |
`anchor` | [Vec2](vec2.md) |
**Returns:** *[FrictionJoint](frictionjoint.md)*
## Properties
### `Static` TYPE
2021-04-16 17:10:15 +02:00
▪ **TYPE**: *"friction-joint"* = 'friction-joint' as 'friction-joint'
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:78](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L78)*
2020-07-28 20:21:55 -07:00
## Methods
2021-04-16 17:10:15 +02:00
### getAnchorA
2021-05-11 18:30:36 -07:00
▸ **getAnchorA**(): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getAnchorA](joint.md#abstract-getanchora)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:244](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L244)*
2021-04-16 17:10:15 +02:00
Get the anchor point on bodyA in world coordinates.
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getAnchorB
2021-05-11 18:30:36 -07:00
▸ **getAnchorB**(): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getAnchorB](joint.md#abstract-getanchorb)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:251](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L251)*
2021-04-16 17:10:15 +02:00
Get the anchor point on bodyB in world coordinates.
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getBodyA
2021-05-11 18:30:36 -07:00
▸ **getBodyA**(): *[Body](body.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getBodyA](joint.md#getbodya)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:159](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L159)*
2021-04-16 17:10:15 +02:00
Get the first body attached to this joint.
2021-05-11 18:30:36 -07:00
**Returns:** *[Body](body.md)*
2021-04-16 17:10:15 +02:00
___
### getBodyB
2021-05-11 18:30:36 -07:00
▸ **getBodyB**(): *[Body](body.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getBodyB](joint.md#getbodyb)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:166](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L166)*
2021-04-16 17:10:15 +02:00
Get the second body attached to this joint.
2021-05-11 18:30:36 -07:00
**Returns:** *[Body](body.md)*
2021-04-16 17:10:15 +02:00
___
### getCollideConnected
▸ **getCollideConnected**(): *boolean*
*Inherited from [Joint](joint.md).[getCollideConnected](joint.md#getcollideconnected)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:190](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L190)*
2021-04-16 17:10:15 +02:00
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*
___
2020-07-28 20:21:55 -07:00
### getLocalAnchorA
2021-05-11 18:30:36 -07:00
▸ **getLocalAnchorA**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:200](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L200)*
2021-04-16 17:10:15 +02:00
The local anchor point relative to bodyA's origin.
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
### getLocalAnchorB
2021-05-11 18:30:36 -07:00
▸ **getLocalAnchorB**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:207](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L207)*
2021-04-16 17:10:15 +02:00
The local anchor point relative to bodyB's origin.
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
### getMaxForce
▸ **getMaxForce**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:222](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L222)*
2021-04-16 17:10:15 +02:00
Get the maximum friction force in N.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
### getMaxTorque
▸ **getMaxTorque**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:237](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L237)*
2021-04-16 17:10:15 +02:00
Get the maximum friction torque in N*m.
**Returns:** *number*
___
### getNext
2021-05-11 18:30:36 -07:00
▸ **getNext**(): *[Joint](joint.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getNext](joint.md#getnext)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:173](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L173)*
2021-04-16 17:10:15 +02:00
Get the next joint the world joint list.
2021-05-11 18:30:36 -07:00
**Returns:** *[Joint](joint.md)*
2021-04-16 17:10:15 +02:00
___
### getReactionForce
2021-05-11 18:30:36 -07:00
▸ **getReactionForce**(`inv_dt`: number): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getReactionForce](joint.md#abstract-getreactionforce)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:258](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L258)*
2021-04-16 17:10:15 +02:00
Get the reaction force on bodyB at the joint anchor in Newtons.
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`inv_dt` | number |
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getReactionTorque
2021-05-11 18:30:36 -07:00
▸ **getReactionTorque**(`inv_dt`: number): *number*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getReactionTorque](joint.md#abstract-getreactiontorque)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:265](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L265)*
2021-04-16 17:10:15 +02:00
Get the reaction torque on bodyB in N*m.
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`inv_dt` | number |
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
2021-04-16 17:10:15 +02:00
### getType
▸ **getType**(): *string*
*Inherited from [Joint](joint.md).[getType](joint.md#gettype)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:152](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L152)*
2021-04-16 17:10:15 +02:00
Get the type of the concrete joint.
**Returns:** *string*
___
### getUserData
▸ **getUserData**(): *unknown*
*Inherited from [Joint](joint.md).[getUserData](joint.md#getuserdata)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:177](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L177)*
2021-04-16 17:10:15 +02:00
**Returns:** *unknown*
___
### initVelocityConstraints
2021-05-11 18:30:36 -07:00
▸ **initVelocityConstraints**(`step`: [TimeStep](timestep.md)): *void*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[initVelocityConstraints](joint.md#abstract-initvelocityconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:269](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L269)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *void*
___
### isActive
▸ **isActive**(): *boolean*
*Inherited from [Joint](joint.md).[isActive](joint.md#isactive)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:145](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L145)*
2021-04-16 17:10:15 +02:00
Short-cut function to determine if either body is inactive.
**Returns:** *boolean*
___
2020-07-28 20:21:55 -07:00
### setMaxForce
2021-05-11 18:30:36 -07:00
▸ **setMaxForce**(`force`: number): *void*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:214](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L214)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
Set the maximum friction force in N.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`force` | number |
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
### setMaxTorque
2021-05-11 18:30:36 -07:00
▸ **setMaxTorque**(`torque`: number): *void*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:229](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L229)*
2021-04-16 17:10:15 +02:00
Set the maximum friction torque in N*m.
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`torque` | number |
2021-04-16 17:10:15 +02:00
**Returns:** *void*
___
### setUserData
▸ **setUserData**(`data`: unknown): *void*
*Inherited from [Joint](joint.md).[setUserData](joint.md#setuserdata)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:181](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L181)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`data` | unknown |
**Returns:** *void*
___
### shiftOrigin
▸ **shiftOrigin**(`newOrigin`: [Vec2](vec2.md)): *void*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[shiftOrigin](joint.md#shiftorigin)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:217](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L217)*
2021-04-16 17:10:15 +02:00
Shift the origin for any points stored in world coordinates.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`newOrigin` | [Vec2](vec2.md) |
2020-07-28 20:21:55 -07:00
**Returns:** *void*
2021-04-16 17:10:15 +02:00
___
### solvePositionConstraints
2021-05-11 18:30:36 -07:00
▸ **solvePositionConstraints**(`step`: [TimeStep](timestep.md)): *boolean*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[solvePositionConstraints](joint.md#abstract-solvepositionconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:407](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L407)*
2021-04-16 17:10:15 +02:00
This returns true if the position errors are within tolerance.
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *boolean*
___
### solveVelocityConstraints
2021-05-11 18:30:36 -07:00
▸ **solveVelocityConstraints**(`step`: [TimeStep](timestep.md)): *void*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[solveVelocityConstraints](joint.md#abstract-solvevelocityconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/FrictionJoint.ts:345](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/FrictionJoint.ts#L345)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *void*