> ## Documentation Index
> Fetch the complete documentation index at: https://docs.speckle.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# CameraController

> The default camera controller extension that comes with the viewer package. Includes toggleable perspective and orthographic camera projections.

## Properties

### aspect

```typescript theme={null}
get aspect(): number
```

Gets the current display aspect ratio

**Returns**: number

### controls

```typescript theme={null}
get controls(): SpeckleControls
```

Gets the current underlying [*SpeckleControls*](/developers/viewer/extensions/speckle-controls-api) implementation.

**Returns**: [*SpeckleControls*](/developers/viewer/extensions/speckle-controls-api)

### enabled

```typescript theme={null}
get enabled(): boolean
set enabled(val: boolean)
```

Gets or sets whether this extension is enabled.

<Tip>
  Extensions typically need to support being turned on/off with no impact on potentially other active extensions.
</Tip>

**Returns**: boolean

### fieldOfView

```typescript theme={null}
get fieldOfView(): number
set fieldOfView(value: number)
```

Gets or sets the perspective camera's field of view.

**Returns**: number

### options

```typescript theme={null}
get options(): CameraControllerOptions
set options(value: CameraControllerOptions)
```

Gets or sets the current camera controller options.

**Returns**: [CameraControllerOptions](/developers/viewer/extensions/camera-controller-api#cameracontrolleroptions)

### renderingCamera

```typescript theme={null}
get renderingCamera(): PerspectiveCamera | OrthographicCamera
set renderingCamera(value: PerspectiveCamera | OrthographicCamera)
```

Gets or sets the current rendering camera.

**Returns**: number

## Methods

### disableRotations

```typescript theme={null}
disableRotations(): void
```

Disables all camera controls rotation capabilities.

**Returns**: void

### enableRotations

```typescript theme={null}
enableRotations(): void
```

Enables all camera controls rotation capabilities.

**Returns**: void

### on

```typescript theme={null}
on<T extends CameraEvent>(
  eventType: T,
  listener: (arg: CameraEventPayload[T]) => void
): void
```

Function for subscribing to camera events.

**Parameters**

* **eventType**: [*CameraEvent*](/developers/viewer/extensions/camera-controller-api#cameraevent)
* **listener**: The handler for the events with [*CameraEventPayload*](/developers/viewer/extensions/camera-controller-api#cameraeventpayload) arguments

**Returns**: void

### removeListener

```typescript theme={null}
removeListener(e: CameraEvent, handler: (data: unknown) => void)
```

Function for un-subscribing from camera events.

**Parameters**

* **e**: [*CameraEvent*](/developers/viewer/extensions/camera-controller-api#cameraevent)
* **handler**: The handler for the events to unsubscribe

**Returns**: void

### setCameraPlanes

```typescript theme={null}
setCameraPlanes(targetVolume: Box3, offsetScale: number = 1)
```

Function that adapts the camera's near and far clipping planes according to the current scene's volume.
**Parameters**

* **targetVolume**: [*Box3*](https://threejs.org/docs/index.html?q=box#api/en/math/Box3)
* *optional* **offsetScale**: Works as a linear tolerance to the volume parameter

**Returns**: void

### setCameraView

```typescript theme={null}
setCameraView(objectIds: string[], transition: boolean, fit?: number): void
```

Focuses the camera based on the volume defined by the received object ids list.

**Parameters**

* **objectIds**: The object ids that make up the volume
* **transition**: Whether or not to make the transition animated
* *optional* **fit**: Linear tolerance

```typescript theme={null}
setCameraView(
    view: CanonicalView | SpeckleView | InlineView | PolarView,
    transition: boolean,
    fit?: number
  ): void
```

Focuses the camera based on explicit view models provided.

**Parameters**

* **view**: Explicit view of different possible type: [*CanonicalView*](/developers/viewer/extensions/camera-controller-api#canonicalview), [*SpeckleView*](/developers/viewer/extensions/camera-controller-api#speckleview), [*InlineView*](/developers/viewer/extensions/camera-controller-api#inlineview)
* **transition**: Whether or not to make the transition animated
* *optional* **fit**: Linear tolerance

```typescript theme={null}
setCameraView(bounds: Box3, transition: boolean, fit?: number): void
```

Focuses the camera based on explicit volume provided as [*Box3*](https://threejs.org/docs/index.html?q=box#api/en/math/Box3).

**Parameters**

* **bounds**: [*Box3*](https://threejs.org/docs/index.html?q=box#api/en/math/Box3)
* **transition**: Whether or not to make the transition animated
* *optional* **fit**: Linear tolerance

**Returns**: void

### setOrthoCameraOn

```typescript theme={null}
setOrthoCameraOn(): void
```

Enables the orthographic camera.

**Returns**: void

### setPerspectiveCameraOn

```typescript theme={null}
setPerspectiveCameraOn(): void
```

Enables the perspective camera.

**Returns**: void

### toggleCameras

```typescript theme={null}
toggleCameras(): void
```

Switches between perspective and orthographic cameras.

**Returns**: void

## Typedefs

### CameraEvent

```typescript theme={null}
enum CameraEvent {
  Stationary = 'stationary',
  Dynamic = 'dynamic',
  FrameUpdate = 'frame-update',
  ProjectionChanged = 'projection-changed',
}
```

Events the camera controller puts out.

### CameraEventPayload

```typescript theme={null}
interface CameraEventPayload {
  [CameraEvent.Stationary]: void
  [CameraEvent.Dynamic]: void
  [CameraEvent.FrameUpdate]x: boolean
  [CameraEvent.ProjectionChanged]: CameraProjection
}
```

Mapping CameraEvent types to handler argument type

### CameraControllerOptions

```typescript theme={null}
type CameraControllerOptions = SmoothOrbitControlsOptions & {
  nearPlaneCalculation?: NearPlaneCalculation;
};
```

The camera controller options. Defaults to

```typescript theme={null}
const DefaultOrbitControlsOptions: Required<CameraControllerOptions> = {
  enableOrbit: true,
  enableZoom: true,
  enablePan: true,
  orbitSensitivity: 1,
  zoomSensitivity: 1,
  panSensitivity: 1,
  inputSensitivity: 1,
  minimumRadius: 0,
  maximumRadius: Infinity,
  minimumPolarAngle: 0,
  maximumPolarAngle: Math.PI,
  minimumAzimuthalAngle: -Infinity,
  maximumAzimuthalAngle: Infinity,
  minimumFieldOfView: 40,
  maximumFieldOfView: 60,
  touchAction: 'none',
  infiniteZoom: true,
  zoomToCursor: true,
  orbitAroundCursor: true,
  showOrbitPoint: true,
  lookSpeed: 1,
  moveSpeed: 1,
  damperDecay: 30,
  enableLook: true,
  relativeUpDown: false,
  nearPlaneCalculation: NearPlaneCalculation.ACCURATE
};
```

### CameraProjection

```typescript theme={null}
enum CameraProjection {
  PERSPECTIVE,
  ORTHOGRAPHIC,
}
```

Camera projection types.

### CanonicalView

```typescript theme={null}
type CanonicalView =
  | 'front'
  | 'back'
  | 'up'
  | 'top'
  | 'down'
  | 'bottom'
  | 'right'
  | 'left'
  | '3d'
  | '3D';
```

Supported cannonical views.

### InlineView

```typescript theme={null}
type InlineView = {
  position: Vector3;
  target: Vector3;
};
```

Inline, on-demand camera view.

* **position**: The position of the camera
* **target**: The point in space where the camera looks at
  **Returns**: void

### PolarView

```typescript theme={null}
type PolarView = {
  azimuth: number;
  polar: number;
  radius?: number;
  origin?: Vector3;
};
```

Camera view defined in polar coordinates.
