Class FollowingCamera

A camera that smoothly follows a point. Optionally it can be contained within specified bounds.

Hierarchy (view full)

Constructors

Properties

acceleration: number = 20
bounds: null | CameraBounds = null
desired: Vector2 = ...
lockDistance: number = 1
maxSpeed: number = 900
modelView: Matrix4 = ...

The model view matrix of this camera. Do not modify outside of camera code.

projection: Matrix4 = ...

The projection matrix of this camera. Do not modify outside of camera code.

slowDistance: number = 100
snapToPixel: boolean = true

If set to true, the position will be snapped to pixels.

speed: number = 0
viewportHeight: number = 0
viewportWidth: number = 0
x: number = 0
y: number = 0
zoom: number = 1

Methods

  • Returns number

    The current x position of the camera (before snapping to pixels).

  • Returns number

    The current y position of the camera (before snapping to pixels).

  • Make the camera move instantly to the desired position instead of gradually moving it.

    Returns void

  • Move the camera to the specified coordinates and apply pixel snapping if configured.

    Parameters

    • x: number

      The new x position of the camera.

    • y: number

      The new y position of the camera.

    Returns void

  • Set the new viewport size of the camera.

    Parameters

    • width: number

      The new width of the viewport.

    • height: number

      The new height of the viewport.

    Returns void

  • Set the camera to the specified coordinates and apply pixel snapping if configured.

    Parameters

    • x: number

      The new x position of the camera.

    • y: number

      The new y position of the camera.

    Returns void

  • Set the zoom value and update the projection matrix accordingly.

    Parameters

    • zoom: number

      The new zoom value.

    Returns void

  • Perform camera movement.

    Parameters

    • deltaTime: number

      The time that elapsed since the last frame.

    Returns void