You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
456 B

import {state, init, pickPosition} from './shared-picking.js';
function size(data) {
state.width = data.width;
state.height = data.height;
}
function mouse(data) {
pickPosition.x = data.x;
pickPosition.y = data.y;
}
const handlers = {
init,
mouse,
size,
};
self.onmessage = function(e) {
const fn = handlers[e.data.type];
if (typeof fn !== 'function') {
throw new Error('no handler for type: ' + e.data.type);
}
fn(e.data);
};