#

API Docs for: 0.6.0
Show: Inherited Protected Private Deprecated

# Body Class

Extends EventTarget
Defined in: `src/objects/Body.js:12`

Base class for all body types.

## Constructor

### `Body`

(

- `[options]`

)

Defined in `src/objects/Body.js:12`

#### Parameters:

- `[options]` Object optional
  - `[position]` Vec3 optional
  - `[mass]` Number optional
  - `[type]` Number optional
  - `[linearDamping]` Number optional

#### Example:

    var body = new Body({
        mass: 1
    });
    var shape = new Sphere(1);
    body.addShape(shape);
    world.add(body);

- Index
- Methods
- Properties

## Item Index

### Methods

- addEventListener
- applyForce
- applyImpulse
- computeAABB
- dispatchEvent
- getVelocityAtWorldPoint
- hasEventListener
- pointToLocalFrame
- pointToWorldFrame
- pointToWorldFrame
- removeEventListener
- sleep
- sleepTick
- updateBoundingRadius
- updateInertiaWorld
- updateMassProperties
- updateSolveMassProperties
- wakeUp

### Properties

- aabb
- aabbNeedsUpdate
- allowSleep
- angularDamping
- angularVelocity
- AWAKE static
- collisionFilterGroup
- collisionFilterMask
- collisionResponse
- DYNAMIC static
- DYNAMIC static
- DYNAMIC static
- fixedRotation
- float linearDamping
- force
- inertia
- initAngularVelocity
- initPosition
- initQuaternion
- initVelocity
- invInertia
- invInertiaSolve
- invInertiaWorld
- invInertiaWorldSolve
- invMass
- mass
- material
- position
- postStep deprecated
- preStep deprecated
- previousPosition
- quaternion
- shapeOffsets
- shapeOrientations
- shapes
- SLEEPING static
- sleepSpeedLimit
- sleepState
- sleepTimeLimit
- SLEEPY static
- type
- Vec3 tau
- velocity
- world

## Methods

### `addEventListener`

(

- `type`
- `listener`

)
EventTarget

Inherited from EventTarget: `src/utils/EventTarget.js:15`

Add an event listener

#### Parameters:

- `type` String
- `listener` Function

#### Returns:

EventTarget:

The self object, for chainability.

### `applyForce`

(

- `force`
- `worldPoint`

)

Defined in `src/objects/Body.js:581`

Apply force to a world point. This could for example be a point on the Body surface. Applying force this way will add to Body.force and Body.tau.

#### Parameters:

- `force` Vec3

  The amount of force to add.

- `worldPoint` Vec3

  A world point to apply the force on.

### `applyImpulse`

(

- `impulse`
- `worldPoint`

)

Defined in `src/objects/Body.js:609`

Apply impulse to a world point. This could for example be a point on the Body surface. An impulse is a force added to a body during a short period of time (impulse = force * time). Impulses will be added to Body.velocity and Body.angularVelocity.

#### Parameters:

- `impulse` Vec3

  The amount of impulse to add.

- `worldPoint` Vec3

  A world point to apply the force on.

### `computeAABB`

()

Defined in `src/objects/Body.js:506`

Updates the .aabb

### `dispatchEvent`

(

- `event`

)
EventTarget

Inherited from EventTarget: `src/utils/EventTarget.js:68`

Emit an event.

#### Parameters:

- `event` Object
  - `type` String

#### Returns:

EventTarget:

The self object, for chainability.

### `getVelocityAtWorldPoint`

(

- `worldPoint`
- `result`

)
Vec3

Defined in `src/objects/Body.js:693`

Get world velocity of a point in the body.

#### Parameters:

- `worldPoint` Vec3
- `result` Vec3

#### Returns:

Vec3:

The result vector.

### `hasEventListener`

(

- `type`
- `listener`

)
Boolean

Inherited from EventTarget: `src/utils/EventTarget.js:34`

Check if an event listener is added

#### Parameters:

- `type` String
- `listener` Function

#### Returns:

Boolean:

### `pointToLocalFrame`

(

- `worldPoint`
- `result`

)
Vec3

Defined in `src/objects/Body.js:418`

Convert a world point to local body frame.

#### Parameters:

- `worldPoint` Vec3
- `result` Vec3

#### Returns:

Vec3:

### `pointToWorldFrame`

(

- `worldPoint`
- `result`

)
Vec3

Defined in `src/objects/Body.js:432`

Convert a local body point to world frame.

#### Parameters:

- `worldPoint` Vec3
- `result` Vec3

#### Returns:

Vec3:

### `pointToWorldFrame`

(

- `worldPoint`
- `result`

)
Vec3

Defined in `src/objects/Body.js:446`

Convert a local body point to world frame.

#### Parameters:

- `worldPoint` Vec3
- `result` Vec3

#### Returns:

Vec3:

### `removeEventListener`

(

- `type`
- `listener`

)
EventTarget

Inherited from EventTarget: `src/utils/EventTarget.js:50`

Remove an event listener

#### Parameters:

- `type` String
- `listener` Function

#### Returns:

EventTarget:

The self object, for chainability.

### `sleep`

()

Defined in `src/objects/Body.js:361`

Force body sleep

### `sleepTick`

(

- `time`

)

Defined in `src/objects/Body.js:379`

Called every timestep to update internal sleep timer and change sleep state if needed.

#### Parameters:

- `time` Number

  The world time in seconds

### `updateBoundingRadius`

()

