Controls Class
Defines keyboard and mouse controls for interacting with the solar system.
Constructor
Controls
()
Item Index
Methods
bindKeyboardControls
()
Binds some key events to handler functions.
bindKeysToPlanets
()
JSON
Handles binding certain key presses to calling the camera snapTo() function.
Returns:
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
FunctionFunction to call when we want to trigger the animation.
degToRad
-
celsius
Converts degrees to radians. @TODO - this is a duplicate of degToRad in AstronomicalObject. Should remove the duplication.
Parameters:
-
celsius
IntValue in degrees.
Returns:
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
EventThe 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
EventThe mouse event.
handleMouseUp
-
event
Handles the mouse up event.
Parameters:
-
event
EventThe mouse event.
millisecondsPerDay
()
Float
Grabs the milliseconds per dsy from the GUI form input.
Returns:
Milliseconds per day.
paused
()
Boolean
Other modules can tell if the animation is paused by querying this.
Returns:
True if animation is paused, false if not.