From 5f1e628952fc4e599c11c249d2107063639bfebb Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Tue, 5 Dec 2017 13:03:00 +0100 Subject: [PATCH] add 'name' to slice function and fix gcode object/string --- index.js | 2 +- src/interface/Settings.js | 2 +- src/interface/index.js | 12 +++++++----- src/interface/utils.js | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 662467c..1799116 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ const jsonLoader = new THREE.JSONLoader(); jsonLoader.load(fileURL, geometry => { render(( - + ), document.getElementById('app')); }); diff --git a/src/interface/Settings.js b/src/interface/Settings.js index 86647c4..40022a3 100644 --- a/src/interface/Settings.js +++ b/src/interface/Settings.js @@ -30,7 +30,7 @@ class Settings extends React.Component { classes: PropTypes.objectOf(PropTypes.string), onChange: PropTypes.func, printers: PropTypes.object.isRequired, - defaultPrinter: PropTypes.string.isRequired, + defaultPrinter: PropTypes.string, quality: PropTypes.object.isRequired, defaultQuality: PropTypes.string.isRequired, material: PropTypes.object.isRequired, diff --git a/src/interface/index.js b/src/interface/index.js index b2dae05..ec9e9e1 100644 --- a/src/interface/index.js +++ b/src/interface/index.js @@ -85,24 +85,25 @@ class Interface extends React.Component { classes: PropTypes.objectOf(PropTypes.string), defaultSettings: PropTypes.object.isRequired, printers: PropTypes.object.isRequired, - defaultPrinter: PropTypes.string.isRequired, + defaultPrinter: PropTypes.string, quality: PropTypes.object.isRequired, defaultQuality: PropTypes.string.isRequired, material: PropTypes.object.isRequired, defaultMaterial: PropTypes.string.isRequired, pixelRatio: PropTypes.number.isRequired, - onCancel: PropTypes.func + onCancel: PropTypes.func, + name: PropTypes.string.isRequired }; static defaultProps = { defaultSettings: baseSettings, printers: printerSettings, - defaultPrinter: 'ultimaker2', quality: qualitySettings, defaultQuality: 'medium', material: materialSettings, defaultMaterial: 'pla', - pixelRatio: 1 + pixelRatio: 1, + name: 'Doodle3D' }; constructor(props) { @@ -177,13 +178,14 @@ class Interface extends React.Component { slice = async () => { const { mesh, settings, isSlicing, printers, quality, material } = this.state; + const { name } = this.props; if (isSlicing) return; this.setState({ isSlicing: true, progress: { action: '', slicing: 0, uploading: 0 }, error: null }); try { - await slice(mesh, settings, printers, quality, material, progress => { + await slice(name, mesh, settings, printers, quality, material, progress => { this.setState({ progress: { ...this.state.progress, ...progress } }); }); } catch (error) { diff --git a/src/interface/utils.js b/src/interface/utils.js index 2247d80..d38eb2c 100644 --- a/src/interface/utils.js +++ b/src/interface/utils.js @@ -105,7 +105,7 @@ export function fetchProgress(url, { method = 'get', headers = {}, body = {} } = const GCODE_SERVER_URL = 'https://gcodeserver.doodle3d.com'; const CONNECT_URL = 'http://connect.doodle3d.com/'; -export async function slice(mesh, settings, printers, quality, material, updateProgress) { +export async function slice(name, mesh, settings, printers, quality, material, updateProgress) { const { dimensions } = settings; const centerX = dimensions.x / 2; const centerY = dimensions.y / 2; @@ -114,7 +114,7 @@ export async function slice(mesh, settings, printers, quality, material, updateP mesh.updateMatrix(); const matrix = new THREE.Matrix4().makeTranslation(centerY, 0, centerX).multiply(mesh.matrix); - const gcode = await sliceGeometry(settings, geometry, matrix, false, false, ({ progress }) => { + const { gcode } = await sliceGeometry(settings, geometry, matrix, false, false, ({ progress }) => { updateProgress({ action: progress.action, slicing: progress.done / progress.total