# Class CoordinateTracker<Tracked3D>

CoordinateTracker contains methods for tracking a screen space coordinate from a 3D position.

#### Type Parameters

- Tracked3D extends TrackCoordinate3D = Vertex3

##### Index

### Constructors

constructor

### Properties

onUpdateObservable

### Accessors

size

### Methods

clear
dispose
entries
forceRecalculation
get
onUpdate
track
trackOnce
untrack

## Constructors

### constructor

- new CoordinateTracker<Tracked3D extends TrackCoordinate3D = Vertex3>(
  bimApi: BimCoreApi,
  recalculate2DEachFrame?: boolean,
  ): CoordinateTracker<Tracked3D>

  Constructor

  #### Type Parameters

  - Tracked3D extends TrackCoordinate3D = Vertex3

  #### Parameters

  - bimApi: BimCoreApi

    BIM Core API.

  - recalculate2DEachFrame: boolean = false

    If `true` then it updates the 2D positions for each tracked 3D coordinate at the end of each frame.

  #### Returns CoordinateTracker<Tracked3D>

## Properties

### `Readonly` onUpdateObservable

onUpdateObservable: Observable<TrackCoordinate2D<Tracked3D>> = ...

Called when a tracked 3D coordinate changes its 2D position (when camera is manipulated). Same as onUpdate but using a Observable instead.

## Accessors

### size

- get size(): number

  Number of items currently being tracked.

  #### Returns number

## Methods

### clear

- clear(): void

  Removes all tracked coordinates from the tracker.

  #### Returns void

### dispose

- dispose(): void

  Disposes the coordinate tracker.

  #### Returns void

### entries

- entries(): IterableIterator<[unknown, Tracked3D]>

  Allows iteration of all entities that are tracked (and their ids)

  #### Returns IterableIterator<[unknown, Tracked3D]>

  collection of all tracked entities and their id.

### forceRecalculation

- forceRecalculation(): void

  Immediately force a recalculation of all 2D coordinates

  #### Returns void

### get

- get(id: unknown): undefined | TrackCoordinate2D<Tracked3D>

  Attempt to get a currently tracked object by id.

  #### Parameters

  - id: unknown

    Id of tracked object.

  #### Returns undefined | TrackCoordinate2D<Tracked3D>

  Tracked object if it exists. Otherwise undefined

### onUpdate

- onUpdate(callback: (coordinate: TrackCoordinate2D<Tracked3D>) => void): void

  Register a callback which will be called when the active camera moves. It is called once for each coordinate registered by track.

  #### Parameters

  - callback: (coordinate: TrackCoordinate2D<Tracked3D>) => void

    Callback to trigger when an active camera moves.

  #### Returns void

### track

- track(coordinate: Tracked3D, id?: unknown): unknown

  This method takes a coordinate in 3D to track screen space position when the camera moves. When method is called events on onUpdateObservable are immediately raised for the passed coordinate. Same coordinate can be passed multiple times (with same id) but it will only be added once. However events onUpdateObservable will still be immediately raised and report 2D coordinates data even if coordinate is already tracked.

  #### Parameters

  - coordinate: Tracked3D

    Coordinate to track.

  - `Optional` id: unknown

    Optional. If not specified an id will be generated

  #### Returns unknown

  id of tracked coordinate.

### trackOnce

- trackOnce(
  coordinate: Tracked3D,
  id: unknown,
  ): undefined | TrackCoordinate2D<Tracked3D>

  Gets 2D coordinate of a 3D coordinate once.

  #### Parameters

  - coordinate: Tracked3D

    3D coordinate to get 2D coordinate from

  - id: unknown

    Identifier for 3D coordinate.

  #### Returns undefined | TrackCoordinate2D<Tracked3D>

### untrack

- untrack(id: unknown): undefined | Tracked3D

  Stops tracking of a 3D coordinate.

  #### Parameters

  - id: unknown

    Id of 3D coordinate to stop tracking

  #### Returns undefined | Tracked3D

  Object that was untracked. If there is no such object then undefined.