# Class MeasureHandler

Contains methods to add, remove and preview distance measurement.

##### Index

### Constructors

constructor

### Accessors

isLaserPreviewActive

### Methods

activateLaserPreview
clear
createOrUpdateLaserPreview
createWallLaser
deactivateLaserPreview
dispose
removeWallLaser

## Constructors

### constructor

- new MeasureHandler(_bimApi: BimApi): MeasureHandler

  Constructor

  #### Parameters

  - _bimApi: BimApi

    BIM Core API.

  #### Returns MeasureHandler

## Accessors

### isLaserPreviewActive

- get isLaserPreviewActive(): boolean

  `true` if activateLaserPreview has been called. `false` if not called or if either deactivateLaserPreview or dispose is called.

  #### Returns boolean

## Methods

### activateLaserPreview

- activateLaserPreview(): void

  Creates and updates laser preview on canvas upon mouse move, by means of createOrUpdateLaserPreview.

  #### Returns void

### clear

- clear(): void

  Removes all measurements and deactivates laser preview. Also removes coordinate trackers for labels if present.

  #### Returns void

### createOrUpdateLaserPreview

- createOrUpdateLaserPreview(): undefined | Ray

  Gets the pointer positions on screen and finds where the geometry is hit. From that intersection on the geometry it creates a preview laser measurement. This method can be run for every frame or activated using activateLaserPreview.

  #### Returns undefined | Ray

### createWallLaser

- createWallLaser(
  id: unknown,
  laserOrigin: Intersection,
  labelDistanceFromOrigin?: number,
  onLabelUpdate?: LabelUpdateHandler,
  ): undefined | Ray

  This method adds a visual measurement to viewer from a intersection on the geometry.

  #### Parameters

  - id: unknown

    String for identifying a unique measurement.

  - laserOrigin: Intersection

    The origin position of the measurement, including surface normal to project ray for finding endpoint of distance to measure.

  - labelDistanceFromOrigin: number = 0.75

    Value between 0 and 1 to describe in percent distance from origin along the ray to use as label coordinate anchor. Default 0.75 (75%).

  - `Optional` onLabelUpdate: LabelUpdateHandler

    If this optional callback is provided it tracks the position calculated from labelDistanceFromOrigin and tells where the coordinate is in screen space.

  #### Returns undefined | Ray

### deactivateLaserPreview

- deactivateLaserPreview(): void

  Deactivates and removes laser preview on canvas upon mouse move.

  #### Returns void

### dispose

- dispose(): void

  Removes all measurements and deactivates laser preview. Also removes coordinate trackers for labels if present.

  #### Returns void

  #### Deprecated

  Use clear instead. The naming convention for this method is incorrect as it does not actually dispose the object but clears it.

### removeWallLaser

- removeWallLaser(id: unknown): boolean

  Removes a measurement by its ID.

  #### Parameters

  - id: unknown

    of measurement to be removed.

  #### Returns boolean

  `true` if wall laser was removed. ´false´ if it did not exist.