NavigationModeSettings
Type alias in @bimworks/viewer3d.
API catalogue · @bimworks/viewer3d · Type alias
type NavigationModeSettings = {
characterHeightMm?: number;
characterRadiusMm?: number;
climbHeightMm?: number;
collision?: boolean;
extends?: PredefinedNavigationMode;
eyeHeightMm?: number;
forwardMode?: "horizontal" | "camera" | "orbit";
gravity?: boolean;
jumpHeightMultiplier?: number;
keyBindings?: ViewerKeyBindings;
keyboardNavigation?: boolean;
lookAround?: boolean;
navigationSpeed?: number;
pointerLock?: boolean;
stopAtEdges?: boolean;
turnWithKeyboard?: boolean;
type?: PredefinedNavigationMode;
walkThroughWalls?: boolean;
[key: string]: unknown;
};Defines one custom navigation mode. The four predefined modes are available as presets through extends:
default: regular orbit/pan/zoom mouse navigation, no keyboard movement.walk: W/S forward and back, A/D sideways, left/right arrows turning (turnLeft/turnRight), Q/Z up and down, and a left-button drag looking around (Alt + left too). With the walkable-surfaces artifact present, walk physics adds wall collision, gravity with stair/step climbing and PageUp/PageDown storey jumps (seecollisionand the character parameters).game: pointer-lock look-around with horizontal WASD/arrow movement.drone: pointer-lock look-around with camera-direction WASD/arrow movement.
Custom modes can map one or more keyboard or mouse combinations to any action supported by NavigationModeSettings with keyBindings.
A KeyBinding uses DOM KeyboardEvent.code values such as KeyW, ArrowUp or PageDown, and DOM mouse button numbers:
0 main/left button, 1 middle button and 2 secondary/right button.
Navigation movement bindings can set speed to scale that binding's movement or turn speed. For example,
{ keyCode: "ArrowUp", speed: 1 } and { keyCode: "ArrowUp", shiftKey: true, speed: 5 } keep the current fast-shift behavior configurable per binding.
Example#
const viewer = new Viewer3d(objectStateManager, undefined, {
navigationMode: "inspection",
navigationModes: {
inspection: {
extends: "game",
pointerLock: false,
keyBindings: {
lookAround: [{ button: 0, altKey: true }],
navigationForward: [{ keyCode: "KeyW" }, { keyCode: "ArrowUp" }],
navigationBackward: [{ keyCode: "KeyS" }, { keyCode: "ArrowDown" }],
navigationLeft: [{ keyCode: "KeyA" }],
navigationRight: [{ keyCode: "KeyD" }]
}
}
}
});Members#
| Member | Kind | Description |
|---|---|---|
| characterHeightMm | Property | Character height in millimetres for headroom checks. Defaults to 1800. |
| characterRadiusMm | Property | Character radius in millimetres for lateral clearance checks. Defaults to 250. |
| climbHeightMm | Property | Highest step (mm) climbed automatically; also the ground-snap reach. Defaults to 300. |
| collision | Property | Enable walk physics (wall collision, ground clamping, gravity, PageUp/PageDown storey jumps) in the walk and game modes. Requires the server-generated walkab… |
| extends | Property | Predefined mode to use as the base configuration. Defaults to default. |
| eyeHeightMm | Property | Eye height above the floor in millimetres. Defaults to 1650. |
| forwardMode | Property | horizontal keeps forward/back movement level with the world; camera follows the camera direction. |
| gravity | Property | Fall when no floor is in reach (through slab holes, off edges). Defaults to true. |
| jumpHeightMultiplier | Property | Space jump height as a multiple of climbHeightMm. Defaults to 2.5 (750 mm). Requires gravity. |
| keyBindings | Property | Mode-specific shortcut overrides. Empty arrays disable the default bindings for that action. |
| keyboardNavigation | Property | Enable keyboard movement actions. Automatically enabled when navigation key bindings are supplied. |
| lookAround | Property | Enable drag look-around when a binding maps to lookAround. |
| navigationSpeed | Property | Mode-level multiplier for free keyboard navigation speed. The predefined drone mode defaults to 3. |
| pointerLock | Property | Request pointer lock when the mode starts and use mouse movement for look-around. |
| stopAtEdges | Property | With gravity, refuse a step off an edge that would start a fall deeper than 600 mm: the walker slides along the edge as along a wall. A jump still goes over … |
| turnWithKeyboard | Property | Use left/right keyboard bindings to yaw instead of strafe. Used by the predefined walk mode. |
| type | Property | Alias for extends, kept for callers that prefer describing the movement type. |
| walkThroughWalls | Property | Keep the ground clamp and gravity but skip wall collision. Defaults to false. |
characterHeightMm#
characterHeightMm?: numberCharacter height in millimetres for headroom checks. Defaults to 1800.
characterRadiusMm#
characterRadiusMm?: numberCharacter radius in millimetres for lateral clearance checks. Defaults to 250.
climbHeightMm#
climbHeightMm?: numberHighest step (mm) climbed automatically; also the ground-snap reach. Defaults to 300.
collision#
collision?: booleanEnable walk physics (wall collision, ground clamping, gravity, PageUp/PageDown storey jumps) in the
walk and game modes. Requires the server-generated walkable-surfaces artifact; without it navigation
silently behaves as before. Defaults to true when the artifact is present.
extends#
extends?: PredefinedNavigationModePredefined mode to use as the base configuration. Defaults to default.
eyeHeightMm#
eyeHeightMm?: numberEye height above the floor in millimetres. Defaults to 1650.
forwardMode#
forwardMode?: "horizontal" | "camera" | "orbit"horizontal keeps forward/back movement level with the world; camera follows the camera direction.
gravity#
gravity?: booleanFall when no floor is in reach (through slab holes, off edges). Defaults to true.
jumpHeightMultiplier#
jumpHeightMultiplier?: numberSpace jump height as a multiple of climbHeightMm. Defaults to 2.5 (750 mm). Requires gravity.
keyBindings#
keyBindings?: ViewerKeyBindingsMode-specific shortcut overrides. Empty arrays disable the default bindings for that action.
keyboardNavigation#
keyboardNavigation?: booleanEnable keyboard movement actions. Automatically enabled when navigation key bindings are supplied.
lookAround#
lookAround?: booleanEnable drag look-around when a binding maps to lookAround.
navigationSpeed#
navigationSpeed?: numberMode-level multiplier for free keyboard navigation speed. The predefined drone mode defaults to 3.
pointerLock#
pointerLock?: booleanRequest pointer lock when the mode starts and use mouse movement for look-around.
stopAtEdges#
stopAtEdges?: booleanWith gravity, refuse a step off an edge that would start a fall deeper than 600 mm: the walker slides along the
edge as along a wall. A jump still goes over it. Defaults to true in the walk mode, false in the game mode.
turnWithKeyboard#
turnWithKeyboard?: booleanUse left/right keyboard bindings to yaw instead of strafe. Used by the predefined walk mode.
type#
type?: PredefinedNavigationModeAlias for extends, kept for callers that prefer describing the movement type.
walkThroughWalls#
walkThroughWalls?: booleanKeep the ground clamp and gravity but skip wall collision. Defaults to false.