diff --git a/src/interface/index.js b/src/interface/index.js index b4a59f3..f278ca0 100644 --- a/src/interface/index.js +++ b/src/interface/index.js @@ -68,7 +68,19 @@ class Interface extends React.Component { placeOnGround(mesh); render(); } - } + }; + + reset = () => { + const { control, mesh, render, gcode, scene } = this.state; + control.visible = true; + mesh.visible = true; + + scene.remove(gcode.linePreview); + gcode.linePreview.geometry.dispose(); + + this.setState({ sliced: false, gcode: null }); + render(); + }; slice = async () => { const { mesh, render, scene, control } = this.state; @@ -86,20 +98,21 @@ class Interface extends React.Component { mesh.updateMatrix(); const matrix = new THREE.Matrix4().makeTranslation(centerY, 0, centerX).multiply(mesh.matrix); - const { gcode, linePreview } = await sliceGeometry(settings, geometry, matrix, true, true, (process) => { + const gcode = await sliceGeometry(settings, geometry, matrix, true, true, (process) => { console.log('process: ', process); }); - // can't disable control so remove it - control.dispose(); - scene.remove(control, mesh); + // TODO + // can't disable control + control.visible = false; + mesh.visible = false; - linePreview.position.x = -centerY; - linePreview.position.z = -centerX; - scene.add(linePreview); + gcode.linePreview.position.x = -centerY; + gcode.linePreview.position.z = -centerX; + scene.add(gcode.linePreview); + this.setState({ sliced: true, gcode }); render(); - this.setState({ sliced: true }); }; componentWillUnmount() { @@ -127,6 +140,10 @@ class Interface extends React.Component { {!sliced &&