---
title: Annotate a model
summary: Every way to put information on objects in the 3D viewer — labels, icons, templates, live data and BVL — on one model.
layout: showcase
order: 45
languages: [javascript]
terms: [annotation, qid, bql, bvl, object-state-manager]
see-also: [reference/viewer3d, reference/bvl, how-to/viewer3d/section-planes, tutorials/bql]
---

# Annotate a model

One model, the AC11 Institute, in one viewer. Pick an example: it runs in the viewer next to its code, and the viewer is reset before the next one. A JavaScript example is the body of an async function with `client`, `viewer`, `objectStateManager`, `vid` and the sample `data` at hand; every person, issue, booking and reading in that data is made up. An annotation shows only while its object does, and spaces are hidden by default, so the examples on rooms show their spaces first. A view of one storey hides the other storeys. The three examples on section planes cut the building with planes; clearing *Show planes* in the viewer's bar hides them while they keep cutting.

```demo
name: annotations
models: ac11
title: AC11 Institute, annotated
needs: Loads the AC11 Institute demo model in this page with the demo API token of your account: open BIM.works and sign in once in this browser.
```

### Overview {#overview}

The Keller on its own: room tags, issues and comment threads from the application, a sensor in every lab, and the model's own accessibility data as a check. The rest of the list takes these apart.

```example
name: overview
code: javascript/annotations/overview.js
target: annotations
viewpoint: overview
caption: The Keller on its own, with a room tag, issues, threads, a sensor and a check on its rooms.
```

Look: hover a pin for its card; orbit, and what goes behind walls fades or hides.

## Labels and icons

### Text labels {#text-labels}

The number and long name of every space on the Erdgeschoss, as two-line text labels. One `TextAnnotation` per object, added together.

```example
name: text-labels
code: javascript/annotations/text-labels.js
target: annotations
viewpoint: erdgeschoss
caption: The Erdgeschoss on its own, a label on each space.
```

Look: zoom out until labels overlap; the nearer one stays and shows how many it stands for.

### Icons with a click {#icons}

A wrench on each of the four technical rooms of the Keller. A click on an icon selects its room.

```example
name: icons
code: javascript/annotations/icons.js
target: annotations
viewpoint: keller
caption: The Keller, a wrench on Technikraum I to IV.
```

Look: click a wrench; the room is selected.

### At a point you click {#at-a-point}

A note where you click on a surface, rather than on a whole object. `selectVertex` hands over the point; its `position` is in the coordinates an annotation takes.

```example
name: at-a-point
code: javascript/annotations/at-a-point.js
target: annotations
viewpoint: keller
caption: The Keller; each click on a surface adds a note there.
```

Look: click a wall, then the floor; each click adds the next note.

### Images {#images}

A picture pinned to the seminar room. An `ImageAnnotation` takes any image URL; this one is a sketch in a data URL.

```example
name: images
code: javascript/annotations/images.js
target: annotations
viewpoint: keller
caption: The Keller with a sketch pinned to the Seminarraum.
```

Look: the picture keeps its size while you zoom.

### Live text, without templates {#live-text}

A temperature in Labor K1 that changes every second, done the way it is done without templates: replace the label's lines. The sensors example below does it for many rooms at once.

```example
name: live-text
code: javascript/annotations/live-text.js
target: annotations
viewpoint: labs
caption: The labs of the Keller; Labor K1 shows a temperature that changes every second.
```

Look: the reading changes in place; nothing else redraws.

## A busy view, readable

### Behind walls {#occlusion}

Every one of the 206 windows labelled, in three groups that behave differently behind walls: hidden, dimmed, and always shown.

```example
name: occlusion
code: javascript/annotations/occlusion.js
target: annotations
viewpoint: facades
caption: The building from the south-east, a label on every window.
```

Look: orbit to the back; one window in three keeps its label, one dims, one hides.

Only what can be picked hides an annotation: the test reads the picking pass. With an object state manager made with `{pickability: true}`, `setPickableSet` decides both which objects take a click and which can hide a label, so objects shown only as context (the dimmed rest of a takeoff, say) neither stop a click nor hide a value. The quantity takeoff demo ([[page:demos/quantity-takeoff]]) works that way.

