1
0

offscreencanvas-worker-cubes.js 364 B

1234567891011121314151617181920212223242526
  1. import { init, state } from './shared-cubes.js';
  2. function size( data ) {
  3. state.width = data.width;
  4. state.height = data.height;
  5. }
  6. const handlers = {
  7. init,
  8. size,
  9. };
  10. self.onmessage = function ( e ) {
  11. const fn = handlers[ e.data.type ];
  12. if ( typeof fn !== 'function' ) {
  13. throw new Error( 'no handler for type: ' + e.data.type );
  14. }
  15. fn( e.data );
  16. };