PacktPublishing / Real-Time-3D-Graphics-with-WebGL-2

Real-Time 3D Graphics with WebGL 2, published by Packt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mat4.perspective require radians, not degrees

owmo-dev opened this issue · comments

When adjusting the fov in ch04_06_projection-modes.html the viewport "flips" all over the place. It looks like the perspective function used in glmatrix library requires radians as input, not degrees as used in the code.

https://glmatrix.net/docs/module-mat4.html

let fov = 45
mat4.perspective(projectionMatrix, fov, width / height, 1, 5000);

Should be:

let fov = 45
mat4.perspective(projectionMatrix, fov * (Math.PI / 180), width / height, 1, 5000);