Camera Translation

Let's move the camera to [0, 0, 4] in world coordinates. This means four units from the origin on the positive z-axis. Remember, at this point, we do not know about a matrix that moves the camera. We only know how to move the world (with the Model-View matrix). If we applied:

mat4.translate(modelViewMatrix, modelViewMatrix, [0, 0, 4]);

In such a case, the world would be translated 4 units on the positive z-axis, and since the camera position has not been changed, it would be located at [0, 0, -4], which is exactly the opposite of what we want.

Now, say that we applied the translation in the opposite direction:

mat4.translate(modelViewMatrix, modelViewMatrix, [0, 0, -4]);

In such a case, the world would be moved 4 units on the negative z-axis and then the camera would be located at [0, 0, 4] in the new world-coordinate system.

In the following section, we will explore translations in both world space and camera space.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.95.38