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.
earthquake_3d_viewer_front/three/manual/examples/offscreencanvas-worker-pick...

35 lines
470 B
JavaScript

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 );
};