Let's take a step back and assess the big picture. We previously mentioned that, in our architecture, we have defined three main functions that define the life cycle of our WebGL application. These functions are configureload, and draw.

Thus far, we've set up the scene by writing the code for the configure function. After that, we 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 draw function.

The code is pretty standard and almost identical to the draw functions that we've written in previous chapters. As the following code demonstrates, we set and clear the area that we are going to draw. Then, we check the camera's perspective and process ...

Get Real-Time 3D Graphics with WebGL 2 - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.