The Camera
The camera object allows to control the what you see in the visualization. Those operations are implemented using matrices for projection and transformations.
Used coordinates spaces
Fatum uses three different coordinates spaces :
- Model coordinates are used in the world of the visualization.
- screen coordinates are WebGL normalised device coordinates. In this space, the rendering area (or viewport) is a square of 2x2, where the bottom left corner is (-1,-1) and the top right corner is (1,1). This space is useful because the screen's center is (0,0).
- Window coordinates, a.k.a pixels. This is most widely used by the OS. Coordinates you get during events will most likely use this coordinate space.
The camera offers conversion functions to easily switch between those coordinates spaces.
Camera operations
The main camera operation is to move the camera around the scene. You can specify a translation vector in model coordinates using moveModel(vector)
, or in screen coordinates using moveScreen(vector)
.
You can also zoom in the scene using zoom(scale, center)
with scale being the zoom ratio (>1 zooms in, <1 zooms out) and center being the coordinates of the point on which to zoom.
Those two operations can be combined to center a specific portion of the visulization using centerBox(box, margin)
.
The setViewport(viewport)
method modifies which portion of the window in rendered to. Viewport is specified in pixels (aka window coordinates).
Double buffered camera
The camera is also double buffered to allow animations. All operations affect the back camera. The camera will animate when fatum.animate()
is called. It is also possible to swap
the camera states without animation.