[**SixL client API**](../../README.md)

***

[SixL client API](../../README.md) / [cameras](../README.md) / CameraMpPool

# Interface: CameraMpPool

The script camera pool: `mp.cameras`. It holds the cameras the script made, and the gameplay camera.

## Example

```ts
const cam = mp.cameras.new('default');
```

## Constructors

### Constructor

> **new CameraMpPool**(`name`, `position?`, `rotation?`, `fov?`): [`CameraMp`](CameraMp.md)

Makes a script camera. It is inactive until [CameraMp.setActive](CameraMp.md#setactive) is called with `true`.

#### Parameters

##### name

`string`

The camera's name. `'default'`, the RAGE MP name of the default scripted camera and the RAGE MP name
of the default scripted fly camera are accepted. Any other name gives the default scripted camera, because VI has
no other named camera types.

##### position?

[`IVector3`](../../common/interfaces/IVector3.md)

The position in metres. Default: the origin.

##### rotation?

[`IVector3`](../../common/interfaces/IVector3.md)

The rotation in degrees (pitch, roll, yaw). Default: no rotation.

##### fov?

`number`

The vertical field of view in degrees. Default `50`.

#### Returns

[`CameraMp`](CameraMp.md)

The new camera. The game makes it on the next frame.

#### Remarks

The camera is removed when the client leaves the server.

#### Example

```ts
const cam = mp.cameras.new('default', { x: 0, y: 0, z: 80 }, { x: -20, y: 0, z: 90 }, 50);
```

## Properties

### gameplay

> `readonly` **gameplay**: [`GameplayCameraMp`](GameplayCameraMp.md)

The gameplay camera: the camera the game shows the player, as the latest frame has it. Read only.

#### Remarks

SixL: it has only the getters and [GameplayCameraMp.doesExist](GameplayCameraMp.md#doesexist); the setters of [CameraMp](CameraMp.md) are
not on it.

#### Example

```ts
const pos = mp.cameras.gameplay.getCoord();
```

***

### length

> `readonly` **length**: `number`

The number of script cameras the client holds now.

#### Example

```ts
const count = mp.cameras.length;
```

## Methods

### at()

> **at**(`id`): [`CameraMp`](CameraMp.md)

The camera with this client id, or `undefined`.

#### Parameters

##### id

`number`

The client's own number for the camera (from 0, reused after a camera is destroyed). It is not a handle.

#### Returns

[`CameraMp`](CameraMp.md)

The camera, or `undefined` when there is none with that id.

#### Example

```ts
const cam = mp.cameras.at(0);
```

***

### exists()

> **exists**(`entity`): `boolean`

Whether a script camera is still held by the pool.

#### Parameters

##### entity

`number` \| [`CameraMp`](CameraMp.md)

A camera, or the client id of one (the id of [CameraMpPool.at](#at)).

#### Returns

`boolean`

`true` while the camera exists; `false` once it is destroyed.

#### Example

```ts
if (mp.cameras.exists(cam)) { }
```

***

### forEach()

> **forEach**(`callingFunction`): `void`

Calls a function for every script camera the pool holds.

#### Parameters

##### callingFunction

(`entity`) => `void`

Called with each camera.

#### Returns

`void`

#### Example

```ts
mp.cameras.forEach((cam) => cam.setActive(false));
```

***

### toArray()

> **toArray**(): [`CameraMp`](CameraMp.md)[]

The script cameras the pool holds, as an array.

#### Returns

[`CameraMp`](CameraMp.md)[]

A new array of the cameras at the time of the call.

#### Example

```ts
const all = mp.cameras.toArray();
```
