You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
364 B
JavaScript
27 lines
364 B
JavaScript
2 months ago
|
import { init, state } from './shared-cubes.js';
|
||
|
|
||
|
function size( data ) {
|
||
|
|
||
|
state.width = data.width;
|
||
|
state.height = data.height;
|
||
|
|
||
|
}
|
||
|
|
||
|
const handlers = {
|
||
|
init,
|
||
|
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 );
|
||
|
|
||
|
};
|