From 16158a3e3c0d7a49e4f1d9dbeb00b3108ae92f19 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Sun, 12 Nov 2017 12:34:50 +0100 Subject: [PATCH] add slice logging --- src/interface/index.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/interface/index.js b/src/interface/index.js index 6d2f90d..ccb3d77 100644 --- a/src/interface/index.js +++ b/src/interface/index.js @@ -25,6 +25,18 @@ const styles = { position: 'absolute', top: 0, right: 0 + }, + overlay: { + position: 'absolute', + backgroundColor: 'rgba(0, 0, 0, 0.5)', + color: 'white', + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + sliceActions: { + listStyleType: 'none' } }; @@ -50,6 +62,7 @@ class Interface extends React.Component { }; state = { controlMode: 'translate', + isSlicing: false, sliced: false }; @@ -106,11 +119,18 @@ class Interface extends React.Component { const geometry = mesh.geometry.clone(); mesh.updateMatrix(); + this.setState({ isSlicing: true, progress: { actions: [], percentage: 0 } }); + const matrix = new THREE.Matrix4().makeTranslation(centerY, 0, centerX).multiply(mesh.matrix); - const gcode = await sliceGeometry(settings, geometry, matrix, false, true, (process) => { - console.log('process: ', process); + const gcode = await sliceGeometry(settings, geometry, matrix, false, true, ({ progress }) => { + this.setState({ progress: { + actions: [...this.state.progress.actions, progress.action], + percentage: progress.done / progress.total + } }); }); + this.setState({ isSlicing: false }); + // TODO // can't disable control ui still interacts with mouse input control.visible = false; @@ -142,7 +162,7 @@ class Interface extends React.Component { render() { const { width, height, classes, onCompleteActions } = this.props; - const { sliced, gcode } = this.state; + const { sliced, isSlicing, progress, gcode } = this.state; return (
@@ -172,6 +192,12 @@ class Interface extends React.Component { ))}
} + {isSlicing &&
+

Slicing: {progress.percentage.toLocaleString(navigator.language, { style: 'percent' })}

+ +
} ); }