Time for action – orthographic and perspective projections
Open the file
ch4_ProjectiveModes.html
in your HTML5 Internet browser.This exercise is very similar to the previous one. However, there are two new buttons: Perspective and Orthogonal. 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 depth cues that is characteristic of orthogonal projections:
Now switch to Perspective mode:
Explore the source code. Go to the
updateTransforms
function:function updateTransforms(){ if (projectionMode == PROJ_PERSPECTIVE){ mat4.perspective(30, c_width / c_height, 10, 5000, pMatrix); } else{ mat4.ortho(-c_width, c_width, -c_height, c_height, -5000, 5000, pMatrix); } }
Please take a look at the parameters that we are using to set up the projective view.
Let's modify the field of view. Create a global variable right before the
updateTransforms
function:var fovy...