audio-vis/raw/javascript/app.js
2020-08-08 21:58:15 +02:00

63 lines
1.7 KiB
JavaScript

const shaderHandler = new ShaderHandler(null),
audioHandler = new AudioHandler(),
gui = new GUI(),
visual = new VisualDrawer(),
template = new Template(),
player = new Player(),
vConf = new Config("visual"),
pConf = new Config("player"),
worker = new Worker('/out/js/worker.min.js'),
startup = new Startup(),
eventHandler = new EventHandler(),
playerConf = new PlayerConfigHandler(),
keyHandler = new KeyHandler(),
version = 1,
camera = new Camera();
let c, gl, cInfo, ctx, sw;
worker.addEventListener('message', e => {
if (e.data.status === 'startup') {
startup.moduleLoaded(e.data.cmd);
return;
}
eventHandler.handleEvent(e);
});
window.addEventListener('startupFin', e => {
setTimeout(e => {
$('.loading-screen').remove();
}, 100)
})
async function startUP() {
if ('serviceWorker' in navigator) {
sw = await navigator.serviceWorker.register('/sw.js');
}
pConf.loadConfigByName('default');
c = $('#c'),
gl = c.getContext("webgl2"),
cInfo = $('#cInfo'),
ctx = cInfo.getContext('2d');
if (!gl) {
alert("SORRY THE BROWSER DOESN'T SUPPORT WEBGL2");
return false;
}
shaderHandler.setGL(gl)
await shaderHandler.loadArray(["wave", "sphere", "water", "wave2d"], '/shaders/');
await NotificationHandler.instance.init();
await audioHandler.init();
await player.init();
await camera.init();
await visual.init();
await gui.init();
await imageUploader.init();
await playerConf.init();
await keyHandler.init();
await initHandler();
toggleShuffle(false);
}
startUP().then(r => {
startup.moduleLoaded('startup');
});