offscreencanvas-worker-cubes.js 433 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. /* global importScripts, init, state */
  3. importScripts('resources/threejs/r115/build/three.min.js');
  4. importScripts('shared-cubes.js');
  5. function size(data) {
  6. state.width = data.width;
  7. state.height = data.height;
  8. }
  9. const handlers = {
  10. init,
  11. size,
  12. };
  13. self.onmessage = function(e) {
  14. const fn = handlers[e.data.type];
  15. if (!fn) {
  16. throw new Error('no handler for type: ' + e.data.type);
  17. }
  18. fn(e.data);
  19. };