---
title: Annotation
summary: Class in @bimworks/viewercommon.
order: 10
languages: [javascript]
sdk-package: JavaScript · @bimworks/viewercommon
---

# Annotation

[[page:reference/javascript/api|API catalogue]] · `@bimworks/viewercommon` · Class

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
class Annotation
````

Abstract super class for all annotations, there are currently [[page:reference/javascript/bimworks-viewercommon/svgannotation-f97560f1|SvgAnnotation]], [[page:reference/javascript/bimworks-viewercommon/imageannotation-5d4c5a4f|ImageAnnotation]] and [[page:reference/javascript/bimworks-viewercommon/textannotation-e62f7481|TextAnnotation]]

## Members

| Member | Kind | Description |
|---|---|---|
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-constructor-dd3521e4e7c9|constructor]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-qid-b9e3b4cc23c7|qid]] | Property | The object the annotation is linked to: hovering either highlights the other |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-align-e37a8acec0db|align]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-align-c6abb5c3187c|align]] | Method | Which side of its anchor the annotation is drawn on, on screen; null (the default) draws text and icons centred on it and an image of no size with its corner… |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-anchor-4a5305b1da5a|anchor]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-anchor-08cc3b03d2d5|anchor]] | Method | Where on its object (qid) the 3D viewer puts an annotation without a position: a point of the object's box in its model's own axes, "center" (the default) or… |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-click-391f5fdd953c|click]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-click-f3e28721d8e5|click]] | Method | Attach a click listener, only one click listener can be attached, previous one will be overwritten |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-group-03825016ee82|group]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-group-5714aafbf887|group]] | Method | The group the annotation belongs to; groups can be shown, hidden and limited together |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-grouplimit-6e14bfba3f5a|groupLimit]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-grouplimit-0b66aa253b6a|groupLimit]] | Method | At most how many annotations of this annotation's group the 3D viewer shows, those nearest to the camera: a positive whole number, or null (the default) for … |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-maxdistancemm-2941e865d70d|maxDistanceMm]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-maxdistancemm-26068b34fa97|maxDistanceMm]] | Method | Set the maximum distance from the annotation to the camera at which it will still be displayed. The default value of this is 0, which means that at any dista… |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-occlusion-45d44a79b05d|occlusion]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-occlusion-2da8f5a08eb0|occlusion]] | Method | What the 3D viewer does while the annotation's point or object is hidden behind other geometry: "hide" (the default), "dim" or "none" |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-position-97f2b1f2f5c8|position]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-position-a235ef16a289|position]] | Method | Where the annotation points, in viewer coordinates (the frame of @bimworks/viewer3d!Viewer3d.pick) |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-scalebydistance-aa05634c5206|scaleByDistance]] | Method |  |
| [[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-scalebydistance-6a13bb3db7e9|scaleByDistance]] | Method | Whether the 3D viewer draws the annotation smaller the further it is from the camera: its normal size up to 10 m, shrinking beyond that to no less than 40 %,… |

## `constructor` {#member-constructor-dd3521e4e7c9}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
constructor()
````



## `qid` {#member-qid-b9e3b4cc23c7}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
qid?: string | Qid
````

The object the annotation is linked to: hovering either highlights the other

## `align` {#member-align-e37a8acec0db}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
align(): AnnotationAlign | null
````



## `align` {#member-align-c6abb5c3187c}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
align(align: AnnotationAlign | null): void
````

Which side of its anchor the annotation is drawn on, on screen; null (the default) draws text and icons centred
on it and an image of no size with its corner there

### Parameters

| Name | Type | Description |
|---|---|---|
| `align` | `AnnotationAlign \| null` |  |

## `anchor` {#member-anchor-4a5305b1da5a}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
anchor(): AnnotationAnchor
````



## `anchor` {#member-anchor-08cc3b03d2d5}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
anchor(anchor: string | null): void
````

