audio-vis/raw/javascript/visual.js
versustunez 9d5259767c - added imageUploader
- fixed loading songs
- cleanup utils
- added some helper class
- cleanup preparing of WEBGL2
- added 3D wave
- added light-support
- added configs
- added gui-events for playing, shuffling and playlist
2020-08-05 11:24:59 +02:00

60 lines
1.3 KiB
JavaScript

class Visual {
constructor() {
this.data = []; //for drawing
this.dataArray = [];
}
updateData() {
}
draw() {
}
setup() {
}
}
class VisualDrawer {
constructor() {
this.visuals = {
"sphere": new Sphere(),
"wave": new Wave(),
"water": new Water()
}
}
init() {
this.switch('wave');
this.updateLoop();
}
switch(visual) {
if (this.visuals[visual] != null) {
this.c = visual;
vConf.loadConfigByName(this.c);
this.visuals[this.c].setup();
}
}
updateLoop() {
let self = this;
let pro = shaderHandler.use(self.c);
let vis = self.visuals[self.c];
vis.updateData();
this.prepare();
vis.draw(pro);
requestAnimationFrame(self.updateLoop.bind(self))
}
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);
}
}