FirstPersonControls Class

Extends Group
Module: Controls

First person controls can be controlled using the mouse and keyboard.

Provides a navigations system familiar to the one found on FPS games.

The mouse left button can be used to look around, and the keyboard arrows for movement.

Methods

getDirection

() Vector3

Used to get camera direction for this controller.

Controller direction can be used to simplify controlling physics objects, create objects in the camera direction, etc.

Returns:

Vector3:

Normalized camera direction.

updateControls

()

Update controls position and rotation.

Should be called if some of its properties are changed manually.

Properties

moveKeys

Array

Array with keys to be used to move the object.

  • Forward
  • Backward
  • Left
  • Right

movementEnabled

Boolean

Indicates if its possible to move the object using the Keyboard keys.

Default: true

moveOnPlane

Boolean

If set to true the object will only move on X and Z axis.

Default: false

moveSpeed

Number

Movement speed, relative to the world.

Default: moveSpeed

needsButtonPressed

Boolean

Flag to indicate if the button left button needs to be pressed to rotate the object.

Default: true

sensitivity

Number

Mouse sensitivity.

vector

Vector2

Orientation of the camera.

X is the horizontal orientation and Y the vertical orientation.