2020-04-07 21:44:46 +02:00
|
|
|
class Visual {
|
|
|
|
constructor() {
|
|
|
|
this.data = []; //for drawing
|
|
|
|
this.dataArray = [];
|
|
|
|
}
|
2020-08-01 21:51:54 +02:00
|
|
|
|
|
|
|
updateData() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-07 21:44:46 +02:00
|
|
|
draw() {
|
|
|
|
}
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VisualDrawer {
|
2020-08-01 21:51:54 +02:00
|
|
|
constructor() {
|
|
|
|
this.visuals = {
|
|
|
|
"sphere": new Sphere(),
|
|
|
|
"wave": new Wave(),
|
|
|
|
"water": new Water()
|
|
|
|
}
|
|
|
|
}
|
2020-04-07 21:44:46 +02:00
|
|
|
|
2020-08-01 21:51:54 +02:00
|
|
|
init() {
|
2020-08-05 11:24:59 +02:00
|
|
|
this.switch('wave');
|
2020-08-01 21:51:54 +02:00
|
|
|
this.updateLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(visual) {
|
|
|
|
if (this.visuals[visual] != null) {
|
|
|
|
this.c = visual;
|
2020-08-05 11:24:59 +02:00
|
|
|
vConf.loadConfigByName(this.c);
|
2020-08-01 21:51:54 +02:00
|
|
|
this.visuals[this.c].setup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLoop() {
|
|
|
|
let self = this;
|
|
|
|
let pro = shaderHandler.use(self.c);
|
|
|
|
let vis = self.visuals[self.c];
|
|
|
|
vis.updateData();
|
2020-08-05 11:24:59 +02:00
|
|
|
this.prepare();
|
2020-08-01 21:51:54 +02:00
|
|
|
vis.draw(pro);
|
|
|
|
requestAnimationFrame(self.updateLoop.bind(self))
|
|
|
|
}
|
2020-08-05 11:24:59 +02:00
|
|
|
|
|
|
|
prepare() {
|
|
|
|
c.width = window.innerWidth;
|
|
|
|
c.height = window.innerHeight;
|
|
|
|
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
|
|
|
gl.clearColor(0, 0, 0, parseFloat(pConf.get("alphaValue", 0)));
|
|
|
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
|
|
gl.enable(gl.DEPTH_TEST);
|
|
|
|
gl.depthFunc(gl.LEQUAL);
|
|
|
|
gl.enable(gl.CULL_FACE);
|
|
|
|
}
|
2020-04-07 21:44:46 +02:00
|
|
|
}
|