Architectural updates
Let's review the structure of the examples developed in the book. Each web page includes several scripts. One of them is WebGLApp.js
. This script contains the WebGLApp
object.
WebGLApp review
The WebGLApp
object
defines three function hooks that control the life cycle of the application. As shown in the diagram, we create a WebGLApp
instance inside the runWebGLApp
function. Then, we connect the WebGLApp
hooks to the configure
, load
, and draw
functions that we coded. Also, please notice that the runWebGLApp
function is the entry point for the application and it is automatically invoked using the onload
event of the web page.
Adding support for matrix stacks
The diagram also shows a new script: SceneTransforms.js
. This file contains the SceneTransforms
objects that encapsulate the matrix-handling operations including matrix stacks operations push and pop. The SceneTransforms
object replaces the functionality provided in Chapter 4, Camera, by the initTransforms
, updateTransforms...