#

API Docs for: 0.6.1
Show: Inherited Protected Private Deprecated

# Ray Class

Defined in: `src/collision/Ray.js:12`

A line in 3D space that intersects bodies and return points.

## Constructor

### `Ray`

(

- `from`
- `to`

)

Defined in `src/collision/Ray.js:12`

#### Parameters:

- `from` Vec3
- `to` Vec3

- Index
- Methods
- Properties

## Item Index

### Methods

- _updateDirection
- getAABB
- intersectBodies
- intersectBody
- intersectBox
- intersectConvex
- intersectHeightfield
- intersectPlane
- intersectShape
- intersectSphere
- intersectTrimesh
- intersectWorld
- reportIntersection

### Properties

- _direction
- callback
- checkCollisionResponse
- collisionFilterGroup
- collisionFilterMask
- from
- hasHit
- mode
- precision
- result
- skipBackfaces
- to

## Methods

### `_updateDirection`

() private

Defined in `src/collision/Ray.js:224`

Updates the _direction vector.

### `getAABB`

(

- `aabb`

)

Defined in `src/collision/Ray.js:334`

Get the world AABB of the ray.

#### Parameters:

- `aabb` AABB

### `intersectBodies`

(

- `bodies`
- `[result]`

)

Defined in `src/collision/Ray.js:208`

#### Parameters:

- `bodies` Array

  An array of Body objects.

- `[result]` RaycastResult optional

  Deprecated

### `intersectBody`

(

- `body`
- `[result]`

)
private

Defined in `src/collision/Ray.js:157`

Shoot a ray at a body, get back information about the hit.

#### Parameters:

- `body` Body
- `[result]` RaycastResult optional

  Deprecated - set the result property of the Ray instead.

### `intersectBox`

(

- `shape`
- `quat`
- `position`
- `body`

)
private

Defined in `src/collision/Ray.js:269`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body

### `intersectConvex`

(

- `shape`
- `quat`
- `position`
- `body`
- `[options]`

)
private

Defined in `src/collision/Ray.js:505`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body
- `[options]` Object optional
  - `[faceList]` Array optional

### `intersectHeightfield`

(

- `shape`
- `quat`
- `position`
- `body`

)
private

Defined in `src/collision/Ray.js:354`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body

### `intersectPlane`

(

- `shape`
- `quat`
- `position`
- `body`

)
private

Defined in `src/collision/Ray.js:282`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body

### `intersectShape`

(

- `shape`
- `quat`
- `position`
- `body`

)
private

Defined in `src/collision/Ray.js:234`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body

### `intersectSphere`

(

- `shape`
- `quat`
- `position`
- `body`

)
private

Defined in `src/collision/Ray.js:439`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body

### `intersectTrimesh`

(

- `shape`
- `quat`
- `position`
- `body`
- `[options]`

)
private

Defined in `src/collision/Ray.js:623`

#### Parameters:

- `shape` Shape
- `quat` Quaternion
- `position` Vec3
- `body` Body
- `[options]` Object optional

### `intersectWorld`

(

- `world`
- `options`

)
Boolean

Defined in `src/collision/Ray.js:99`

Do itersection against all bodies in the given World.

#### Parameters:

- `world` World
- `options` Object

#### Returns:

Boolean:

True if the ray hit anything, otherwise false.

### `reportIntersection`

(

- `normal`
- `hitPointWorld`
- `shape`
- `body`

)
Boolean private

Defined in `src/collision/Ray.js:738`

#### Parameters:

- `normal` Vec3
- `hitPointWorld` Vec3
- `shape` Shape
- `body` Body

#### Returns:

Boolean:

True if the intersections should continue

## Properties

### `_direction`

Vec3 private

Defined in `src/collision/Ray.js:30`

### `callback`

Function

Defined in `src/collision/Ray.js:84`

Current, user-provided result callback. Will be used if mode is Ray.ALL.

### `checkCollisionResponse`

Boolean

Defined in `src/collision/Ray.js:42`

Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.

### `collisionFilterGroup`

Number

Defined in `src/collision/Ray.js:60`

Default: -1

### `collisionFilterMask`

Number

Defined in `src/collision/Ray.js:54`

Default: -1

### `from`

Vec3

Defined in `src/collision/Ray.js:20`

### `hasHit`

Boolean

Defined in `src/collision/Ray.js:78`

Will be set to true during intersectWorld() if the ray hit anything.

### `mode`

Number

Defined in `src/collision/Ray.js:66`

The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.

### `precision`

Number

Defined in `src/collision/Ray.js:36`

The precision of the ray. Used when checking parallelity etc.

### `result`

RaycastResult

Defined in `src/collision/Ray.js:72`

Current result object.

### `skipBackfaces`

Boolean

Defined in `src/collision/Ray.js:48`

If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.

### `to`

Vec3

Defined in `src/collision/Ray.js:25`