Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
peteruithoven 2017-07-19 21:40:19 +02:00
commit 580b41413f
4 changed files with 9 additions and 13 deletions

View File

@ -17,9 +17,8 @@ const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
const slicer = new SLICER.Slicer();
slicer.setGeometry(geometry);
const gcode = await slicer.slice(settings)
.progress(({ progress: { done, total, action } }) => {
const gcode = await slicer.slice(settings, ({ progress: { done, total, action } }) => {
const percentage = `${(done / total * 100).toFixed()}%`
console.log(action, percentage);
});
}));
```

View File

@ -151,7 +151,6 @@ SystemJS.config({
],
map: {
"three": "npm:three@0.83.0",
"progress-promise": "npm:progress-promise@0.0.6",
"text": "github:systemjs/plugin-text@0.0.11",
"js-yaml": "npm:js-yaml@3.9.0",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",

View File

@ -10,7 +10,6 @@
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"js-yaml": "npm:js-yaml@^3.9.0",
"json": "github:systemjs/plugin-json@^0.1.2",
"progress-promise": "npm:progress-promise@^0.0.6",
"text": "github:systemjs/plugin-text@^0.0.11",
"three": "npm:three@0.83.0",
"worker": "github:casperlamboo/plugin-worker@master"

View File

@ -1,7 +1,6 @@
import * as THREE from 'three';
import slice from './sliceActions/slice.js';
import SlicerWorker from './slicerWorker.js!worker';
import ProgressPromise from 'progress-promise';
export default class {
setMesh(mesh) {
@ -26,15 +25,15 @@ export default class {
return this;
}
sliceSync(settings, onprogress) {
return slice(this.geometry, settings, onprogress);
sliceSync(settings, onProgress) {
return slice(this.geometry, settings, onProgress);
}
slice(settings) {
slice(settings, onProgress) {
if (!this.geometry) {
throw new Error('Geometry is not set, use Slicer.setGeometry or Slicer.setMesh first');
}
return new ProgressPromise((resolve, reject, progress) => {
return new Promise((resolve, reject) => {
// create the slicer worker
const slicerWorker = new SlicerWorker();
slicerWorker.onerror = reject;
@ -49,7 +48,7 @@ export default class {
break;
}
case 'PROGRESS': {
progress(data);
onProgress(data);
break;
}
}