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',
|
2017-07-20 10:29:33 +02:00
|
|
|
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': {
|
2017-07-20 10:29:33 +02:00
|
|
|
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
|
|
|
|
2017-07-20 10:29:33 +02:00
|
|
|
const gcode = slice(settings, geometry, onProgress);
|
2016-08-19 14:46:02 +02:00
|
|
|
|
|
|
|
self.postMessage({
|
|
|
|
message: 'SLICE',
|
|
|
|
data: { gcode }
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, false);
|