Rendering
Let's take a step back to take a look at the big picture. We mentioned before that in our architecture we have defined three main functions that define the lifecycle of our WebGL application. These functions are: configure
, load
, and render
.
Up to this point, we have set up the scene writing the code for the configure
function. After that, we have created our JSON cars and loaded them by writing the code for the load
function. Now, we will implement the code for the third function: the render
function.
The code is pretty standard and almost identical to the draw
/render
functions that we have written in previous chapters. As we can see in the following diagram, we set and clear the area that we are going to draw on, then we check on the camera perspective and then we process every object in Scene.objects
.
The only consideration that we need to have here is to make sure that we are mapping correctly the material properties defined in our JSON objects to the appropriate shader uniforms...