I am trying to implement multiple lights in my shader but I have trouble to fill the uniform with my light data.
My vertex shader:
attribute vec3 aVertex
gl.uniform3fv expects a flattened array of floats. Also, you are calling it multiple times with the same uniform location. So, the last one wins. Imagine that uniform3fv is a low-level copy command, and you give it (destination, source). It just copies a buffer from one place to another.
Assuming your example has only 3 lights, you could assign the location uniform this way:
var locations = [
1.0, 0, 0,
0, 1.0, 0,
0, 0, 0
];
gl.uniform3fv(shaderProgram.pointLightingLocationUniform, locations);
I would also recommend using a more simple shader when you are debugging problems like this. With something like the following in your vertex shader:
for (int i = 0; i < 3; i++) {
vColor += uPointLightingLocation[i];
}
And fragment shader:
gl_FragColor = vec4(vColor, 1);
Then, if your polygons are yellow you know it is working.