Camera Class
Initialises the camera.
Constructor
Camera
()
Item Index
Methods
calculateMovementSpeed
-
acceleration
Calculates the movement speed of the camera, given the number of frames the movement key has been held down for.
Parameters:
-
acceleration
IntIn this case, this is the number of frames that the movement key has been held down for.
Returns:
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:
Projection view matrix of the camera.
goBackwards
-
acceleration
Moves the camera backwards in 3D space.
Parameters:
-
acceleration
IntThe number of frames the movement key has been held down for.
goForwards
-
acceleration
Moves the camera forwards in 3D space.
Parameters:
-
acceleration
IntThe number of frames the movement key has been held down for.
goLeft
-
acceleration
Strafes the camera to the left in 3D space.
Parameters:
-
acceleration
IntThe number of frames the movement key has been held down for.
goRight
-
acceleration
Strafes the camera to the right in 3D space.
Parameters:
-
acceleration
IntThe 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
ArrayRotation 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
IntWidth of the canvas.
-
height
IntHeight of the canvas.
snapTo
-
planet
Snaps the camera to the given planet.
Parameters:
-
planet
AstronomicalObjectThe planet object to snap to.
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.