# Class DistanceToCamera

Tracks distance of objects relative a camera.

Call trackDistanceToCamera for each visible mesh, then read minDistanceToCamera to get the result. Call endFrame before each frame.

##### Index

### Constructors

constructor

### Accessors

minDistanceToCamera

### Methods

beginFrame
trackDistanceToCamera

## Constructors

### constructor

- new DistanceToCamera(): DistanceToCamera

  #### Returns DistanceToCamera

## Accessors

### minDistanceToCamera

- get minDistanceToCamera(): number

  The calculated minimum distance from the closest tracked mesh to the camera, divided by the distance divisor and clamped between ViewerCamera.cameraMinZ and the max near plane distance. Resets when beginFrame is called.

  #### Returns number

## Methods

### beginFrame

- beginFrame(): void

  Starts tracking distances for a new frame.

  #### Returns void

### trackDistanceToCamera

- trackDistanceToCamera(options: TrackMeshDistanceToCameraOptions): number

  Tracks a mesh's distance to the camera.

  Updates the internal minimum distance if this mesh is closer than previously tracked meshes.

  #### Parameters

  - options: TrackMeshDistanceToCameraOptions

    The tracking options

  #### Returns number

  The distance from the mesh to the camera