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 => {
render((
<MuiThemeProvider>
<Interface geometry={geometry}/>
<Interface geometry={geometry} name="Doodle3D"/>
</MuiThemeProvider>
), document.getElementById('app'));
});

View File

@ -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,

View File

@ -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) {

View File

@ -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