# Class PolyLine<Point>

Represents a dynamic polyline. It is possible to add, insert and remove points to it and have those changes reflect its 3D visualization. Useful for tools that need to calculate distances between start and end points etc.

#### Type Parameters

- Point extends PolyLinePoint

##### Index

### Constructors

constructor

### Properties

name
onPointTrackableScreen
points

### Accessors

color

### Methods

apply
clear
dispose
distance
forEachLine

## Constructors

### constructor

- new PolyLine<Point extends TrackCoordinate3D>(
  name: string,
  _api: BimCoreApi,
  options?: { maxPointCount?: number },
  ): PolyLine<Point>

  Polyline constructor.

  #### Type Parameters

  - Point extends TrackCoordinate3D

  #### Parameters

  - name: string

    Name of polyline

  - _api: BimCoreApi

    BimCoreApi instance

  - `Optional` options: { maxPointCount?: number }

    Options for line creation

  #### Returns PolyLine<Point>

## Properties

### name

name: string

Name of polyline

### `Readonly` onPointTrackableScreen

onPointTrackableScreen: Observable<TrackCoordinate2D<Point>> = ...

Triggered when apply is called or when camera moves around. By listening to this event it is possible to know when new points are added, updated and removed. It is also possible to see how far away the points are from the camera. What position they have in 2D space (perhaps one wants to add a HTML element to the DOM there.).

### points

points: Point[] = []

Points that make up the polyline. Use usual array operations to add, remove insert points etc. When changes have been made call apply in order to visualize the changes as a LinesMesh.

## Accessors

### color

- get color(): Color3

  Color of the line.

  #### Returns Color3

  The color

- set color(c: Color3): void

  Color of the line

  #### Parameters

  - c: Color3

    The color the line shall have.

  #### Returns void

## Methods

### apply

- apply(): void

  Apply changes made to the points array. This will mirror the changes in the visual representation of the polygon line. It will also trigger onPointTrackableScreen events.

  #### Returns void

### clear

- clear(): void

  Sets point array to zero and disables visibility for the lines mesh. Also removes coordinate trackers for labels if present.

  #### Returns void

### dispose

- dispose(): void

  Sets point array to zero and disables visibility for the lines mesh. Also removes coordinate trackers for labels if present. And disposes the linemesh.

  #### Returns void

### distance

- distance(o?: { end: Point }): number

  Gets the distance of the polyline.

  #### Parameters

  - `Optional` o: { end: Point }

    Optional. Specifies point where distance calculation should end. That is distance from first point up to this point.

  #### Returns number

  distance.

### forEachLine

- forEachLine(predicate: (start: Point, end: Point) => boolean): void

  Makes it possible to iterate each line that points represents

  #### Parameters

  - predicate: (start: Point, end: Point) => boolean

    Called for each line with start and end vector. If predicate returns `false` then iteration is stopped.

  #### Returns void