Shader Learn

05 Data becomes vertices

Index array → triangles

Indices tell the GPU which three points make a face; two triangles make a square.

Explanation

// JS - three indices make one triangleindices = [  0, 1, 2,  0, 2, 3];
p3p2p1p0
Three.jsnew THREE.BoxGeometry() stores exactly these two arrays

2 triangles make a face; 12 make a cube.

JS sidegl.uniformMatrix4fv(uModel, …) // rotation -0.55 / 0.35

An index array joins points into triangles by number; 12 triangles make a cube. That is exactly what Three.js’s BoxGeometry stores.

Try it

  • Turn the cube and find the triangle made of p0, p1 and p2