Doodle3D-Slicer/src/slicer.worker.js

31 lines
680 B
JavaScript
Raw Normal View History

2017-09-07 12:55:56 +02:00
import 'core-js'; // polyfills
2016-10-13 14:22:04 +02:00
import slice from './sliceActions/slice.js';
2017-07-18 12:38:03 +02:00
import * as THREE from 'three';
2016-08-19 14:46:02 +02:00
const loader = new THREE.JSONLoader();
2017-07-18 12:26:30 +02:00
const onProgress = progress => {
self.postMessage({
message: 'PROGRESS',
data: progress
2017-07-18 12:26:30 +02:00
});
}
2016-08-19 14:46:02 +02:00
self.addEventListener('message', (event) => {
const { message, data } = event.data;
switch (message) {
case 'SLICE': {
const { settings, geometry: JSONGeometry } = data;
2017-07-19 11:50:23 +02:00
const { geometry } = loader.parse(JSONGeometry.data);
2016-08-19 14:46:02 +02:00
const gcode = slice(settings, geometry, onProgress);
2016-08-19 14:46:02 +02:00
self.postMessage({
message: 'SLICE',
data: { gcode }
});
break;
}
}
}, false);