A class that controls the camera quaternion and rotation from pointer events

Hierarchy

  • ControlCamera
    • ControlCamera

Constructors

  • Creates a new ControlCamera instance with a new camera object

    Parameters

    • o: {
          canvas: HTMLCanvasElement;
          fov?: number;
          height: number;
          max?: number;
          min?: number;
          mouseSensitivity?: number;
          width: number;
      }

      The options for the camera object

      • canvas: HTMLCanvasElement

        The canvas element to bind the camera to

      • Optional fov?: number

        The field of view for the camera in degrees

      • height: number

        The canvas height

      • Optional max?: number

        The far clipping plane for the camera

      • Optional min?: number

        The near clipping plane for the camera

      • Optional mouseSensitivity?: number

        The sensitivity of the camera movement

      • width: number

        The canvas width

    Returns ControlCamera

Properties

camera: PerspectiveCamera

The PerspectiveCamera that this camera uses

canPanMouse: boolean = false

A boolean flag that indicates whether the camera can pan using mouse controls or not

canPanTouch: boolean = false

A boolean flag that indicates whether the camera can pan using touch controls or not

canvas: HTMLCanvasElement

The canvas element the camera is bound to

classes: RequiredThree

The Three.js classes to be used

mouseSensitivity: number = 100

The mouse sensitivity for camera panning

rx: number = RADIAN_HALF

The angle in radians for the x-axis rotation

ry: number = -RADIAN_HALF

The angle in radians for the y-axis rotation

touch: {
    down: boolean;
    id: number;
    lx: number;
    ly: number;
    x: number;
    y: number;
} = ...

An object that stores the touch information

Type declaration

  • down: boolean

    A flag indicating whether a touch event is currently active

  • id: number

    The pointer event identifier of the active touch event

  • lx: number

    The x-coordinate of the last touch event

  • ly: number

    The y-coordinate of the last touch event

  • x: number

    The difference in the x-coordinate between the current and the last touch event

  • y: number

    The difference in the y-coordinate between the current and the last touch event

Methods

  • Disables the camera panning using mouse controls

    Returns ControlCamera

    The current instance of ControlCamera

  • Disables the camera panning using touch controls

    Returns ControlCamera

    The current instance of ControlCamera

  • Enables the camera panning using the mouse and adds the event listeners to the element

    Returns ControlCamera

    The current instance of ControlCamera

  • Enables the camera panning using touch screen and adds the event listeners to the element

    Returns ControlCamera

    The current instance of ControlCamera

  • A function that gets called on the pointer move event

    Parameters

    • _e: {
          x: number;
          y: number;
      }
      • x: number
      • y: number

    Returns void

  • A function that gets called when the pointer gets unlocked

    Returns void

  • Sets the default angles for the camera quaternion and updates it accordingly

    Parameters

    • x: number

      The angle in radians for the x-axis rotation

    • y: number

      The angle in radians for the y-axis rotation

    Returns ControlCamera

    The current instance of ControlCamera

Generated using TypeDoc