Defined in `src/objects/Body.js:483`

Update the bounding radius of the body. Should be done if any of the shapes are changed.

### `updateInertiaWorld`

()

Defined in `src/objects/Body.js:552`

Update .inertiaWorld and .invInertiaWorld

### `updateMassProperties`

()

Defined in `src/objects/Body.js:650`

Should be called whenever you change the body mass.

### `updateSolveMassProperties`

()

Defined in `src/objects/Body.js:402`

If the body is sleeping, it should be immovable / have infinite mass during solve. We solve it by having a separate "solve mass".

### `wakeUp`

()

Defined in `src/objects/Body.js:349`

Wake the body up.

## Properties

### `aabb`

Vec3

Defined in `src/objects/Body.js:280`

### `aabbNeedsUpdate`

Boolean

Defined in `src/objects/Body.js:286`

Indicates if the AABB needs to be updated before use.

### `allowSleep`

Boolean

Defined in `src/objects/Body.js:155`

If true, the body will automatically fall to sleep.

### `angularDamping`

Number

Defined in `src/objects/Body.js:275`

### `angularVelocity`

Vec3

Defined in `src/objects/Body.js:208`

### `AWAKE`

Number static

Defined in `src/objects/Body.js:326`

### `collisionFilterGroup`

Number

Defined in `src/objects/Body.js:62`

### `collisionFilterMask`

Number

Defined in `src/objects/Body.js:67`

### `collisionResponse`

Number

Defined in `src/objects/Body.js:72`

Whether to produce contact forces

### `DYNAMIC`

Number static

Defined in `src/objects/Body.js:300`

A dynamic body is fully simulated. 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.

### `DYNAMIC`

Number static

Defined in `src/objects/Body.js:308`

A static body does not move during simulation and behaves as if it has infinite mass. Static bodies can be moved manually by setting the position of the body. The velocity of a static body is always zero. Static bodies do not collide with other static or kinematic bodies.

### `DYNAMIC`

Number static

Defined in `src/objects/Body.js:316`

A kinematic body moves under simulation according to its velocity. They do not respond to forces. They can be moved manually, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass. Kinematic bodies do not collide with other static or kinematic bodies.

### `fixedRotation`

Boolean

Defined in `src/objects/Body.js:269`

Set to true if you don't want the body to rotate. Make sure to run .updateMassProperties() after changing this.

### `float linearDamping`

Number

Defined in `src/objects/Body.js:139`

### `force`

Vec3

Defined in `src/objects/Body.js:112`

Linear force on the body

### `inertia`

Vec3

Defined in `src/objects/Body.js:241`

### `initAngularVelocity`

Vec3

Defined in `src/objects/Body.js:214`

### `initPosition`

Vec3

Defined in `src/objects/Body.js:93`

Initial position of the body

### `initQuaternion`

Quaternion

Defined in `src/objects/Body.js:202`

### `initVelocity`

Vec3

Defined in `src/objects/Body.js:106`

### `invInertia`

Vec3

Defined in `src/objects/Body.js:247`

### `invInertiaSolve`

Vec3

Defined in `src/objects/Body.js:259`

### `invInertiaWorld`

Mat3

Defined in `src/objects/Body.js:252`

### `invInertiaWorldSolve`

Mat3

Defined in `src/objects/Body.js:264`

### `invMass`

Number

Defined in `src/objects/Body.js:127`

### `mass`

Number

Defined in `src/objects/Body.js:121`

### `material`

Material

Defined in `src/objects/Body.js:133`

### `position`

Vec3

Defined in `src/objects/Body.js:78`

### `postStep`

Function deprecated

Defined in `src/objects/Body.js:52`

Deprecated: Use World events instead

Callback function that is used AFTER stepping the system. Inside the function, "this" will refer to this Body object.

### `preStep`

Function deprecated

Defined in `src/objects/Body.js:44`

Deprecated: Use World events instead

Callback function that is used BEFORE stepping the system. Use it to apply forces, for example. Inside the function, "this" will refer to this Body object.

### `previousPosition`

Vec3

Defined in `src/objects/Body.js:88`

### `quaternion`

Quaternion

Defined in `src/objects/Body.js:195`

Orientation of the body

### `shapeOffsets`

Array

Defined in `src/objects/Body.js:229`

### `shapeOrientations`

Array

Defined in `src/objects/Body.js:235`

### `shapes`

Array

Defined in `src/objects/Body.js:223`

### `SLEEPING`

Number static

Defined in `src/objects/Body.js:340`

### `sleepSpeedLimit`

Number

Defined in `src/objects/Body.js:169`

If the speed (the norm of the velocity) is smaller than this value, the body is considered sleepy.

### `sleepState`

Number

Defined in `src/objects/Body.js:162`

Current sleep state.

### `sleepTimeLimit`

Number

Defined in `src/objects/Body.js:176`

If the body has been sleepy for this sleepTimeLimit seconds, it is considered sleeping.

### `SLEEPY`

Number static

Defined in `src/objects/Body.js:333`

### `type`

Number

Defined in `src/objects/Body.js:145`

One of the states Body.DYNAMIC, Body.STATIC and Body.KINEMATIC

### `Vec3 tau`

Unknown

Defined in `src/objects/Body.js:188`

Rotational force on the body, around center of mass

### `velocity`

Vec3

Defined in `src/objects/Body.js:100`

### `world`

World

Defined in `src/objects/Body.js:37`

Reference to the world the body is living in