A much more realistic vertex shader. The mat4, 4x4, modelViewMatrix places the object into the scene as seen by the viewer.
214 var vertexShaderSource = "attribute vec3 position;" 215 + "attribute vec4 color;" 216 + "uniform mat4 modelViewMatrix;" 217 + "" 218 + "varying vec4 vColor;" 219 + "" 220 + "void main()" 221 + "{" 222 + " gl_Position = modelViewMatrix * vec4(position, 1);" 223 + " vColor = color;" 224 + "}";
Uniforms are constant across all vertices. We change the modelViewMatrix for the sceond triangle every time the slider is moved.
When you move through a 3D scene, you are seeing the effects of a vertex shader moving the vertices.