mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2025-04-06 20:03:21 +02:00
30 lines
649 B
JavaScript
30 lines
649 B
JavaScript
import slice from './sliceActions/slice.js';
|
|
import * as THREE from 'three';
|
|
|
|
const loader = new THREE.JSONLoader();
|
|
|
|
const onProgress = progress => {
|
|
self.postMessage({
|
|
message: 'PROGRESS',
|
|
data: progress
|
|
});
|
|
}
|
|
|
|
self.addEventListener('message', (event) => {
|
|
const { message, data } = event.data;
|
|
switch (message) {
|
|
case 'SLICE': {
|
|
const { settings, geometry: JSONGeometry } = data;
|
|
const { geometry } = loader.parse(JSONGeometry.data);
|
|
|
|
const gcode = slice(settings, geometry, onProgress);
|
|
|
|
self.postMessage({
|
|
message: 'SLICE',
|
|
data: { gcode }
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
}, false);
|