2015-05-27 12:25:51 +02:00
|
|
|
importScripts("../library/three.js");
|
|
|
|
importScripts("../library/clipper.js");
|
|
|
|
importScripts("../src/utils.js");
|
|
|
|
importScripts("../src/printer.js");
|
|
|
|
importScripts("../src/paths.js");
|
|
|
|
importScripts("../src/slicer.js");
|
2015-06-05 09:56:58 +02:00
|
|
|
importScripts("../src/gcode.js");
|
2015-05-27 12:25:51 +02:00
|
|
|
|
|
|
|
var printer = new D3D.Printer();
|
|
|
|
var slicer = new D3D.Slicer();
|
2015-05-29 13:51:18 +02:00
|
|
|
slicer.onProgress = function (progress) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
self.postMessage({
|
|
|
|
"cmd": "PROGRESS",
|
|
|
|
"progress": progress
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
2015-05-27 12:25:51 +02:00
|
|
|
|
2015-05-29 10:41:44 +02:00
|
|
|
self.addEventListener("message", function (event) {
|
2015-05-27 12:25:51 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
switch (event.data["cmd"]) {
|
|
|
|
case "SET_MESH":
|
2015-06-01 12:06:11 +02:00
|
|
|
|
|
|
|
//hack...
|
|
|
|
//because boundings loses functions when converting
|
|
|
|
event.data["geometry"].boundingBox = event.data["geometry"].boundingSphere = null;
|
|
|
|
|
2015-05-29 10:41:44 +02:00
|
|
|
var geometry = new THREE.Geometry().fromBufferGeometry(event.data["geometry"]);
|
2015-05-27 12:25:51 +02:00
|
|
|
var matrix = new THREE.Matrix4().fromArray(event.data["matrix"]);
|
|
|
|
|
|
|
|
slicer.setMesh(geometry, matrix);
|
2015-05-29 10:41:44 +02:00
|
|
|
|
2015-05-27 12:25:51 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "SET_SETTINGS":
|
|
|
|
printer.updateConfig(event.data["USER_SETTINGS"]);
|
|
|
|
printer.updateConfig(event.data["PRINTER_SETTINGS"]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "SLICE":
|
2015-06-09 11:08:06 +02:00
|
|
|
var gcode = slicer.getGCode(printer);
|
2015-05-27 12:25:51 +02:00
|
|
|
|
2015-05-29 13:51:18 +02:00
|
|
|
self.postMessage({
|
|
|
|
"cmd": "GCODE",
|
|
|
|
"gcode": gcode
|
|
|
|
});
|
2015-05-27 12:25:51 +02:00
|
|
|
break;
|
|
|
|
|
2015-05-29 10:41:44 +02:00
|
|
|
case "CLOSE":
|
2015-05-27 12:25:51 +02:00
|
|
|
self.close();
|
|
|
|
break;
|
2015-05-29 10:41:44 +02:00
|
|
|
|
2015-05-27 12:25:51 +02:00
|
|
|
}
|
|
|
|
});
|