Class ScreenCamera

A fixed camera that is centered on the screen. This can be used to draw UI (like a HUD for example).

Hierarchy (view full)

Constructors

Properties

bounds: null | CameraBounds = null
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.

snapToPixel: boolean = true

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

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).

  • 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