---
title: 2D viewer changes in 3.0
summary: Every change an application built on the 2.x 2D viewer meets in 3.0 — the swapped mouse buttons, several models in one plan, fitting, the client getter, labels and annotations, the declared types and the viewercommon changes a 2D application feels — with what to do for each.
order: 40
languages: [javascript]
terms: [qid, building-storey]
see-also: [changelog/v3-0, changelog/v3-0/viewer3d, changelog/v3-0/from-2-to-3, how-to/viewer2d/show-floor-plans]
---

# 2D viewer changes in 3.0

`@bimworks/viewer2d` keeps its package name, its entry point and its type definitions, and the constructor is unchanged. This page lists everything else an application built on the 2.x 2D viewer sees change in 3.0, and what to do about it. The 2D viewer is being phased out: for new work, show plans in the 3D viewer ([[page:how-to/viewer3d/show-a-floor-plan]]), whose own changes are on [[page:changelog/v3-0/viewer3d]].

Every change has a class:

- **Breaking**: 2.x code fails or gives a wrong result.
- **Behaviour**: the same code runs, but the result or what the user sees differs.
- **Requirement**: how the viewer is installed or served.

## Overview {#overview}

| Change | 2.x | 3.0 | Class | What to do |
|---|---|---|---|---|
| Mouse buttons | a left drag panned, a middle drag rotated | a left drag rotates, a middle drag pans, as in the 3D viewer | Behaviour | tell your users ([below](#mouse)) |
| `Version` export | `Version` | [[js:@bimworks/viewer2d/BuildVersion|`BuildVersion`]] | Breaking | rename |
| `viewer2d.client` | a field | a getter without a setter | Breaking if used | set the client on the [[js:@bimworks/viewercommon/ModelManager|ModelManager]] |
| Several models in one plan | each in its own frame, up to tens of metres apart | placed together; the camera follows the 3D viewer correctly | Behaviour | drop your own offset correction |
| Fit on load | per model, as each arrived | once, to all the models of the first batch | Behaviour | — |
| [[js:@bimworks/viewer2d/Viewer2d#viewFit|`viewFit`]], [[js:@bimworks/viewer2d/Viewer2d#viewFitModels|`viewFitModels`]] | — | return a Promise; a fit can turn the plan ([[js:@bimworks/viewercommon/ViewFitOptions#rotation|`rotation`]]) | Behaviour | await them where order matters |
| Labels | applied to the objects loaded at that moment | also applied to objects loaded later | Behaviour | — |
| Annotation overlay | — | a `.bwa-annotation-overlay` element in the container | Behaviour | check your own elements in the container |
| Versions in the [[js:@bimworks/viewercommon/ModelManager|ModelManager]] | any version object | a version without [[js:@bimworks/jssdk/Version#uuid|`uuid`]] or its metadata is refused ([[js:@bimworks/viewercommon/IncompleteVersionError|`IncompleteVersionError`]]) | Breaking for some | load full versions ([below](#viewercommon)) |
| Dependencies | — | all `@bimworks/*` and `@sascom/*` packages of one version | Requirement | upgrade the packages together |

## Mouse buttons {#mouse}

**Left drag rotates** (Behaviour). A drag with the left button turns the plan, and a drag with the middle button pans it, the same as in the 3D viewer; 2.x did the opposite. There is no setting for the mapping. With rotation switched off, a left drag does nothing (in 2.x it panned). The viewer also stops the browser's autoscroll on a middle click in its container. Your users notice at once, so tell them.

## Packages {#packages}

**[[js:@bimworks/viewer2d/BuildVersion|`BuildVersion`]]** (Breaking). The export `Version`, the viewer's build string, is now [[js:@bimworks/viewer2d/BuildVersion|`BuildVersion`]], as in jssdk, viewercommon and the 3D viewer; `import {Version} from "@bimworks/viewer2d"` fails when the module links.

**One version for every package** (Requirement). Upgrade `@bimworks/viewer2d`, `@bimworks/viewercommon`, `@bimworks/jssdk`, `@sascom/commonjs` and `@sascom/jsclient` together, to the version of the instance: packages of two versions install two copies of jssdk, and its [[js:@bimworks/jssdk/Qid|`Qid`]] and [[js:@bimworks/jssdk/QidSet|`QidSet`]] objects then fail `instanceof` across them ([[page:how-to/install/javascript]]). The single-file build is still `viewer2d.bimworks.js` ([[page:how-to/install/downloads]]).

**The npm package**. It ships `www/` and `viewer2d.d.ts` only, and its JavaScript without comments; entry point and paths are unchanged.

## The viewer {#viewer}

**`viewer2d.client` is a getter** (Breaking, rare). 2.x copied the [[js:@bimworks/viewercommon/ModelManager|ModelManager]]'s client into a field when the viewer was created. 3.0 reads it from the [[js:@bimworks/viewercommon/ModelManager|ModelManager]] each time it needs it, through a getter without a setter, so `viewer2d.client = x` throws a `TypeError` in a module. Set the client on the [[js:@bimworks/viewercommon/ModelManager|ModelManager]] ([[js:@bimworks/viewercommon/ModelManager#setClient|`setClient`]]) instead.

**Several models in one plan** (Behaviour). 2.x drew every model in its own frame, so models that belong together could lie tens of metres apart. 3.0 places every model relative to the first one, so they line up, and a camera position from the 3D viewer is converted with that viewer's offset, which 2.x left out, so it lands where it should. When no storey matches the camera's height, the storeys shown stay as they are. Remove any offset your application applied itself.

**Fit on load** (Behaviour). 2.x fitted the view to each model's box as it arrived. 3.0 fits once, to the union of the models of the first batch.

**Fitting** (Behaviour). [[js:@bimworks/viewer2d/Viewer2d#viewFit|`viewFit`]] and [[js:@bimworks/viewer2d/Viewer2d#viewFitModels|`viewFitModels`]] return a Promise that resolves once the fit is applied. [[js:@bimworks/viewercommon/ViewFitOptions#rotation|`ViewFitOptions.rotation`]] is new: `KEEP`, the default, keeps the 2.x behaviour; `ORIGINAL`, `WIDEST_HORIZONTAL`, `MODEL_AXIS` and `OBJECT_AXIS` turn the plan, the last one by [[js:@bimworks/viewercommon/ViewFitOptions#rotationObject|`rotationObject`]] or the one fitted object. [[js:@bimworks/viewercommon/ViewFitOptions#animationTimeMs|`animationTimeMs`]] is honoured, next to the older `duration`, and the scale is right for a turned view.

**Labels** (Behaviour). Labels set with [[js:@bimworks/viewercommon/ObjectStateManager#setLabels|`ObjectStateManager.setLabels`]] also reach objects that load later. Text placement was rewritten.

**Annotations** (Behaviour). The viewer always adds an element `.bwa-annotation-overlay` to its container: absolutely positioned, `z-index: 12`, and transparent to the pointer. It draws the template annotation layers; annotations added with [[js:@bimworks/viewercommon/ObjectStateManager#addAnnotation|`addAnnotation`]] are still not drawn in 2D. Check elements of your own that you position in the viewer's container.

**Declarations**. These change no behaviour, but TypeScript written against the 2.x declarations may stop compiling:

- [[js:@bimworks/viewer2d/Viewer2d#addModels|`addModels(newVersions, allVersions)`]] and [[js:@bimworks/viewer2d/Viewer2d#removeModels|`removeModels(versions)`]] take versions; 2.x declared [[js:@bimworks/viewercommon/Model|`Model`]] and `unknown`.
- [[js:@bimworks/viewercommon/ObjectStateListener#primarySelectionChanged|`primarySelectionChanged`]], a declared method that did nothing, is gone; the [[js:@bimworks/viewercommon/ObjectStateManager|ObjectStateManager]] calls it only on listeners that have it.
- [[js:@bimworks/viewer2d/Viewer2d#isTextShown|`isTextShown`]], [[js:@bimworks/viewer2d/Viewer2d#getFontScale|`getFontScale`]], [[js:@bimworks/viewer2d/Viewer2d#setFontScale|`setFontScale`]], [[js:@bimworks/viewer2d/Viewer2d#getActiveStorey|`getActiveStorey`]], [[js:@bimworks/viewer2d/Viewer2d#hasModels|`hasModels`]], [[js:@bimworks/viewer2d/Viewer2d#toggleFullScreen|`toggleFullScreen`]] and [[js:@bimworks/viewer2d/Viewer2d#isFullScreen|`isFullScreen`]] are declared. New are [[js:@bimworks/viewer2d/Viewer2d#setCameraPoseViewer|`setCameraPoseViewer`]], [[js:@bimworks/viewer2d/Viewer2d#cameraPoseToWorld|`cameraPoseToWorld`]], [[js:@bimworks/viewer2d/Viewer2d#worldToCameraPose|`worldToCameraPose`]] and [[js:@bimworks/viewer2d/Control#getWorldCoordinatesFromScreenCoordinates|`Control.getWorldCoordinatesFromScreenCoordinates`]], the [[js:@bimworks/viewer2d/ScreenshotOptions#annotations|`annotations`]] option of [[js:@bimworks/viewer2d/Viewer2d#screenshot|`screenshot`]], [[js:@bimworks/viewer2d/Viewer2dSettings#debugging|`debugging.renderStatistics`]], and the declaration of the existing [[js:@bimworks/viewer2d/Viewer2dSettings#showLoader|`showLoader`]] setting.

## Changes in viewercommon that a 2D application meets {#viewercommon}

**Incomplete versions are refused** (Breaking for some). [[js:@bimworks/viewercommon/ModelManager#addModels|`ModelManager.addModels`]] and [[js:@bimworks/viewercommon/ModelManager#setModels|`setModels`]] reject with [[js:@bimworks/viewercommon/IncompleteVersionError|`IncompleteVersionError`]] for a version without a [[js:@bimworks/jssdk/Version#uuid|`uuid`]], or without its metadata ([[js:@bimworks/jssdk/Version#im_metadata|`im_metadata`]]) unless it is a point cloud, a PDF or a GLB. The 2.x [[js:@bimworks/viewercommon/ModelManager|ModelManager]] and 2D viewer never read the metadata, so a 2D-only application could pass the version summaries of a node listing; those have no metadata. Load each version in full with [[js:@bimworks/jssdk/Fs#getNodeVersion|`client.fs.getNodeVersion(uuid)`]], and wait until its processing has finished.

**Labels are [[js:@bimworks/viewercommon/Label|`{qid, labels}`]]** (Breaking, TypeScript only). The [[js:@bimworks/viewercommon/Label|`Label`]] type is [[js:@bimworks/viewercommon/Label|`{qid, labels}`]]; 2.x declared `{qid, lines}`, which the viewers ignored. [[js:@bimworks/viewercommon/ObjectStateManager#setLabels|`setLabels`]] returns a Promise.

**[[js:@bimworks/viewercommon/ObjectStateManager#highlightQuery|`highlightQuery(query, highlightColor, backgroundColor)`]]** (Breaking, TypeScript only). 2.x declared a first argument `origin` that the code never had, so TypeScript that followed the declaration passed its listener as the query.

**[[js:@bimworks/viewercommon/ModelManager#inverseOf|`inverseOf`]]** (Behaviour, a fix). [[js:@bimworks/viewercommon/ModelManager#inverseOf|`ModelManager.inverseOf()`]] returns every loaded object not in the argument; in 2.x it always returned an empty set.
