O'Reilly logo

WebGL Game Development by Sumeet Arora

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the basic camera

Let's now write our class for the basic camera. What have we learned so far? There are two transformation matrices: the view matrix and the projection matrix. To calculate the view matrix, we need four parameters: up, direction, left, and position. These parameters define the camera's orientation and position in space.

To compute the projection matrix, we need four parameters as well: field of view (radians), aspect ratio of the 2D screen, and the near and far clip planes.

Hence, in our basic camera class, we will need getters/setters for our four parameters and a function to calculate the view and projection matrices. Although the camera class in games would need more functions such as pitch and yaw, we will first create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required