An annotation on the top or bottom of its object, such as a room tag on the floor, stands for the whole object. It shows while the object's centre line, from floor to ceiling, can be seen, and nothing inside the object's box hides it. So the furniture in a room does not hide its tag, nor do the room's own walls when you look at a slant. The slab under the room hides the tag from below, and the storey above hides it from above.

### Merging and counts {#clustering}

Labels on all windows: overlapping ones merge into the nearest, which shows how many it stands for. An icon on every door, coloured by storey: merged icons show a ring of their colours.

```example
name: clustering
code: javascript/annotations/clustering.js
target: annotations
viewpoint: facades
caption: The building from the south-east, window labels with counts, door icons with rings.
```

Look: zoom in and the merged labels come apart; hover a ring for what it holds.

### Limits {#limits}

At most 30 window labels, those nearest the camera, and at most 50 annotations in the viewer altogether.

```example
name: limits
code: javascript/annotations/limits.js
target: annotations
viewpoint: facades
caption: The building from the south-east; only the nearest labels show.
```

Look: orbit; the labels move to the windows that are nearest now.

### Smaller further away {#distance}

Window labels drawn smaller further from the camera, down to 40 % of their size, and not at all beyond 40 m.

```example
name: distance
code: javascript/annotations/distance.js
target: annotations
viewpoint: west-end
caption: The south-west corner up close, window labels shrinking along the façade and gone beyond 40 m.
```

Look: zoom out; the labels shrink, then disappear at 40 m.

### On hover only {#hover-only}

A label that appears beside a window only while the window is hovered, outside its footprint so it does not cover it.

```example
name: hover-only
code: javascript/annotations/hover-only.js
target: annotations
viewpoint: facades
caption: The building from the south-east; hovering a window shows its label.
```

Look: move over the façade; each window's label follows the pointer.

### Section planes {#section-planes}

Labels on every space, and a section box around the 1. Obergeschoss. Its annotation mode decides what happens to the labels it cuts away: hide them, ignore the box, or project them onto its faces.

```example
name: section-planes
code: javascript/annotations/section-planes.js
target: annotations
viewpoint: obergeschoss-1
caption: A section box around the 1. Obergeschoss; the labels of the other storeys sit on its faces.
```

Look: the labels of the other storeys sit on the box's top and bottom faces; the next example switches between the modes.

### Hide, ignore or project {#section-plane-modes}

The three annotation modes on one plane, a button each: a section plane through the middle of the building cuts away its east half, and the buttons in the viewer's bar choose what it does with the labels of the corridors there. The frame's `toolbar` stands in for the controls of your application.

```example
name: section-plane-modes
code: javascript/annotations/section-plane-modes.js
target: annotations
viewpoint: building
caption: The building cut through the middle; the labels of its east corridors hidden, left where they were, or on the cut.
```

Look: Ignore leaves the east labels in the air where the cut-away half stood; Project lines them up on the cut, each at its own storey.

### From the top {#section-plane-from-above}

The same three buttons on a plane from the top, the way you look into a storey: the plane cuts just under the ceiling of the 1. Obergeschoss, and every space of the building has its number, in its storey's colour. The buttons choose what the plane does with the numbers of the 2. Obergeschoss and the Dachgeschoss above it. Its reach keeps that to one storey: `setAnnotationReach(3000)` hides every label more than 3 m past the plane, whatever the mode, so in a tower only the storey above comes along. The spaces are taken out of the end caps (`removeFromEndcapsSet`): they are solids too, and their caps would close every room; the walls and slabs keep theirs.

```example
name: section-plane-from-above
code: javascript/annotations/section-plane-from-above.js
target: annotations
viewpoint: into-obergeschoss-1
caption: The 1. Obergeschoss cut open from the top, a number on every space; those of the storey above hidden, left where they were, or on the cut, and those further up hidden.
```

