Mouse, touch, and keyboard controller for navigating and interacting with a
View's
Camera. Three navigation modes
(orbit, first-person, plan-view), context-aware movement scaling,
pivot-about-pick, and ViewObject hover / pick / right-click events.
The navigation/model module adds the default model-centric interaction controller
for a View. It combines orbit, first-person and plan-view camera navigation with
pointer-aware model interaction: hover, snap, pick, double-pick, right-click, pivot
around picked geometry, and fly-to gestures. Use one ModelNavigationController
per View, configured with a navigation mode and optional pick / key-map overrides.
Three navigation modes — OrbitNavigationMode (orbit
around a focus point), FirstPersonNavigationMode (free WASD
walking), PlanViewNavigationMode (top-down pan + zoom).
Switch live via modelNavigation.navMode = ....
Pointer-following — dynamic camera target tracking that
responds to where the cursor is pointing.
Context-aware movement scaling — speed bigger in open
spaces, smaller in confined spaces; computed from the
under-cursor depth so the user doesn't need to tune speed
manually.
Pivot-about-pick — orbit around the picked world point
instead of a global origin, so rotating around a detail keeps
the detail centred.
Axis-aligned-view shortcuts — KEY_NUM_1 … KEY_NUM_6
snap to top / bottom / front / back / left / right views.
Per-event hooks — onHover, onPicked,
onDoublePicked, onRightClick, with onHoverEnter /
onHoverOut for transition-only handlers.
Configurable key map — QWERTYLayout (default) and
AZERTYLayout ship; arbitrary remaps via the keyMap
parameter on construction or live mutation afterwards.
Vertical constraint — constrainVertical: true clamps
pitch to [-90°, 90°] so the camera never flips upside-down.
Installation
Install the package using npm:
npminstall@xeokit/sdk
Usage
This example demonstrates how to set up a Viewer with a WebGLRenderer,
a Scene to manage geometry and materials, plus model-centric camera navigation and pointer interaction via ModelNavigationController.
xeokit Model Navigation Controller
Mouse, touch, and keyboard controller for navigating and interacting with a View's Camera. Three navigation modes (orbit, first-person, plan-view), context-aware movement scaling, pivot-about-pick, and ViewObject hover / pick / right-click events.
The
navigation/modelmodule adds the default model-centric interaction controller for a View. It combines orbit, first-person and plan-view camera navigation with pointer-aware model interaction: hover, snap, pick, double-pick, right-click, pivot around picked geometry, and fly-to gestures. Use one ModelNavigationController per View, configured with a navigation mode and optional pick / key-map overrides.Shape
Features
OrbitNavigationMode(orbit around a focus point),FirstPersonNavigationMode(free WASD walking),PlanViewNavigationMode(top-down pan + zoom). Switch live viamodelNavigation.navMode = ....KEY_NUM_1…KEY_NUM_6snap to top / bottom / front / back / left / right views.onHover,onPicked,onDoublePicked,onRightClick, withonHoverEnter/onHoverOutfor transition-only handlers.QWERTYLayout(default) andAZERTYLayoutship; arbitrary remaps via thekeyMapparameter on construction or live mutation afterwards.constrainVertical: trueclamps pitch to[-90°, 90°]so the camera never flips upside-down.Installation
Install the package using npm:
Usage
This example demonstrates how to set up a Viewer with a WebGLRenderer, a Scene to manage geometry and materials, plus model-centric camera navigation and pointer interaction via ModelNavigationController.
Navigation Modes
ModelNavigationController provides three camera navigation modes while retaining the same model hover, pick, snap and right-click event surface:
Orbit Mode
To activate orbit mode:
+and-.SHIFTwhile left-dragging.First-Person Mode
Enables camera movement similar to a first-person video game.
WandS(QWERTY) orZandS(AZERTY).AandD.Plan-View Mode
Keeps the camera locked to a top-down perspective.
W,A,S,D).ModelNavigationController Events
ModelNavigationControllertriggers events when interacting with ViewObjects using a mouse or touch input.Usage
To subscribe to an event:
To unsubscribe:
Event List
Hover Events
"hover"– Fired when the pointer moves over an entity."hoverOff"– Fired when the pointer moves over empty space."hoverEnter"– Fired when the pointer enters an entity."hoverOut"– Fired when the pointer leaves an entity.Click & Tap Events
"picked"– Fired on left-click/tap on an entity."pickedSurface"– Fired on left-click/tap on an entity's surface."pickedNothing"– Fired on left-click/tap on empty space.Double Click & Tap Events
"doublePicked"– Fired on double-click/tap on an entity."doublePickedSurface"– Fired on double-click/tap on an entity's surface."doublePickedNothing"– Fired on double-click/tap on empty space.Right Click Event
"rightClick"– Fired on right-click anywhere on the canvas.Custom Keyboard Mappings
The default key mappings can be overridden to fit specific layouts.
Alternatively, define custom mappings: