Skip to content

free-camera.controller overview


Table of contents


utils

FreeCameraController (class)

A controller for a free-moving camera.

Signature

export declare class FreeCameraController {
  constructor(
    protected readonly keyboard: KeyboardInput,
    protected readonly camera: Renderer3dEntity,
    options: Partial<FreeCameraControllerOptions> = {}
  )
}

reset (method)

Signature

public reset(): void

onSpawned (method)

Signature

async onSpawned(world: GgWorld<any, any>): Promise<void>

onRemoved (method)

Signature

async onRemoved(): Promise<void>

tickOrder (property)

Signature

readonly tickOrder: TickOrder.INPUT_CONTROLLERS

options (property)

Signature

readonly options: FreeCameraControllerOptions

mouseInput (property)

The mouse input controller used for camera rotation.

Signature

readonly mouseInput: MouseInput

directionsInput (property)

The keyboard input controller used for camera movement.

Signature

readonly directionsInput: DirectionKeyboardInput

_spherical (property)

Signature

_spherical: MutableSpherical

resetMotion$ (property)

Signature

resetMotion$: any

FreeCameraControllerOptions (type alias)

Options for configuring a FreeCameraInput controller.

Signature

export type FreeCameraControllerOptions = {
  /**
   * A keymap for controlling camera movement, where each key corresponds to a movement direction. 'wasd' by default
   */
  keymap: DirectionKeyboardKeymap
  /**
   * The speed of camera movement in meters per second. 20 by default
   */
  cameraLinearSpeed: number
  /**
   * An elasticity factor for camera movement. 0 by default (no elastic motion)
   */
  cameraMovementElasticity: number
  /**
   * A linear speed multiplier when user holds shift key. 2.5 by default
   */
  cameraBoostMultiplier: number
  /**
   * The speed of camera rotation in radians per 1000px mouse movement. 1 by default
   */
  cameraRotationSensitivity: number
  /**
   * An elasticity factor for camera rotation. 0 by default (no elastic motion)
   */
  cameraRotationElasticity: number
  /**
   * Flag to ignore cursor movement if pointer was not locked. false by default
   */
  ignoreMouseUnlessPointerLocked: boolean
  /**
   * Flag to ignore keyboard events if pointer was not locked. false by default
   */
  ignoreKeyboardUnlessPointerLocked: boolean
  /**
   * Options for configuring mouse input.
   */
  mouseOptions: Partial<MouseInputOptions>
}