October 2018
Intermediate to advanced
500 pages
12h 40m
English
In updateTransforms, we use the contents of the global variables' position and rotation to update the matrices. This is, of course, as follows::
function updateTransforms() { mat4.perspective(projectionMatrix, 45,canvas.width /gl.canvas.height, 0.1, 1000); if (coordinates === WORLD_COORDINATES) { mat4.identity(modelViewMatrix); mat4.translate(modelViewMatrix, modelViewMatrix, position); mat4.rotateX(modelViewMatrix, modelViewMatrix, rotation[0] * Math.PI / 180); mat4.rotateY(modelViewMatrix, modelViewMatrix, rotation[1] * Math.PI / 180); mat4.rotateZ(modelViewMatrix, modelViewMatrix, rotation[2] * Math.PI / 180); } else { mat4.identity(cameraMatrix); mat4.translate(cameraMatrix, cameraMatrix, position); mat4.rotateX ...