---
title: Walk through a building
summary: Walk through a building at eye height with collision, gravity, stairs, jumps and storey jumps on the walkable surfaces the server computes, show a route, and name the room and zones the camera is in.
order: 25
since: 3.0
languages: [javascript]
terms: [building-storey, qid]
see-also: [how-to/viewer3d/navigation-modes, reference/viewer3d/key-bindings, how-to/viewer3d/proximity-fade, reference/viewer3d, explanation/geometry-and-the-viewers#walkable-surfaces]
---

# Walk through a building

The walk navigation mode puts the camera at eye height and moves it with the keyboard, turning with the left and right keys and looking around with Alt and the mouse. When the server has generated the *walkable surfaces* of the loaded models, walking gets physics: walls stop you, gravity keeps you on the floor and drops you through a slab opening, steps and stairs are climbed automatically, and Page Up and Page Down take you to the nearest walkable spot one storey up or down. While you walk, a tracker can name the room you are in and the zones it belongs to. This guide sets both up; switching modes in general is on [[page:how-to/viewer3d/navigation-modes]].

## Live demo

```demo
name: walk-mode
title: Walk through the building
models: maleva
height: 560
notes: |
  The demo opens on the whole building, flies to the front porch and switches to walk mode by itself; *Back to the entrance* replays that. Click in the view to give it the keyboard, then **W A S D** or the arrows to walk, **Alt + drag** to look around, **Page Up / Page Down** for the next storey. In *Fullscreen* the demo captures the mouse (pointer lock): the mouse looks around and **A / D** step sideways; click the view once when the browser asks for it, **Esc** releases the mouse. The panel says whether this instance has walkable surfaces for the model; without them walking is free flight at eye height. Walk through a door and *Where you are* in the panel names the room and its zones; **Next room** flies you into the spaces one by one, **Room features** fetches property sets or base quantities for every space in one query, and **Show the room** tints the space you are in (spaces are hidden by default). Combine with the proximity fade to see where you are going.
```

## Before you start

- Physics needs the instance feature `walkable_surfaces` (on by default) and a generated walkable-surfaces artifact for every loaded model; without either, walk mode is plain first-person flight. `viewer.walkPhysicsAvailable()` says whether it is there.
- Naming the room needs the space index of the model, which every check-in writes; a model checked in before it existed needs a reindex.

## 1. Start walking

`startWalkNavigation(settings)` starts the mode. Its settings, on top of the keyboard and pointer settings every mode has:

| Setting | Default | Meaning |
|---|---|---|
| `collision` | on | Walls stop the character. |
| `gravity` | on | The character stays on the floor and falls through openings. |
| `walkThroughWalls` | off | Ignore walls while keeping the floor. |
| `characterHeightMm` | 1800 | Height of the character. |
| `eyeHeightMm` | 1650 | Height of the camera above the floor. |
| `characterRadiusMm` | 250 | How close the character gets to a wall. |
| `climbHeightMm` | 300 | The highest step climbed without a jump. |
| `navigationSpeed` | 1.5 | Times a base pace of 1 m/s; Shift runs at five times that. |

Walking moves at that fixed pace regardless of what is in front of the camera and of the frame rate. The viewer fetches the walkable surfaces on the first walk and uses them for collision, ground clamping, step climbing and the storey jump.

**Space jumps** in walk and game modes. A jump rises by `climbHeightMm × jumpHeightMultiplier`, with a default multiplier of 2.5 (750 mm with the default step limit). Move forward while jumping to reach a higher step; Shift adds speed. Walls and low ceilings still block movement. Release Space before jumping again after landing. Jumping requires walkable surfaces, collision and gravity; Space is reserved from auto-rotation in these modes even when physics is unavailable.

## 2. Show a route

The server can compute a route between two points over the walkable surfaces; the viewer shows it with `showRoute` and follows it with the camera with `followRoute`. `clearPaths()` removes it.

## 3. Name the room you are in

```javascript {#current-space}
const tracker = await viewer3d.ensureCurrentSpaceTracker(); // null without a space index
await tracker.configure({
    getClause: "property.Pset_SpaceCommon.Reference",
    labelTemplate: "{attribute.Name} · {zone.attribute.Name}"
});
tracker.on("current_space_changed", ({spaces, stale}) => {
    const room = spaces[0]; // best match: the reference model's hit, then the smallest footprint
    console.log(room ? room.label : "outside", room ? room.zones.map((z) => z.name) : [], stale);
});
tracker.on("current_zone_changed", ({zones}) => console.log(zones.map((z) => z.name)));
```

`ensureCurrentSpaceTracker()` downloads the space index once and, on every camera change, tests the eye against the spaces — throttled, with a minimum move, and with a short grace period at a door so the label does not flicker to "nothing" on the threshold. `configure` sets the extra features to fetch for every space (a BQL `GET` fragment) and the label template. One BQL prefetch fetches the name, the `zone` path and those features for every space; entering a room never queries. `current_space_changed` fires when the ordered set of containing spaces or the stale flag changes, `current_zone_changed` only when the zone set differs. How the index and the test work is on [[page:explanation/geometry-and-the-viewers#walkable-surfaces]].

## In the app

The navigation-mode buttons in the View window start walk mode; hover one for its key cheat sheet. The character controls next to them set *collision*, *through walls*, *gravity*, and the height, radius and climb sliders. A notice says when the loaded models have no walkable-surfaces data.

While you walk, the chip in the top-left corner of the 3D view names the room you are in, with the zones (`IfcZone`) the room belongs to beneath it; a click on a zone tints every space of that zone, and **Show** tints the room itself, in the 3D and the 2D view alike. Click the chip to see the extra features of the room. The chip is on by default; the door-handle button in the 3D menu bar hides it. In a workspace, the Models tab has two settings for it: **Current space: extra features** (a BQL GET fragment such as `property.Pset_SpaceCommon.Reference, quantity.Qto_SpaceBaseQuantities.NetFloorArea`) and **Current space: label template** (`{attribute.Name} · {zone.attribute.Name}`); the explorer of a published workspace shows the same chip with those settings. The chat's `get_current_space` tool answers "which room am I in" from the same state.

## Limits

Models with a rotated placement drop out of the physics. Very large models are still generated in one piece, which costs memory on the server.

A space without geometry is not in the space index and cannot be located. The storey of the space is not stored yet. A zone nested in another zone is not followed: only the zones a space is assigned to directly are listed. The tracker follows rendered camera changes; a camera set from code is located on the next frame.

## Check

`viewer.walkPhysicsAvailable()` is `true` for a model with walkable surfaces; walking into a wall stops the camera, and walking through a door fires `current_space_changed` with the room's label.
