---
title: Show a floor plan
summary: Turn the 3D viewer into a floor plan — one storey, an orthographic camera looking down, 2D mode (a drag turns the plan, nothing tilts), the ceilings hidden and every room labelled with its number, name and area — the replacement for the 2D viewer.
order: 38
languages: [javascript]
terms: [viewer, building-storey, object-state-manager, model-manager, annotation]
see-also: [how-to/viewer3d/building-storeys, how-to/viewer3d/navigation-modes, how-to/viewer3d/annotations, how-to/viewer2d/show-floor-plans, how-to/rendering/export-a-vector-drawing]
---

# Show a floor plan

A floor plan is the 3D viewer with four settings: an orthographic camera, one [[term:building-storey|storey]] visible, the camera above it looking down, and 2D mode, in which a drag turns the plan instead of orbiting. This is how to show plans in new applications: the 2D viewer, which drew plans the server generated, is being phased out ([[page:how-to/viewer2d]]). The 3D plan shows the same objects with the same selection, colours and annotations as the 3D view, because it is the 3D view. A plan *beside* a 3D view is a second viewer on the same ModelManager, which shares the loaded models ([[page:how-to/viewer3d/several-viewports]]).

## Live demo

```demo
name: floor-plan
title: A storey as a plan in the 3D viewer
models: ac11
height: 520
notes: |
  **Storey** picks the floor; press a point and go around it to turn the plan (it snaps square), right-drag or Shift-drag to pan, scroll to zoom. **Text** picks the rooms' labels (number, name and floor area in every room the text fits, on by default), room tags (annotations) or nothing. **3D** switches the same viewer back to a perspective view of the whole model, **Plan** returns to the plan.
```

## Before you start

You have a viewer with a model loaded ([[page:how-to/viewer3d/embed-the-viewer]]). The model needs building storeys; most IFC models have them.

## Steps

```example
name: viewer-floor-plan
code: javascript/viewer-floor-plan.js
notes: A page with a `<div id="viewer">` of a fixed height. The storey picker starts on floor 0, the ground floor.
highlight: 9-21,29-31,41-49
```

