SDK JS
    Preparing search index...

    An embeddable, framework-agnostic MapLibre control panel (a maplibregl.IControl) for the SDK's first-person navigation — the walk/drone mode that pins the camera at a fixed height above ANY rendered surface (terrain, 3D Tiles, I3S, splats, point clouds, BIM) and moves it with the keyboard.

    The panel offers:

    • a draggable pegman (the hero interaction, Street-View style): drag the little figure out of the panel and drop it anywhere on the map to enter first person AT that spot — a ghost figure follows the pointer, a drop ring lights up while over the map, and Escape (or releasing off the map) cancels; while first person is active the pegman shows as "placed",
    • a prominent First person toggle that engages/disengages the nav at the current camera position (and reflects the controller's live state, however it was changed),
    • a Walk / Fly mode switch (walk blocks forward motion at walls; fly climbs up and over anything),
    • a Surface padlock — fly mode's terrain clamp: locked, the eye rides at the set height above whatever is under it; released, it holds its altitude (free flight). Inert in walk mode, which always stays on the surface,
    • a Height input in metres with a live feet-equivalent hint (the scroll wheel also adjusts height while navigating, and the input follows),
    • a Speed input in m/s, and
    • a Climb slider (walk mode): the surface rise a step may gain before it is refused as a wall, in metres, with the slope that allowance buys AT THE CURRENT SPEED on the line beneath — the obstacle probe scales with speed, so editing Speed changes what walk mode will climb, and this is where that stops being invisible.

    Both number inputs are two-way bound: edits go through the controller (which clamps — height to the 2 ft minimum, speed to 0.1 m/s) and the value the controller actually holds is written back, so a clamped entry corrects itself in place.

    import { createFirstPersonNav, FirstPersonNavWidget } from '@bitruvius/sdk-maplibre';

    const nav = createFirstPersonNav(map, { heightM: 1.8, mode: 'walk' });
    map.addControl(new FirstPersonNavWidget({ nav }), 'top-right');

    FirstPersonNavWidgetOptions for the configuration fields.

    Implements

    • IControl
    Index

    Constructors

    Methods

    • MapLibre IControl hook: the default corner when the control is added without an explicit position.

      Returns ControlPosition

      The MapLibre ControlPosition 'top-right'.

    • MapLibre IControl hook: build the DOM, inject the (ref-counted) stylesheet, subscribe to the controller's events, and render the current state. Called by map.addControl(...).

      Parameters

      • map: Map$1

        The MapLibre map this control is being added to — the pegman drop hit-tests and unprojects against it.

      Returns HTMLElement

      The control's root HTMLElement for MapLibre to place.

      Error when FirstPersonNavWidgetOptions.nav was not provided.

    • MapLibre IControl hook: unsubscribe from the controller, remove the root element, and release this instance's stylesheet reference. The controller itself is NOT disabled or disposed — the widget does not own it. Called by map.removeControl(...).

      Returns void

    • Collapse the panel to its round little-man FAB, or expand it back.

      Parameters

      • collapsed: boolean

        true to fold to the FAB, false to expand the panel.

      Returns void