Chevron DownAPI Reference

FirstPersonController

Inherits from Base Controller.

The FirstPersonController class can be passed to either the Deck class's controller prop or a View class's controller prop to specify that viewport interaction should be enabled.

FirstPersonController is the default controller for FirstPersonView.

Usage

Use with the default view:

import {Deck, FirstPersonView} from '@deck.gl/core';

new Deck({
  views: new FirstPersonView(),
  controller: {keyboard: false, inertia: true},
  initialViewState: viewState
});

is equivalent to:

import {Deck, FirstPersonView} from '@deck.gl/core';

new Deck({
  views: new FirstPersonView({
    controller: {keyboard: false,  inertia: true}
  }),
  initialViewState: viewState
})

Options

Supports all Controller options with the following default behavior:

  • dragMode: default 'rotate' (drag to rotate)
  • dragPan: not effective, this view does not support panning
  • keyboard: arrow keys to move camera, arrow keys with shift/ctrl down to rotate, +/- to zoom

Custom FirstPersonController

You can further customize the FirstPersonController's behavior by extending the class:

import {Deck, FirstPersonView, FirstPersonController} from '@deck.gl/core';

class MyFirstPersonController extends FirstPersonController {

  handleEvent(event) {
    if (event.type === 'pan') {
      // do something
    } else {
      super.handleEvent(event);
    }
  }
}

new Deck({
  views: new FirstPersonView(),
  controller: {type: MyFirstPersonController},
  initialViewState: viewState
})

See the Controller class documentation for the methods that you can use and/or override.

Source

modules/core/src/controllers/first-person-controller.js