-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (37 loc) · 1.06 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
let gl = null;
let uints_for_indices;
let generator = null;
let quad = null;
let genView = null;
let capture = false;
let prevTime = Date.now();
let alpha = 0.99;
let fps = 60;
let genTime = 0;
let quadTime = 0;
function updateFps() {
fps = alpha * fps + (1.0 - alpha) * Math.min(1000 / (Date.now() - prevTime), 9999);
document.getElementById("fps").textContent = Math.trunc(fps);
document.getElementById("fpsBox").style = document.getElementById("showFps").checked ? "" : "display:none;";
prevTime = Date.now();
}
function draw() {
updateFps();
GlUtils.resizeCanvas(gl);
generator.draw();
genView.draw();
quad.draw();
requestAnimationFrame(draw);
}
async function init() {
const mainCanvas = document.getElementById("drawCanvas");
gl = GlUtils.createContext(mainCanvas);
uints_for_indices = gl.getExtension("OES_element_index_uint");
generator = new Generator();
quad = new Quad();
genView = new GeneratorView();
await generator.init(gl);
await quad.init(gl);
await genView.init(gl);
draw();
}