API Docs for: 0.1.0
Show:

Camera Class

Module: Camera

Initialises the camera.

Constructor

Camera

()

Methods

calculateMovementSpeed

(
  • acceleration
)
Int

Calculates the movement speed of the camera, given the number of frames the movement key has been held down for.

Parameters:

  • acceleration Int

    In this case, this is the number of frames that the movement key has been held down for.

Returns:

Int:

A number representing the distance in the 3D world that we should move by in the next frame.

getProjectionViewMatrix

() array

Returns the projection view matrix of the camera. This is used by the AstronomicalObject class.

Returns:

array:

Projection view matrix of the camera.

goBackwards

(
  • acceleration
)

Moves the camera backwards in 3D space.

Parameters:

  • acceleration Int

    The number of frames the movement key has been held down for.

goForwards

(
  • acceleration
)

Moves the camera forwards in 3D space.

Parameters:

  • acceleration Int

    The number of frames the movement key has been held down for.

goLeft

(
  • acceleration
)

Strafes the camera to the left in 3D space.

Parameters:

  • acceleration Int

    The number of frames the movement key has been held down for.

goRight

(
  • acceleration
)

Strafes the camera to the right in 3D space.

Parameters:

  • acceleration Int

    The number of frames the movement key has been held down for.

moveCameraToStartingPosition

()

Resets camera to its starting position - which is the origin of the solar system, set back by a certain distance so as not to be stuck "inside" the Sun.

resetPosition

()

Resets the camera to its original position.

rotateView

(
  • rotationMatrix
)

Rotates the camera by the given rotation matrix.

Parameters:

  • rotationMatrix Array

    Rotation matrix to merge with the camera matrix.

setCanvasSize

(
  • width
  • height
)

Sets the size of the canvas and informs the necessary objects/matrices of the change.

Parameters:

  • width Int

    Width of the canvas.

  • height Int

    Height of the canvas.

snapTo

(
  • planet
)

Snaps the camera to the given planet.

Parameters:

toggleFullScreen

()

Toggles full screen mode. When full screen, the canvas is set to the size of the viewport, otherwise it is set to the default height and width, defined in this class.

updateProjectionMatrix

()

Updates the projection view matrix.