@xeokit/sdk-plugins - v0.1.5
    Preparing search index...

    Class WalkModePlugin

    Viewer plugin for first-person walking through a model, with gravity, collisions and steps.

    Requires a Z-up World (viewer.camera.worldAxis = [1, 0, 0, 0, 0, 1, 0, -1, 0]).

    Default controls: mouse to look (pointer lock), WASD to move, Shift to run, Space to fly up, G free flight (Space / Ctrl up / down), F go through the targeted door, Esc to exit. Keys are configurable with cfg.keys, modes can be switched off with cfg.modes, and speeds, body dimensions, physics and object types are set by the WalkModeSettings options.

    import {Viewer} from "@xeokit/xeokit-sdk";
    import {WalkModePlugin} from "@xeokit/sdk-plugins";

    const viewer = new Viewer({canvasId: "myCanvas"});
    const walkMode = new WalkModePlugin(viewer, {
    keys: {forward: ["KeyW", "ArrowUp"], fly: ["KeyV"]},
    modes: {jetpack: false},
    walkSpeed: 2,
    eyeHeight: 1.6
    });

    walkMode.on("target", (target) => console.log(target)); // "door" or null
    walkMode.on("active", (active) => console.log(active ? "walking" : "orbiting"));

    button.onclick = () => walkMode.activate(); // Pointer lock needs a user gesture

    Hierarchy

    Index
    id: string

    ID for this Plugin, unique within its Viewer.

    keys: Readonly<Record<WalkModeAction, readonly string[]>>

    Effective key bindings; actions of disabled modes have no keys.

    viewer: Viewer

    The Viewer that contains this Plugin.

    • Starts walking from the camera's current look position.

      Call it from a user gesture (e.g. a button click), so that the browser grants pointer lock.

      Returns void

    • Logs an error message to the JavaScript developer console, prefixed with the ID of this Plugin.

      Parameters

      • msg: string

        The error message

      Returns void

    • Fires an event at this Plugin.

      Parameters

      • event: string

        The event type name

      • value: any

        The event parameters

      Returns void

    • Logs a message to the JavaScript developer console, prefixed with the ID of this Plugin.

      Parameters

      • msg: string

        The error message

      Returns void

    • Removes event subscription.

      Parameters

      • subId: string

        Subscription id

      Returns void

    • Logs a warning message to the JavaScript developer console, prefixed with the ID of this Plugin.

      Parameters

      • msg: string

        The error message

      Returns void