-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoints.js
More file actions
25 lines (23 loc) · 870 Bytes
/
points.js
File metadata and controls
25 lines (23 loc) · 870 Bytes
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
class Point {
constructor() {
this.type = 'point';
this.position = [0.0, 0.0, 0.0];
this.color = [1.0, 1.0, 1.0, 1.0];
this.size = 10;
}
render() {
var xy = this.position;
var rgba = this.color;
var size = this.size;
gl.disableVertexAttribArray(a_Position);
//gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ xy[0], xy[1] ]), gl.DYNAMIC_DRAW);
// Pass the position of a point to a_Position variable
gl.vertexAttrib3f(a_Position, xy[0], xy[1], 0.0);
// Pass the color of a point to u_FragColor variable
gl.uniform4f(u_FragColor, rgba[0], rgba[1], rgba[2], rgba[3]);
// pass the size of a point to u_size variable
gl.uniform1f(u_Size, size);
// Draw
gl.drawArrays(gl.POINTS, 0, 1);
}
}