1. **Define a plan navigation mode.** A custom mode that extends `default`, with no binding for `lookAround` and with the middle and right buttons and Shift + left drag panning ([[page:how-to/viewer3d/navigation-modes]]). The left button keeps `orbit`, which 2D mode turns into turning the plan. The wheel still zooms. `viewer.startNavigationMode("plan")` and `viewer.startNavigationMode("default")` switch between plan and 3D at run time.
2. **Switch to 2D mode.** `viewer.set2dMode(true)` makes the camera orthographic and turns it to look straight down at what is in the middle of the view, at the same scale; `set2dMode(false)` turns it back to the perspective view it left. A camera you made orthographic yourself (`viewer.getCamera().fov = 0`, as the example does; any positive field of view below 120 switches back to perspective) stays orthographic when you leave 2D mode. In 2D mode the left button (one finger) turns the plan about the vertical axis through the point you press, without tilting it, and a pan moves the plan exactly with the pointer, as a sheet of paper under your hand. The press places the pivot; going around it turns the plan by the pointer's angle around that point, however far out you are. A cross through the pivot shows level and plumb, and the plan snaps where the model's own axes (0°, 90°, 180°, 270°) or the building's walls (the axes of the model's oriented bounding box) stand level with it; hold Shift while turning with the mouse to turn freely. A drawing on its own (a PDF or DWG) is in 2D mode by itself; `set2dMode(null)` lets the model decide again, `is2dMode()` tells which mode the viewer is in and `add2dModeListener(listener)` hears it change. `set2dMode(true, {side: "front"})` shows an elevation instead (also `"back"`, `"left"` and `"right"`; `"bottom"` looks up at the plan from below): upright, and the left button pans it; `get2dSide()` tells the side.
3. **List the storeys.** `client.bim.listBuildingStoreys(versionUuids)` answers one entry per storey, merged over the models you pass: the storeys of an architectural and an installation model with the same name, GlobalId or elevation become one entry. Each has a `name`, an `elevation`, a `floor` number (0 for the ground floor) and `buildingStoreys`, the [[term:qid|Qids]] of the storey objects in each model. An entry named `[No BS]` holds the objects that are in no storey ([[page:how-to/viewer3d/building-storeys]]).
4. **Show one storey.** `setBuildingStoreysVisibleExclusive(storeyQids)` on the [[term:object-state-manager|ObjectStateManager]] makes the objects of those storeys the only visible ones, openings left out. Hide what covers the plan from above, usually the suspended ceilings (`IFCCOVERING`).
5. **Look down on it.** `viewFit` with `viewDirection: [0, 0, 1]` puts the camera above the objects with north (the model's +Y) up. In 2D mode a fit keeps the plan turned as it is; `rotation` turns it as the 2D viewer's fit does: `"ORIGINAL"` puts the model's +X to the right, `"MODEL_AXIS"` lays the building's main axis across, `"OBJECT_AXIS"` the main axis of `rotationObject`. The direction points from the objects to the camera. With the orthographic camera the fit sizes the view to the bounding box of the objects, so the storey fills the width or the height of the viewer; `margin` keeps that percentage of the view free on each side. Fit what the plan draws: the objects of a storey can include its grid lines (`IFCANNOTATION`), which are not drawn and reach metres beyond the building.

## Room labels {#room-labels}

In 2D mode, and in 3D views from above, the viewer writes the number, the name and the floor area of every space into the room, as the 2D viewer did, without a line of code: where the text fits, horizontal on screen however the plan is turned, a fixed size on screen. Zoomed out, a room that is too small for its text shows none; zoom in and it comes. The spaces themselves can stay hidden: a room's text shows while its storey does.

The labels of the [[term:object-state-manager|ObjectStateManager]] are drawn the same way, on any object: `setLabels([{qid, labels}])`, one string per line, as for the 2D viewer:

```example
name: viewer-floor-plan-labels
code: javascript/viewer-floor-plan-labels.js
notes: Runs after `showStorey(storey)` of the example above.
```

- **Fit.** A label shows when its text fits inside its object: inside the object's rectangle (its oriented bounding box) when the object fills it, otherwise inside the largest circle that fits in the object's floor area, which the server computed at check-in. So a label in an L-shaped room sits in the room, not in the corner of its box.
- **Your text wins.** A label you set replaces a space's own text; `resetLabels()` brings that back.
- **Hidden where covered.** A label shows only where nothing is drawn above it: with two storeys shown, the upper one's floor covers the lower one's labels, and a roof covers every room under it.
- **From an angle.** In a 3D view looking down up to 70° from the vertical, a label lies in its room like text on paper: at the height of the room's top (the cut of a section plane, or the top of the walls), foreshortened, still reading left to right. Flatter, it fades and goes. `height: "bottom"` in the [[page:reference/viewer3d#planlabels|planLabels]] setting puts it on the floor instead, where walls and furniture in front cover it; `setPlanLabelsHeight("bottom")` and `setPlanLabelsHeight("top")` switch a running viewer between the two.
- **Settings.** `setPlanLabelsEnabled(false)` hides all of them, `fontScaling` sets the size in pixels (15 by default), and the [[page:reference/viewer3d#planlabels|planLabels]] setting turns off the spaces' own text (`spaces: false`) or leaves out the last lines of a label that does not fit (`dropLines: true`).
- **Corridors.** With `orientation: "AUTO"` in that setting, a label that does not fit across a narrow room runs along it instead, as on a drawing: turned with the plan, but never upside down, and bottom to top where the room stands upright.
- **Screenshots.** `screenshot({includeText: true})` draws them into the image ([[page:how-to/viewer3d/take-a-screenshot]]).

## Room tags

Room tags are cards rather than text in the plan: an annotation layer with the `roomTag` template puts the number, the name and the net floor area on every space of the storey, at any zoom ([[page:how-to/viewer3d/annotations#room-tags]]). Turn the labels off under them, `setPlanLabelsEnabled(false)`, or the rooms carry both:

```example
name: viewer-floor-plan-room-tags
code: javascript/viewer-floor-plan-room-tags.js
notes: Runs after `showStorey(storey)` of the example above. The colour leaves the spaces almost clear; without it they cover the floor in their own colour.
```

Any other annotation works on a plan too: text, icons, values from properties ([[page:how-to/viewer3d/annotations]]).

## Cut the plan {#cut}

A floor plan is cut about 1.2 m above the floor, so walls, doors and windows read as cut and what stands higher goes. `viewer.setPlanCut(z)` removes everything above height `z` (mm, in the render frame) and closes the cut with end caps, as a section plane does. It is none of the six section planes: it is not listed in `getSectionPlanes().getPlanes()`, not drawn and leaves the user all six. `setPlanCut(null)` removes it, `getPlanCut()` reads it. An annotation on an object that the cut keeps part of is drawn on the cut, over its object, even when its anchor lies above the cut (on top of a window's box). The cut hides the annotations of objects it removes whole. The storey's floor in the render frame is its `elevation` from `listBuildingStoreys`, times the model's length unit (`viewer.getModelLengthUnitMm(vid)`), through `viewer.modelToMeasurementCoordinates(vid, [0, 0, z])` and `viewer.measurementToRenderCoordinates`: cut at that height plus 1200. The cut stays when you leave 2D mode; remove it there when the plan was what it was for.

## Compared with the 2D viewer

| 2D viewer | Plan in the 3D viewer |
|---|---|
| `new Viewer2d(objectStateManager)`, `init()`, `start()` | `new Viewer3d(...)` with a plan navigation mode and `set2dMode(true)` |
| `setBuildingStoreysVisibleExclusive` | The same call |
| `setLabels([{qid, labels}])`, labels on the spaces | The same call, drawn inside the objects; the spaces' own labels without code |
| Plans generated on the server, drawn flat | The 3D geometry seen from above: furniture, stairs and sloped surfaces as they are |
| Its own viewer next to a 3D view | The same viewer switches between plan and 3D; a second `Viewer3d` on the same ObjectStateManager gives both side by side ([[page:how-to/viewer3d/several-viewports]]; in the BIM.works app, two viewers with the 3D camera on the plan: [[page:how-to/using-bimworks/connect-two-viewers]]) |

## Limits

- A label half behind a wall shows whole or not at all: it is hidden when its centre or two of its corners are covered.
- Without a cut the plan shows each object of the storey from above, so a wall is its top face and a tall cupboard hides what is under it. Cut it as a floor plan is drawn ([[page:how-to/viewer3d/show-a-floor-plan#cut]]), or export a vector drawing on the server ([[page:how-to/rendering/export-a-vector-drawing]]).

## Check

The storey fills the view from above, the rooms carry their number, name and area where the text fits, a left drag around the press point turns the plan without tilting it (the text stays horizontal) and snaps it square, a right drag moves it, and **3D** (`fov = 45`, `set2dMode(null)` and the `default` mode) brings back the perspective view of the same viewer.
