Real-Time 3D Graphics with WebGL 2
上QQ阅读APP看书,第一时间看更新

Indices

Indices are numeric labels for the vertices in a given 3D scene. Indices allow us to tell WebGL how to connect vertices in order to produce a surface. As with vertices, indices are stored in a JavaScript array and are then passed along to WebGL's rendering pipeline using a WebGL index buffer.

VBOs Versus IBOs

There are two kinds of WebGL buffers used to describe and process geometry. Buffers that contain vertex data are known as  VBOs,  and buffers that contain index data are known as  IBOs .

In this section, we will use the following steps to render an object in WebGL:

  1. Define a geometry using JavaScript arrays
  2. Create the respective WebGL buffers
  3. Point a vertex shader attribute to a VBO from the previous step to store vertex coordinates
  4. Use the IBO to render the geometry