API Docs for: 0.1.0
Show:

Controls Class

Defines keyboard and mouse controls for interacting with the solar system.

Constructor

Controls

()

Methods

bindKeyboardControls

()

Binds some key events to handler functions.

bindKeysToPlanets

() JSON

Handles binding certain key presses to calling the camera snapTo() function.

Returns:

JSON:

Associative array where key is keyboard shortcut, value is Astronomical Object linked to that shortcut.

bindMouseControls

()

Binds the mouse events to handler functions.

bindToAnimation

(
  • callback
)

Provides a hook for app.js to call functions after we've manually triggered animation. i.e. If we update the view in controls.js we can trigger the callback and ensure that the changes are drawn immediately (useful if the solar system animation is paused).

Parameters:

  • callback Function

    Function to call when we want to trigger the animation.

degToRad

(
  • celsius
)
Float

Converts degrees to radians. @TODO - this is a duplicate of degToRad in AstronomicalObject. Should remove the duplication.

Parameters:

  • celsius Int

    Value in degrees.

Returns:

Float:

Converted value in radians.

handleMouseDown

(
  • event
)

Handles the mouse down event. In this case, we cache the position of the mouse so it can be used in rotation calculations later.

Parameters:

  • event Event

    The mouse event.

handleMouseMove

(
  • event
)

Handles the mouse move event. In this case, we rotate the camera if the mouse button is down at the same time.

Parameters:

  • event Event

    The mouse event.

handleMouseUp

(
  • event
)

Handles the mouse up event.

Parameters:

  • event Event

    The mouse event.

millisecondsPerDay

() Float

Grabs the milliseconds per dsy from the GUI form input.

Returns:

Float:

Milliseconds per day.

paused

() Boolean

Other modules can tell if the animation is paused by querying this.

Returns:

Boolean:

True if animation is paused, false if not.