Let's look at an example covering the different types of projections:
- Open the ch04_06_projection-modes.html file in your browser.
- This exercise is very similar to the previous one. However, there are two new options under Projection Mode: Perspective and Orthogonal Projection. As you can see, Perspective is activated by default.
- Change the camera type to Orbiting.
- Change the projective mode to Orthographic.
- Explore the scene. Notice the lack of the depth cues characteristic of orthogonal projections:
![](https://static.packt-cdn.com/products/9781788629690/graphics/assets/d8173bc0-3ec2-4833-85b1-bddb0d1e8d6b.png)
- Switch to Perspective mode:
![](https://static.packt-cdn.com/products/9781788629690/graphics/assets/3c05ed7f-ab40-49e3-8132-904154678bb6.png)
- Explore the source code. Go to the updateTransforms function:
function updateTransforms() {
const { width, height } = canvas;
if (projectionMode === PERSPECTIVE_PROJECTION) {
mat4.perspective(
projectionMatrix,
fov,
width / height,
10,
5000
)...