-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.js
28 lines (28 loc) · 1.08 KB
/
lights.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var LIGHTS = function () {
return {
ready: false,
array: [],
load: function () {
this.ready = false;
$.getJSON(URL.lights, function (data) {
LIGHTS.array = data;
LIGHTS.ready = true;
$('canvas').trigger('loadData');
});
},
getLightUniformLocation: function(gl, program, varName) {
return {
xyz: gl.getUniformLocation(program, varName + ".xyz"),
ambient: gl.getUniformLocation(program, varName + ".ambient"),
diffuse: gl.getUniformLocation(program, varName + ".diffuse"),
specular: gl.getUniformLocation(program, varName + ".specular")
};
},
setLightUniform: function(gl, lightUniform, light) {
gl.uniform3f(lightUniform.xyz, light.x, light.y, light.z);
gl.uniform3fv(lightUniform.ambient, light.ambient);
gl.uniform3fv(lightUniform.diffuse, light.diffuse);
gl.uniform3fv(lightUniform.specular, light.specular);
}
}
}();