summaryrefslogtreecommitdiff
path: root/webhogg/wasm/pkg/worker.js
blob: 780ea6f3fe70f4c72689d71699fd793f31c4227f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let data = null;

onmessage = function (e) {
    data = e.data;

    importScripts('../bin/webhogg-wasm.js');
    wasm_bindgen(data.source).then(ctx => {
        if (data.type === 'graphics') {
            wasm_bindgen.start_graphics(data.canvas);
            setInterval(wasm_bindgen.loop_graphics, data.dt);
        } else if (data.type === 'logic') {
            wasm_bindgen.start_logic();
            setInterval(wasm_bindgen.loop_logic, data.dt);
        }

    });
}