Rendering

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 configure, load, 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.