# OrientedBox

class in `three-mesh-bvh`

```js
import { OrientedBox } from 'three-mesh-bvh';
```

An oriented version of three.js' Box3 class. A variety of derivative values are cached on the
object to accelerate the intersection functions. `.needsUpdate` must be set to true when
modifying the box parameters.

## Constructor

```js
new OrientedBox( min?: Vector3, max?: Vector3, matrix?: Matrix4 )
```

- `min`, `Vector3`, optional
- `max`, `Vector3`, optional
- `matrix`, `Matrix4`, optional

## Properties

### .min: Vector3

### .max: Vector3

### .matrix: Matrix4

Matrix transformation applied to the box.

### .needsUpdate: boolean

Indicates that the bounding box fields have changed so cached variables to accelerate
other function execution can be updated. Must be set to true after modifying the
oriented box `min`, `max`, `matrix` fields.

## Methods

### .set

```js
.set( min: Vector3, max: Vector3, matrix: Matrix4 )
```

Sets the oriented box parameters.

- `min`, `Vector3`
- `max`, `Vector3`
- `matrix`, `Matrix4`

### .intersectsBox

```js
.intersectsBox( box: Box3 ): boolean
```

Returns true if intersecting with the provided box.

- `box`, `Box3`

### .intersectsTriangle

```js
.intersectsTriangle( triangle: Triangle ): boolean
```

Returns true if intersecting with the provided triangle.

- `triangle`, `Triangle`

### .closestPointToPoint

```js
.closestPointToPoint( point: Vector3, target: Vector3 ): number
```

Returns the distance to the provided point. Sets `target` to the closest point on the surface
of the box if provided.

- `point`, `Vector3`
- `target`, `Vector3`

### .distanceToPoint

```js
.distanceToPoint( point: Vector3 ): number
```

Returns the distance to the provided point.

- `point`, `Vector3`

### .distanceToBox

```js
.distanceToBox( box: Box3, threshold?: number, target1?: Vector3, target2?: Vector3 ): number
```

Returns the distance to the provided box. `threshold` is an optional distance to return early
if the distance is found to be within it. `target1` and `target2` are set to the points on the
surface of this box and the `box` argument respectively.

- `box`, `Box3`
- `threshold`, `number`, optional, default `0`
- `target1`, `Vector3`, optional
- `target2`, `Vector3`, optional