Look: Project puts each number of the 2. Obergeschoss on the cut, right above the room under it (319 over 219); Ignore leaves them higher up, off their rooms; Hide shows the 1. Obergeschoss alone. All storeys brings back the grey numbers of the Dachgeschoss, almost 5 m past the plane.

## Templates from model data

### Object labels {#object-labels}

The name, long name and type with its icon, on the spaces and doors of the Erdgeschoss. The `objectLabel` template asks for its fields itself, so a WHERE clause is all it needs, in JavaScript or in BVL.

```example
name: object-labels
code: javascript/annotations/object-labels.js
bvl: bvl/annotations/object-labels.bvl
target: annotations
viewpoint: erdgeschoss
caption: The Erdgeschoss on its own, an object label on each space and door.
```

Look: switch to the BVL tab; the same labels come from the server's resolution.

### Room tags {#room-tags}

Number, name and net floor area on every space of the 1. Obergeschoss, as the architectural room tag on the floor of the room. The same in BVL.

```example
name: room-tags
code: javascript/annotations/room-tags.js
bvl: bvl/annotations/room-tags.bvl
target: annotations
viewpoint: obergeschoss-1
caption: The 1. Obergeschoss on its own, a room tag on each of its spaces.
```

Look: zoom out; the tags shrink to 40 % and stay readable longer than the rooms.

### Properties of your own {#properties}

The spaces of the Keller with fields of your own GET: their category, whether they are accessible, their maximum temperature. A card shows three fields; with more, hover it for all of them.

```example
name: properties
code: javascript/annotations/properties.js
target: annotations
viewpoint: keller
caption: The Keller on its own, its spaces with category, accessibility and temperature.
```

Look: the keys read as you named them; quantities keep their units.

### What you select {#selection}

Whatever you select gets its type and storey. The selection is a query parameter, so it is never spliced into the query text.

```example
name: selection
code: javascript/annotations/selection.js
target: annotations
viewpoint: erdgeschoss
caption: The Erdgeschoss; selected objects get a card with their type and storey.
```

Look: select a few objects with Shift; the cards follow the selection.

### A template of your own {#own-template}

A template written on the page: the category of a space as a coloured chip, with its net floor area beside it. Its fields are BQL, so the layer only needs a WHERE clause. With `hover: "template"` it draws its own hover: `ctx.hovered` is true while the chip or its space is under the pointer, and the chip is drawn again when that changes.

```example
name: own-template
code: javascript/annotations/own-template.js
target: annotations
viewpoint: keller
caption: The Keller on its own, a category chip on every space.
```

Look: hover a chip or its space, and the chip rings in its colour; the chips merge by colour, and a count's tooltip lists the categories it holds.

A card of your own can look like the built-in ones: `AnnotationTemplateKit.css`, included in the template's `css`, styles a `.card` with its `.head`, `.eyebrow`, `h3`, `.facts`, `.meta`, `.actions` and `.button`, and `AnnotationTemplateKit.pill(color, label)` draws a status pill. The repair notes demo ([[page:demos/repair-annotations]]) is built that way.

### One per zone {#per-zone}

One annotation per zone of the model, on the bounds of its spaces together: its name, description and number of spaces.

```example
name: per-zone
code: javascript/annotations/per-zone.js
target: annotations
viewpoint: outside
caption: The building from the south-west, a card in the middle of each zone.
```

Look: the temperature zones span storeys; their cards sit between them.

## Data from your application

### Issues {#issues}

Eight issues from an issue tracker, each on a room by its GlobalId: a pin in its status colour, open and urgent ones in front, a card on hover with buttons your application handles.

```example
name: issues
code: javascript/annotations/issues.js
target: annotations
viewpoint: keller
caption: The Keller on its own, issue pins on its rooms; Labor K1 has two.
```

Look: hover a pin, then click Zoom to in its card.

### Conversations {#conversations}

Comment threads on rooms: who takes part and how much is unread, the last comments on hover. Closing a thread changes its row, and the annotation follows.

```example
name: conversations
code: javascript/annotations/conversations.js
target: annotations
viewpoint: keller
caption: The Keller on its own, comment threads on the seminar room and Labor K4.
```

