2020-07-28 20:21:55 -07:00
|
|
|
|
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Body](body.md)
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
# Class: Body
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
A rigid body composed of one or more fixtures.
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
To create a new Body use [World.createBody](world.md#createbody).
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
## Hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
* **Body**
|
|
|
|
|
|
|
|
|
|
|
|
## Index
|
|
|
|
|
|
|
|
|
|
|
|
### Properties
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
* [DYNAMIC](body.md#static-readonly-dynamic)
|
|
|
|
|
|
* [KINEMATIC](body.md#static-readonly-kinematic)
|
|
|
|
|
|
* [STATIC](body.md#static-readonly-static)
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
|
|
|
|
* [advance](body.md#advance)
|
|
|
|
|
|
* [applyAngularImpulse](body.md#applyangularimpulse)
|
|
|
|
|
|
* [applyForce](body.md#applyforce)
|
|
|
|
|
|
* [applyForceToCenter](body.md#applyforcetocenter)
|
|
|
|
|
|
* [applyLinearImpulse](body.md#applylinearimpulse)
|
|
|
|
|
|
* [applyTorque](body.md#applytorque)
|
|
|
|
|
|
* [createFixture](body.md#createfixture)
|
|
|
|
|
|
* [destroyFixture](body.md#destroyfixture)
|
|
|
|
|
|
* [getAngle](body.md#getangle)
|
|
|
|
|
|
* [getAngularDamping](body.md#getangulardamping)
|
|
|
|
|
|
* [getAngularVelocity](body.md#getangularvelocity)
|
|
|
|
|
|
* [getContactList](body.md#getcontactlist)
|
|
|
|
|
|
* [getFixtureList](body.md#getfixturelist)
|
|
|
|
|
|
* [getGravityScale](body.md#getgravityscale)
|
|
|
|
|
|
* [getInertia](body.md#getinertia)
|
|
|
|
|
|
* [getJointList](body.md#getjointlist)
|
|
|
|
|
|
* [getLinearDamping](body.md#getlineardamping)
|
|
|
|
|
|
* [getLinearVelocity](body.md#getlinearvelocity)
|
|
|
|
|
|
* [getLinearVelocityFromLocalPoint](body.md#getlinearvelocityfromlocalpoint)
|
|
|
|
|
|
* [getLinearVelocityFromWorldPoint](body.md#getlinearvelocityfromworldpoint)
|
|
|
|
|
|
* [getLocalCenter](body.md#getlocalcenter)
|
|
|
|
|
|
* [getLocalPoint](body.md#getlocalpoint)
|
|
|
|
|
|
* [getLocalVector](body.md#getlocalvector)
|
|
|
|
|
|
* [getMass](body.md#getmass)
|
|
|
|
|
|
* [getMassData](body.md#getmassdata)
|
|
|
|
|
|
* [getNext](body.md#getnext)
|
|
|
|
|
|
* [getPosition](body.md#getposition)
|
|
|
|
|
|
* [getTransform](body.md#gettransform)
|
|
|
|
|
|
* [getUserData](body.md#getuserdata)
|
|
|
|
|
|
* [getWorld](body.md#getworld)
|
|
|
|
|
|
* [getWorldCenter](body.md#getworldcenter)
|
|
|
|
|
|
* [getWorldPoint](body.md#getworldpoint)
|
|
|
|
|
|
* [getWorldVector](body.md#getworldvector)
|
|
|
|
|
|
* [isActive](body.md#isactive)
|
|
|
|
|
|
* [isAwake](body.md#isawake)
|
|
|
|
|
|
* [isBullet](body.md#isbullet)
|
|
|
|
|
|
* [isDynamic](body.md#isdynamic)
|
|
|
|
|
|
* [isFixedRotation](body.md#isfixedrotation)
|
|
|
|
|
|
* [isKinematic](body.md#iskinematic)
|
|
|
|
|
|
* [isSleepingAllowed](body.md#issleepingallowed)
|
|
|
|
|
|
* [isStatic](body.md#isstatic)
|
|
|
|
|
|
* [isWorldLocked](body.md#isworldlocked)
|
|
|
|
|
|
* [resetMassData](body.md#resetmassdata)
|
|
|
|
|
|
* [setActive](body.md#setactive)
|
|
|
|
|
|
* [setAngle](body.md#setangle)
|
|
|
|
|
|
* [setAngularDamping](body.md#setangulardamping)
|
|
|
|
|
|
* [setAngularVelocity](body.md#setangularvelocity)
|
|
|
|
|
|
* [setAwake](body.md#setawake)
|
|
|
|
|
|
* [setBullet](body.md#setbullet)
|
|
|
|
|
|
* [setDynamic](body.md#setdynamic)
|
|
|
|
|
|
* [setFixedRotation](body.md#setfixedrotation)
|
|
|
|
|
|
* [setGravityScale](body.md#setgravityscale)
|
|
|
|
|
|
* [setKinematic](body.md#setkinematic)
|
|
|
|
|
|
* [setLinearDamping](body.md#setlineardamping)
|
|
|
|
|
|
* [setLinearVelocity](body.md#setlinearvelocity)
|
|
|
|
|
|
* [setMassData](body.md#setmassdata)
|
|
|
|
|
|
* [setPosition](body.md#setposition)
|
|
|
|
|
|
* [setSleepingAllowed](body.md#setsleepingallowed)
|
|
|
|
|
|
* [setStatic](body.md#setstatic)
|
|
|
|
|
|
* [setTransform](body.md#settransform)
|
|
|
|
|
|
* [setUserData](body.md#setuserdata)
|
|
|
|
|
|
* [shouldCollide](body.md#shouldcollide)
|
|
|
|
|
|
* [synchronizeFixtures](body.md#synchronizefixtures)
|
|
|
|
|
|
* [synchronizeTransform](body.md#synchronizetransform)
|
|
|
|
|
|
|
|
|
|
|
|
## Properties
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
### `Static` `Readonly` DYNAMIC
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
▪ **DYNAMIC**: *[BodyType](../globals.md#bodytype)* = "dynamic"
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:173](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L173)*
|
2021-05-08 11:13:58 -07:00
|
|
|
|
|
|
|
|
|
|
A dynamic body is fully simulated.
|
|
|
|
|
|
They can be moved manually by the user, but normally they move according to forces.
|
|
|
|
|
|
A dynamic body can collide with all body types.
|
|
|
|
|
|
A dynamic body always has finite, non-zero mass.
|
|
|
|
|
|
If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won't rotate.
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
### `Static` `Readonly` KINEMATIC
|
|
|
|
|
|
|
|
|
|
|
|
▪ **KINEMATIC**: *[BodyType](../globals.md#bodytype)* = "kinematic"
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:164](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L164)*
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
A kinematic body moves under simulation according to its velocity.
|
|
|
|
|
|
Kinematic bodies do not respond to forces.
|
|
|
|
|
|
They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity.
|
|
|
|
|
|
A kinematic body behaves as if it has infinite mass, however, zero is stored for the mass and the inverse mass.
|
|
|
|
|
|
Kinematic bodies do not collide with other kinematic or static bodies.
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
### `Static` `Readonly` STATIC
|
|
|
|
|
|
|
|
|
|
|
|
▪ **STATIC**: *[BodyType](../globals.md#bodytype)* = "static"
|
2020-07-28 20:21:55 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:156](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L156)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-08 11:13:58 -07:00
|
|
|
|
A static body does not move under simulation and behaves as if it has infinite mass.
|
|
|
|
|
|
Internally, zero is stored for the mass and the inverse mass.
|
|
|
|
|
|
Static bodies can be moved manually by the user.
|
|
|
|
|
|
A static body has zero velocity.
|
|
|
|
|
|
Static bodies do not collide with other static or kinematic bodies.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
|
|
|
|
### advance
|
|
|
|
|
|
|
|
|
|
|
|
▸ **advance**(`alpha`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:607](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L607)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Used in TOI.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`alpha` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### applyAngularImpulse
|
|
|
|
|
|
|
|
|
|
|
|
▸ **applyAngularImpulse**(`impulse`: number, `wake?`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:979](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L979)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Apply an angular impulse.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`impulse` | number | The angular impulse in units of kg*m*m/s |
|
|
|
|
|
|
`wake?` | boolean | Also wake up the body |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### applyForce
|
|
|
|
|
|
|
|
|
|
|
|
▸ **applyForce**(`force`: [Vec2](vec2.md), `point`: [Vec2](vec2.md), `wake?`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:896](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L896)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Apply a force at a world point. If the force is not applied at the center of
|
|
|
|
|
|
mass, it will generate a torque and affect the angular velocity. This wakes
|
|
|
|
|
|
up the body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`force` | [Vec2](vec2.md) | The world force vector, usually in Newtons (N). |
|
|
|
|
|
|
`point` | [Vec2](vec2.md) | The world position of the point of application. |
|
|
|
|
|
|
`wake?` | boolean | Also wake up the body |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### applyForceToCenter
|
|
|
|
|
|
|
|
|
|
|
|
▸ **applyForceToCenter**(`force`: [Vec2](vec2.md), `wake?`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:916](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L916)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Apply a force to the center of mass. This wakes up the body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`force` | [Vec2](vec2.md) | The world force vector, usually in Newtons (N). |
|
|
|
|
|
|
`wake?` | boolean | Also wake up the body |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### applyLinearImpulse
|
|
|
|
|
|
|
|
|
|
|
|
▸ **applyLinearImpulse**(`impulse`: [Vec2](vec2.md), `point`: [Vec2](vec2.md), `wake?`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:958](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L958)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Apply an impulse at a point. This immediately modifies the velocity. It also
|
|
|
|
|
|
modifies the angular velocity if the point of application is not at the
|
|
|
|
|
|
center of mass. This wakes up the body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`impulse` | [Vec2](vec2.md) | The world impulse vector, usually in N-seconds or kg-m/s. |
|
|
|
|
|
|
`point` | [Vec2](vec2.md) | The world position of the point of application. |
|
|
|
|
|
|
`wake?` | boolean | Also wake up the body |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### applyTorque
|
|
|
|
|
|
|
|
|
|
|
|
▸ **applyTorque**(`torque`: number, `wake?`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:936](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L936)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Apply a torque. This affects the angular velocity without affecting the
|
|
|
|
|
|
linear velocity of the center of mass. This wakes up the body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`torque` | number | About the z-axis (out of the screen), usually in N-m. |
|
|
|
|
|
|
`wake?` | boolean | Also wake up the body |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### createFixture
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
▸ **createFixture**(`def`: [FixtureDef](../interfaces/fixturedef.md)): *[Fixture](fixture.md)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1053](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1053)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Creates a fixture and attach it to this body.
|
|
|
|
|
|
|
|
|
|
|
|
If the density is non-zero, this function automatically updates the mass of
|
|
|
|
|
|
the body.
|
|
|
|
|
|
|
|
|
|
|
|
Contacts are not created until the next time step.
|
|
|
|
|
|
|
|
|
|
|
|
Warning: This function is locked during callbacks.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2020-07-28 20:21:55 -07:00
|
|
|
|
`def` | [FixtureDef](../interfaces/fixturedef.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Fixture](fixture.md)*
|
|
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
▸ **createFixture**(`shape`: [Shape](shape.md), `opt?`: [FixtureOpt](../interfaces/fixtureopt.md)): *[Fixture](fixture.md)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1054](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1054)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`shape` | [Shape](shape.md) |
|
2020-07-28 20:21:55 -07:00
|
|
|
|
`opt?` | [FixtureOpt](../interfaces/fixtureopt.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Fixture](fixture.md)*
|
|
|
|
|
|
|
|
|
|
|
|
▸ **createFixture**(`shape`: [Shape](shape.md), `density?`: number): *[Fixture](fixture.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1055](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1055)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`shape` | [Shape](shape.md) |
|
|
|
|
|
|
`density?` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Fixture](fixture.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### destroyFixture
|
|
|
|
|
|
|
|
|
|
|
|
▸ **destroyFixture**(`fixture`: [Fixture](fixture.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1080](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1080)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Destroy a fixture. This removes the fixture from the broad-phase and destroys
|
|
|
|
|
|
all contacts associated with this fixture. This will automatically adjust the
|
|
|
|
|
|
mass of the body if the body is dynamic and the fixture has positive density.
|
|
|
|
|
|
All fixtures attached to a body are implicitly destroyed when the body is
|
|
|
|
|
|
destroyed.
|
|
|
|
|
|
|
|
|
|
|
|
Warning: This function is locked during callbacks.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`fixture` | [Fixture](fixture.md) | The fixture to be removed. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getAngle
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getAngle**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:629](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L629)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the current world rotation angle in radians.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getAngularDamping
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getAngularDamping**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:727](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L727)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getAngularVelocity
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getAngularVelocity**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:700](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L700)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the angular velocity.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
the angular velocity in radians/second.
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getContactList
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getContactList**(): *[ContactEdge](contactedge.md) | null*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:347](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L347)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
Warning: this list changes during the time step and you may miss some
|
|
|
|
|
|
collisions if you don't use ContactListener.
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[ContactEdge](contactedge.md) | null*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getFixtureList
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getFixtureList**(): *[Fixture](fixture.md) | null*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:335](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L335)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Fixture](fixture.md) | null*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getGravityScale
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getGravityScale**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:735](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L735)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getInertia
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getInertia**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:760](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L760)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the rotational inertia of the body about the local origin.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
the rotational inertia, usually in kg-m^2.
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getJointList
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
▸ **getJointList**(): *[JointEdge](jointedge.md) | null*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:339](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L339)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
**Returns:** *[JointEdge](jointedge.md) | null*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLinearDamping
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLinearDamping**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:719](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L719)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLinearVelocity
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLinearVelocity**(): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:656](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L656)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the linear velocity of the center of mass.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
the linear velocity of the center of mass.
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLinearVelocityFromLocalPoint
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLinearVelocityFromLocalPoint**(`localPoint`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:676](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L676)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the world velocity of a local point.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`localPoint` | [Vec2](vec2.md) | A point in local coordinates. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLinearVelocityFromWorldPoint
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLinearVelocityFromWorldPoint**(`worldPoint`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:665](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L665)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the world linear velocity of a world point attached to this body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`worldPoint` | [Vec2](vec2.md) | A point in world coordinates. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLocalCenter
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLocalCenter**(): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:647](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L647)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the local position of the center of mass.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLocalPoint
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLocalPoint**(`worldPoint`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1157](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1157)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Gets the corresponding local point of a world point.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`worldPoint` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getLocalVector
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getLocalVector**(`worldVector`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1164](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1164)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Gets the corresponding local vector of a world vector.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`worldVector` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getMass
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getMass**(): *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:751](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L751)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the total mass of the body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *number*
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
The mass, usually in kilograms (kg).
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getMassData
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
▸ **getMassData**(`data`: [MassData](massdata.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:768](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L768)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Copy the mass data of the body to data.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
`data` | [MassData](massdata.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getNext
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getNext**(): *[Body](body.md) | null*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:323](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L323)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Body](body.md) | null*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getPosition
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getPosition**(): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:618](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L618)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the world position for the body's origin.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getTransform
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getTransform**(): *[Transform](transform.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:559](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L559)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the world transform for the body's origin.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Transform](transform.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getUserData
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getUserData**(): *unknown*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:331](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L331)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *unknown*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getWorld
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getWorld**(): *[World](world.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:319](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L319)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[World](world.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getWorldCenter
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getWorldCenter**(): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:640](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L640)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the world position of the center of mass.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getWorldPoint
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getWorldPoint**(`localPoint`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1143](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1143)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the corresponding world point of a local point.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`localPoint` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getWorldVector
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getWorldVector**(`localVector`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:1150](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L1150)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the corresponding world vector of a local vector.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`localVector` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Vec2](vec2.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isActive
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isActive**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:485](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L485)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isAwake
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isAwake**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:460](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L460)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isBullet
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isBullet**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:438](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L438)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isDynamic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isDynamic**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:355](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L355)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isFixedRotation
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isFixedRotation**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:537](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L537)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isKinematic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isKinematic**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:359](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L359)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isSleepingAllowed
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isSleepingAllowed**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:449](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L449)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isStatic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isStatic**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:351](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L351)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### isWorldLocked
|
|
|
|
|
|
|
|
|
|
|
|
▸ **isWorldLocked**(): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:315](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L315)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### resetMassData
|
|
|
|
|
|
|
|
|
|
|
|
▸ **resetMassData**(): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:779](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L779)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
This resets the mass properties to the sum of the mass properties of the
|
|
|
|
|
|
fixtures. This normally does not need to be called unless you called
|
|
|
|
|
|
SetMassData to override the mass and you later want to reset the mass.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setActive
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setActive**(`flag`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:502](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L502)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set the active state of the body. An inactive body is not simulated and
|
|
|
|
|
|
cannot be collided with or woken up. If you pass a flag of true, all fixtures
|
|
|
|
|
|
will be added to the broad-phase. If you pass a flag of false, all fixtures
|
|
|
|
|
|
will be removed from the broad-phase and all contacts will be destroyed.
|
|
|
|
|
|
Fixtures and joints are otherwise unaffected.
|
|
|
|
|
|
|
|
|
|
|
|
You may continue to create/destroy fixtures and joints on inactive bodies.
|
|
|
|
|
|
Fixtures on an inactive body are implicitly inactive and will not participate
|
|
|
|
|
|
in collisions, ray-casts, or queries. Joints connected to an inactive body
|
|
|
|
|
|
are implicitly inactive. An inactive body is still owned by a World object
|
|
|
|
|
|
and remains
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`flag` | boolean |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setAngle
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setAngle**(`angle`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:633](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L633)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`angle` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setAngularDamping
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setAngularDamping**(`angularDamping`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:731](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L731)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`angularDamping` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setAngularVelocity
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setAngularVelocity**(`w`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:709](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L709)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set the angular velocity.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`w` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setAwake
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setAwake**(`flag`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:469](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L469)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set the sleep state of the body. A sleeping body has very low CPU cost.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`flag` | boolean | Set to true to wake the body, false to put it to sleep. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setBullet
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setBullet**(`flag`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:445](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L445)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Should this body be treated like a bullet for continuous collision detection?
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`flag` | boolean |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setDynamic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setDynamic**(): *[Body](body.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:371](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L371)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Body](body.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setFixedRotation
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setFixedRotation**(`flag`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:544](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L544)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set this body to have fixed rotation. This causes the mass to be reset.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`flag` | boolean |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setGravityScale
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setGravityScale**(`scale`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:742](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L742)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Scale the gravity applied to this body.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`scale` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setKinematic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setKinematic**(): *[Body](body.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:376](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L376)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Body](body.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setLinearDamping
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setLinearDamping**(`linearDamping`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:723](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L723)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`linearDamping` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setLinearVelocity
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setLinearVelocity**(`v`: [Vec2](vec2.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:685](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L685)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set the linear velocity of the center of mass.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`v` | [Vec2](vec2.md) | The new linear velocity of the center of mass. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setMassData
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
▸ **setMassData**(`massData`: [MassData](massdata.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:850](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L850)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Set the mass properties to override the mass properties of the fixtures. Note
|
|
|
|
|
|
that this changes the center of mass position. Note that creating or
|
|
|
|
|
|
destroying fixtures can also alter the mass. This function has no effect if
|
|
|
|
|
|
the body isn't dynamic.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`massData` | [MassData](massdata.md) | The mass properties. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setPosition
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setPosition**(`p`: [Vec2](vec2.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:622](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L622)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`p` | [Vec2](vec2.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setSleepingAllowed
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setSleepingAllowed**(`flag`: boolean): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:453](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L453)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`flag` | boolean |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setStatic
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setStatic**(): *[Body](body.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:366](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L366)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
This will alter the mass and velocity.
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Body](body.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setTransform
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setTransform**(`position`: [Vec2](vec2.md), `angle`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:571](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L571)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Set the position of the body's origin and rotation. Manipulating a body's
|
|
|
|
|
|
transform may cause non-physical behavior. Note: contacts are updated on the
|
|
|
|
|
|
next call to World.step.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`position` | [Vec2](vec2.md) | The world position of the body's local origin. |
|
|
|
|
|
|
`angle` | number | The world rotation in radians. |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setUserData
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setUserData**(`data`: any): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:327](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L327)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`data` | any |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### shouldCollide
|
|
|
|
|
|
|
|
|
|
|
|
▸ **shouldCollide**(`that`: [Body](body.md)): *boolean*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:997](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L997)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
This is used to prevent connected bodies (by joints) from colliding,
|
|
|
|
|
|
depending on the joint's collideConnected flag.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`that` | [Body](body.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *boolean*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### synchronizeFixtures
|
|
|
|
|
|
|
|
|
|
|
|
▸ **synchronizeFixtures**(): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:593](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L593)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Update fixtures in broad-phase.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### synchronizeTransform
|
|
|
|
|
|
|
|
|
|
|
|
▸ **synchronizeTransform**(): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/dynamics/Body.ts:586](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Body.ts#L586)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|