add 'name' to slice function and fix gcode object/string

This commit is contained in:
Rick Companje 2017-12-05 13:03:00 +01:00
parent a1b4a9c454
commit 5f1e628952
4 changed files with 11 additions and 9 deletions

View File

@ -24,7 +24,7 @@ const jsonLoader = new THREE.JSONLoader();
jsonLoader.load(fileURL, geometry => { jsonLoader.load(fileURL, geometry => {
render(( render((
<MuiThemeProvider> <MuiThemeProvider>
<Interface geometry={geometry}/> <Interface geometry={geometry} name="Doodle3D"/>
</MuiThemeProvider> </MuiThemeProvider>
), document.getElementById('app')); ), document.getElementById('app'));
}); });

View File

@ -30,7 +30,7 @@ class Settings extends React.Component {
classes: PropTypes.objectOf(PropTypes.string), classes: PropTypes.objectOf(PropTypes.string),
onChange: PropTypes.func, onChange: PropTypes.func,
printers: PropTypes.object.isRequired, printers: PropTypes.object.isRequired,
defaultPrinter: PropTypes.string.isRequired, defaultPrinter: PropTypes.string,
quality: PropTypes.object.isRequired, quality: PropTypes.object.isRequired,
defaultQuality: PropTypes.string.isRequired, defaultQuality: PropTypes.string.isRequired,
material: PropTypes.object.isRequired, material: PropTypes.object.isRequired,

View File

@ -85,24 +85,25 @@ class Interface extends React.Component {
classes: PropTypes.objectOf(PropTypes.string), classes: PropTypes.objectOf(PropTypes.string),
defaultSettings: PropTypes.object.isRequired, defaultSettings: PropTypes.object.isRequired,
printers: PropTypes.object.isRequired, printers: PropTypes.object.isRequired,
defaultPrinter: PropTypes.string.isRequired, defaultPrinter: PropTypes.string,
quality: PropTypes.object.isRequired, quality: PropTypes.object.isRequired,
defaultQuality: PropTypes.string.isRequired, defaultQuality: PropTypes.string.isRequired,
material: PropTypes.object.isRequired, material: PropTypes.object.isRequired,
defaultMaterial: PropTypes.string.isRequired, defaultMaterial: PropTypes.string.isRequired,
pixelRatio: PropTypes.number.isRequired, pixelRatio: PropTypes.number.isRequired,
onCancel: PropTypes.func onCancel: PropTypes.func,
name: PropTypes.string.isRequired
}; };
static defaultProps = { static defaultProps = {
defaultSettings: baseSettings, defaultSettings: baseSettings,
printers: printerSettings, printers: printerSettings,
defaultPrinter: 'ultimaker2',
quality: qualitySettings, quality: qualitySettings,
defaultQuality: 'medium', defaultQuality: 'medium',
material: materialSettings, material: materialSettings,
defaultMaterial: 'pla', defaultMaterial: 'pla',
pixelRatio: 1 pixelRatio: 1,
name: 'Doodle3D'
}; };
constructor(props) { constructor(props) {
@ -177,13 +178,14 @@ class Interface extends React.Component {
slice = async () => { slice = async () => {
const { mesh, settings, isSlicing, printers, quality, material } = this.state; const { mesh, settings, isSlicing, printers, quality, material } = this.state;
const { name } = this.props;
if (isSlicing) return; if (isSlicing) return;
this.setState({ isSlicing: true, progress: { action: '', slicing: 0, uploading: 0 }, error: null }); this.setState({ isSlicing: true, progress: { action: '', slicing: 0, uploading: 0 }, error: null });
try { 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 } }); this.setState({ progress: { ...this.state.progress, ...progress } });
}); });
} catch (error) { } catch (error) {

View File

@ -105,7 +105,7 @@ export function fetchProgress(url, { method = 'get', headers = {}, body = {} } =
const GCODE_SERVER_URL = 'https://gcodeserver.doodle3d.com'; const GCODE_SERVER_URL = 'https://gcodeserver.doodle3d.com';
const CONNECT_URL = 'http://connect.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 { dimensions } = settings;
const centerX = dimensions.x / 2; const centerX = dimensions.x / 2;
const centerY = dimensions.y / 2; const centerY = dimensions.y / 2;
@ -114,7 +114,7 @@ export async function slice(mesh, settings, printers, quality, material, updateP
mesh.updateMatrix(); mesh.updateMatrix();
const matrix = new THREE.Matrix4().makeTranslation(centerY, 0, centerX).multiply(mesh.matrix); 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({ updateProgress({
action: progress.action, action: progress.action,
slicing: progress.done / progress.total slicing: progress.done / progress.total