Where on its object ([[page:reference/javascript/bimworks-viewercommon/annotation-e9883720#member-qid-b9e3b4cc23c7|qid]]) the 3D viewer puts an annotation without a position: a point of the object's
box in its model's own axes, "center" (the default) or up to three words as [[page:reference/javascript/bimworks-viewercommon/annotationanchor-f36198b9|AnnotationAnchor]] lists them.
Setting takes the words separated by spaces too; reading gives the "-" form. Read when the viewer adds the
annotation

### Parameters

| Name | Type | Description |
|---|---|---|
| `anchor` | `string \| null` |  |

## `click` {#member-click-391f5fdd953c}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
click(): Function
````



### Returns

The currently set click listener

## `click` {#member-click-f3e28721d8e5}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
click(fn: Function): void
````

Attach a click listener, only one click listener can be attached, previous one will be overwritten

### Parameters

| Name | Type | Description |
|---|---|---|
| `fn` | `Function` | The method to call whenever this annotation is clicked |

## `group` {#member-group-03825016ee82}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
group(): string
````



## `group` {#member-group-5714aafbf887}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
group(group: string): void
````

The group the annotation belongs to; groups can be shown, hidden and limited together

### Parameters

| Name | Type | Description |
|---|---|---|
| `group` | `string` |  |

## `groupLimit` {#member-grouplimit-6e14bfba3f5a}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
groupLimit(): number | null
````



### Returns

The limit on the annotations shown of this annotation's group, null for none

## `groupLimit` {#member-grouplimit-0b66aa253b6a}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
groupLimit(groupLimit: number | null): void
````

At most how many annotations of this annotation's group the 3D viewer shows, those nearest to the camera:
a positive whole number, or null (the default) for no limit. Annotations hidden behind other geometry take
no place, and hovering an annotation's object still shows it.

### Parameters

| Name | Type | Description |
|---|---|---|
| `groupLimit` | `number \| null` |  |

## `maxDistanceMm` {#member-maxdistancemm-2941e865d70d}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
maxDistanceMm(): number
````



### Returns

The currently set max distance in mm

## `maxDistanceMm` {#member-maxdistancemm-26068b34fa97}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
maxDistanceMm(distance: number): void
````

Set the maximum distance from the annotation to the camera at which it will still be displayed.
The default value of this is 0, which means that at any distance the annotation will be displayed

### Parameters

| Name | Type | Description |
|---|---|---|
| `distance` | `number` | The max distance in mm |

## `occlusion` {#member-occlusion-45d44a79b05d}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
occlusion(): "none" | "hide" | "dim"
````



## `occlusion` {#member-occlusion-2da8f5a08eb0}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
occlusion(occlusion: "none" | "hide" | "dim"): void
````

What the 3D viewer does while the annotation's point or object is hidden behind other geometry:
"hide" (the default), "dim" or "none"

### Parameters

| Name | Type | Description |
|---|---|---|
| `occlusion` | `"none" \| "hide" \| "dim"` |  |

## `position` {#member-position-97f2b1f2f5c8}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
position(): vec3
````



## `position` {#member-position-a235ef16a289}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
position(position: vec3): void
````

Where the annotation points, in viewer coordinates (the frame of `@bimworks/viewer3d!Viewer3d.pick`)

### Parameters

| Name | Type | Description |
|---|---|---|
| `position` | [[page:reference/javascript/bimworks-viewercommon/vec3-d8edaba2|vec3]] |  |

## `scaleByDistance` {#member-scalebydistance-aa05634c5206}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
scaleByDistance(): boolean | null
````



### Returns

true or false when set on this annotation, null when it follows the viewer's setting

## `scaleByDistance` {#member-scalebydistance-6a13bb3db7e9}

````typescript sdk=js sdk-namespace="@bimworks/viewercommon"
scaleByDistance(scaleByDistance: boolean | null): void
````

Whether the 3D viewer draws the annotation smaller the further it is from the camera: its normal size
up to 10 m, shrinking beyond that to no less than 40 %, and its normal size again while it or its
object is hovered. null (the default) follows the viewer's annotationScaleByDistance setting.

### Parameters

| Name | Type | Description |
|---|---|---|
| `scaleByDistance` | `boolean \| null` |  |
