---
title: Show the reference grid
summary: Switch on an infinite metric grid in the ground plane that the camera orbits and zooms over, that double-click flies to, and whose intersections snap like vertices.
order: 55
since: 3.0
languages: [javascript]
see-also: [how-to/viewer3d/navigation-modes, how-to/viewer3d/measure, how-to/using-bimworks/edit-a-model, reference/viewer3d]
---

# Show the reference grid

An empty scene, or the space next to a model, gives the camera nothing to hold on to: orbiting over it has no pivot and zooming towards it has no target. The grid gives that space a surface. Lines every 0.1, 1, 10 or 100 metres, depending on the zoom, with the axes coloured; the orbit pivot and the double-click fly-to land on it, and its intersections are snapping targets for the measurement and editing tools.

## Live demo

```demo
name: grid
title: The grid, with and without a model
models: schependomlaan
height: 520
needs: Starts with an empty scene; nothing is loaded until you ask. Open BIM.works and sign in once in this browser.
notes: |
  Orbit and zoom over the empty grid, double-click a point on it. Change the **Elevation** and the **Opacity**, switch **Snap to intersections** off and on. Then **Load a model onto the grid** to see the spacing follow the zoom.
```

## Steps

1. **Switch it on** after `initializeViewer()`; there is no viewer setting to have it on from the start.
2. **Set its options**: elevation, opacity, snapping and the colours.

```javascript {#grid-api}
viewer.setGridEnabled(true);
viewer.setGridOptions({
	elevation: 0,          // metres
	opacity: 1,
	snapping: true,        // false: visible but inert
	minorColor: [0.42, 0.47, 0.53, 0.35],
	majorColor: [0.28, 0.34, 0.41, 0.60],
	axisXColor: [0.78, 0.25, 0.25, 0.85],   // alpha 0 hides an axis
	axisYColor: [0.25, 0.60, 0.30, 0.85]
});
const spacing = viewer.getGridSnapSpacing();   // metres, or null when the grid is not in view
```

## How it behaves

- The grid is a render layer of the viewer with its own shader: it is drawn against the depth of the model, fades with distance and with the viewing angle, and switches its spacing in decades as the camera moves.
- It is a *surface* for navigation: picking a point on empty ground returns a hit on the grid, so the orbit pivot, the double-click fly-to and the measurement tools all work over it.
- Its intersections are seeded into the vertex-snapping buffer, so a measurement or an object move snaps to them exactly like to model vertices. A grid point hidden behind a wall does not snap.

## In the app

The grid button in the View window's toolbar switches it on and off. It is off by default and there is no key binding.

## Limits

The grid is a plane at one elevation; it is not a per-storey grid.

## Check

With the grid on and no model loaded, a double-click on the grid flies the camera to that point, and `getGridSnapSpacing()` returns the spacing of the lines in view.