Look: click Close thread in a card; the stack greys out.

### BCF topics {#bcf}

The topics of a BCF file, placed by the GlobalIds of their components: the topic type's code in the status colour, the details on hover.

```example
name: bcf
code: javascript/annotations/bcf.js
target: annotations
viewpoint: keller
caption: The Keller on its own, BCF topics on four rooms.
```

Look: Open viewpoint in a card flies to the component.

### Sensors {#sensors}

A temperature sensor in every lab and meeting room of the Keller, against the room's own maximum temperature from the model, and CO₂ in the seminar room. A simulated feed sends a reading per room every second.

```example
name: sensors
code: javascript/annotations/sensors.js
target: annotations
viewpoint: labs
caption: The labs of the Keller with live readings; one sensor has gone quiet.
```

Look: zoom out past 30 m; the sensors become dots in their state's colour.

### Desks {#desks}

The 52 desks of the building as free, booked or in use, who and until when on hover. A template written here, on bookings that change every two seconds.

```example
name: desks
code: javascript/annotations/desks.js
target: annotations
viewpoint: desks
caption: The 2. Obergeschoss on its own, each desk a square in its booking's colour; the desks of the storeys below are hidden with them.
```

Look: watch a desk change colour; its card changes with it.

### Maintenance {#maintenance}

The technical rooms and the two lab benches as assets: the name and tag from the model, the schedule from a maintenance system, joined on the GlobalId.

```example
name: maintenance
code: javascript/annotations/maintenance.js
target: annotations
viewpoint: keller
caption: The Keller on its own, asset chips on its technical rooms; the lab benches are in Labor I, one storey up.
```

Look: the overdue air handling unit has a red dot and comes first.

### Progress per storey {#progress}

Fit-out progress per storey from a planning file: one ring per storey, on the bounds of its spaces together.

```example
name: progress
code: javascript/annotations/progress.js
target: annotations
viewpoint: outside
caption: The building from the south-west, a progress ring on each storey.
```

Look: hover the late storey for planned against forecast.

## From BVL

### Text and icons {#bvl-text-and-icons}

The annotations BVL had before templates: an icon on every lab of the Keller, and the long name of every room there while it is hovered.

```example
name: bvl-text-and-icons
code: bvl/annotations/bvl-text-and-icons.bvl
target: annotations
viewpoint: keller
caption: The Keller on its own, a flask on every lab.
```

Look: hover a room for its name.

### An accessibility check {#bvl-checks}

The model's `HandicapAccessible` as a check on the spaces of the 1. Obergeschoss: a pass where it is true, a warning where it is false, drawn by the `checkResult` template.

```example
name: bvl-checks
code: bvl/annotations/bvl-checks.bvl
target: annotations
viewpoint: obergeschoss-1
caption: The 1. Obergeschoss on its own, a pass or a warning on each space.
```

Look: hover a warning for what was expected against what was found.

### Your own template, named in BVL {#bvl-app-template}

The category chip of "A template of your own", registered by this page as `docs.spaceCategory` and named in BVL with its fields bound. A viewer that has not registered the template shows the fields as text.

```example
name: bvl-app-template
code: bvl/annotations/bvl-app-template.bvl
target: annotations
viewpoint: keller
caption: The Keller on its own, a category chip on every space.
```

Look: the same chips as in the JavaScript example; here the server resolves the category and area.

## Your own look

### Another accent and font {#theme}

The same kinds of annotations in another accent, font and radius: the theme variables, set on an element around the viewer. Every template reads them.

```example
name: theme
code: javascript/annotations/theme.js
target: annotations
viewpoint: keller
caption: The Keller on its own, object labels and threads in purple and a serif font.
```

Look: hover a thread; its card has the new accent too.

### Markup in data stays text {#escaping}

Data from outside with markup in it: a name that tries to run script, a link that is not one, a type in bold. A template escapes every value.

```example
name: escaping
code: javascript/annotations/escaping.js
target: annotations
viewpoint: labs
caption: Labor K1 with an object label whose data is markup, shown as text.
```

Look: the label shows the markup as characters; nothing runs.
