This time our vertex array contains both the vertex coordinates and a color value for each vertex.
114 // Like any three dimensional polygon, we specify the vertices. 115 var vertices = [ 116 // Vetex coordinate 117 -1.0, -1.0, 0.0, 118 // Vertex color (r,g,b,α) 119 1.0, 0.0, 0.0, 1.0, 120 1.0, -1.0, 0.0, 121 0.0, 1.0, 0.0, 1.0, 122 0.0, 1.0, 0.0, 123 0.0, 0.0, 1.0, 1.0 124 ];
We use the same vertex coordinates as before (-1,-1) (1,-1) (0,1). This time though we include a color value for each vertex. The earlier example had three floating point elements per vertex, the addition of color data will increase this to seven elements per vertex.