mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
comply with linter
This commit is contained in:
parent
5a40c7c647
commit
0be1ee6d51
1427
package-lock.json
generated
1427
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -42,7 +42,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "6.24.1",
|
||||
"babel-eslint": "^8.2.3",
|
||||
"babel-eslint": "^5.0.4",
|
||||
"babel-loader": "7.0.0",
|
||||
"babel-plugin-transform-es2015-classes": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
@ -53,11 +53,9 @@
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-preset-stage-0": "^6.24.1",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-airbnb": "^16.1.0",
|
||||
"eslint-plugin-import": "^2.11.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.3",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"eslint": "^1.10.3",
|
||||
"eslint-config-airbnb": "^3.1.0",
|
||||
"eslint-plugin-react": "^3.16.1",
|
||||
"file-loader": "^1.1.11",
|
||||
"html-webpack-plugin": "^2.29.0",
|
||||
"html-webpack-template": "^6.0.2",
|
||||
|
@ -1,8 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'proptypes';
|
||||
import _ from 'lodash';
|
||||
import injectSheet from 'react-jss';
|
||||
import MaterialUISelectField from 'material-ui/SelectField'
|
||||
import MaterialUISelectField from 'material-ui/SelectField';
|
||||
import MaterialUICheckbox from 'material-ui/Checkbox';
|
||||
import TextFieldIcon from 'material-ui-textfield-icon';
|
||||
import RefreshIcon from 'material-ui-icons/Refresh';
|
||||
@ -59,8 +58,8 @@ const _NumberField = ({ name, min, max, muiTheme: { palette }, ...props }, conte
|
||||
type="number"
|
||||
icon={context.advancedFields.includes(name) && <RefreshIcon
|
||||
style={{ fill: palette.textColor }}
|
||||
onTouchTap={() => context.onChange(name, null)} />
|
||||
}
|
||||
onTouchTap={() => context.onChange(name, null)}
|
||||
/>}
|
||||
floatingLabelStyle={{
|
||||
color: context.advancedFields.includes(name) ? palette.primary1Color : palette.primary3Color
|
||||
}}
|
||||
|
@ -1,61 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'proptypes';
|
||||
import muiThemeable from 'material-ui/styles/muiThemeable';
|
||||
import injectSheet from 'react-jss';
|
||||
import FlatButton from 'material-ui/FlatButton';
|
||||
import { sleep, getMalyanStatus } from './utils.js';
|
||||
|
||||
const styles = {
|
||||
|
||||
};
|
||||
|
||||
class MalyanControl extends React.Component {
|
||||
static propTypes = {
|
||||
ip: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
state = {
|
||||
status: null,
|
||||
mounted: true
|
||||
};
|
||||
|
||||
// componentDidMount = async () => {
|
||||
// const { ip } = this.props;
|
||||
// while (this.state.mounted) {
|
||||
// const status = await getMalyanStatus(ip).catch(() => null);
|
||||
// this.setState({ status });
|
||||
// await sleep(1000);
|
||||
// }
|
||||
// };
|
||||
|
||||
home = () => {
|
||||
const { ip } = this.props;
|
||||
fetch(`http://${ip}/set?code=G28`, { method: 'GET', mode: 'no-cors' });
|
||||
};
|
||||
|
||||
stop = () => {
|
||||
const { ip } = this.props;
|
||||
fetch(`http://${ip}/set?cmd={P:X}`, { method: 'GET', mode: 'no-cors' });
|
||||
};
|
||||
|
||||
componentWillUnmount() {
|
||||
this.setState({ mounted: false });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { status } = this.state;
|
||||
return (
|
||||
<div>
|
||||
{status && <span>
|
||||
<p>Nozzle temperature: {status.nozzleTemperature}/{status.nozzleTargetTemperature}</p>
|
||||
<p>Bed temperature: {status.bedTemperature}/{status.bedTargetTemperature}</p>
|
||||
{status.state === 'printing' && <p>Progress: {status.progress}%</p>}
|
||||
</span>}
|
||||
<FlatButton label="Stop" onTouchTap={this.stop} />
|
||||
<FlatButton label="Home" onTouchTap={this.home} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default muiThemeable()(injectSheet(styles)(MalyanControl));
|
@ -45,13 +45,16 @@ const styles = {
|
||||
'& h3': {
|
||||
fontWeight: 'bold',
|
||||
marginTop: '20px',
|
||||
marginBottom: '20px',
|
||||
marginBottom: '20px'
|
||||
}
|
||||
},
|
||||
error: {
|
||||
color: red500
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
const updateLocalStorage = (localStorage) => {
|
||||
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(localStorage));
|
||||
};
|
||||
|
||||
const getLocalStorage = () => {
|
||||
@ -66,10 +69,6 @@ const getLocalStorage = () => {
|
||||
return localStorage;
|
||||
};
|
||||
|
||||
const updateLocalStorage = (localStorage) => {
|
||||
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(localStorage));
|
||||
};
|
||||
|
||||
class Settings extends React.Component {
|
||||
static propTypes = {
|
||||
selectedPrinter: PropTypes.string,
|
||||
@ -110,9 +109,8 @@ class Settings extends React.Component {
|
||||
const { localStorage } = this.state;
|
||||
|
||||
if (selectedPrinter && localStorage.active) {
|
||||
const activePrinter = selectedPrinter && Object.entries(localStorage.printers)
|
||||
.map(([key, value]) => ({ key, value }))
|
||||
.find(({ key, value: { ip } }) => ip === selectedPrinter);
|
||||
const activePrinter = selectedPrinter && Object.values(localStorage.printers)
|
||||
.find(({ ip }) => ip === selectedPrinter);
|
||||
|
||||
if (activePrinter) {
|
||||
const state = this.changeSettings('activePrinter', activePrinter.key);
|
||||
@ -212,7 +210,6 @@ class Settings extends React.Component {
|
||||
case 'settings.support.density':
|
||||
case 'settings.support.minArea':
|
||||
case 'settings.support.margin':
|
||||
case 'settings.support.speed':
|
||||
case 'settings.support.flowRate':
|
||||
if (!localStorage.active) return this.openAddPrinterDialog();
|
||||
|
||||
@ -307,14 +304,22 @@ class Settings extends React.Component {
|
||||
};
|
||||
|
||||
editPrinter = () => {
|
||||
const { localStorage: { active, printers }, managePrinter: { printer, name, ip } } = this.state;
|
||||
const { localStorage: { active }, managePrinter: { printer, name, ip } } = this.state;
|
||||
|
||||
if (!name) {
|
||||
this.setState(update(this.state, { managePrinter: { error: { $set: 'Please enter a name' } } }));
|
||||
this.setState(update(this.state, {
|
||||
managePrinter: {
|
||||
error: { $set: 'Please enter a name' }
|
||||
}
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (printer === 'doodle3d_printer' && !validateIp(ip)) {
|
||||
this.setState(update(this.state, { managePrinter: { error: { $set: 'Please enter a valid IP adress' } } }));
|
||||
this.setState(update(this.state, {
|
||||
managePrinter: {
|
||||
error: { $set: 'Please enter a valid IP adress' }
|
||||
}
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -384,8 +389,8 @@ class Settings extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { addPrinter, managePrinter, localStorage, wifiBoxes } = this.state;
|
||||
const { classes, disabled } = this.props;
|
||||
const { addPrinter, managePrinter, localStorage } = this.state;
|
||||
const { classes } = this.props;
|
||||
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
@ -540,5 +545,8 @@ function printDialog(props, state, title, form, submitText, data, closeDialog, r
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
printDialog.propTypes = {
|
||||
classes: PropTypes.objectOf(PropTypes.string)
|
||||
};
|
||||
|
||||
export default injectSheet(styles)(Settings);
|
||||
|
@ -1,59 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'proptypes';
|
||||
import muiThemeable from 'material-ui/styles/muiThemeable';
|
||||
import injectSheet from 'react-jss';
|
||||
import FlatButton from 'material-ui/FlatButton';
|
||||
import { Doodle3DBox } from 'doodle3d-api';
|
||||
|
||||
const styles = {
|
||||
|
||||
};
|
||||
|
||||
class WifiBoxControl extends React.Component {
|
||||
static propTypes = {
|
||||
ip: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
state = {
|
||||
box: null,
|
||||
status: null
|
||||
};
|
||||
|
||||
componentDidMount = async () => {
|
||||
const { ip } = this.props;
|
||||
|
||||
const box = new Doodle3DBox(ip);
|
||||
window.d3dbox = box;
|
||||
box.addEventListener('update', ({ state }) => this.setState({ status: state }));
|
||||
box.setAutoUpdate(true, 5000);
|
||||
|
||||
this.setState({ box });
|
||||
|
||||
const alive = await box.checkAlive();
|
||||
};
|
||||
|
||||
stop = async () => {
|
||||
const { box } = this.state;
|
||||
const result = await box.printer.stop();
|
||||
console.log('result: ', result);
|
||||
};
|
||||
|
||||
componentWillUnmount() {
|
||||
const { box } = this.state;
|
||||
if (box) box.setAutoUpdate(false);
|
||||
|
||||
this.setState({ mounted: false });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { status } = this.state;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FlatButton label="Stop" onTouchTap={this.stop} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default muiThemeable()(injectSheet(styles)(WifiBoxControl));
|
@ -1,12 +1,9 @@
|
||||
import * as THREE from 'three';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import PropTypes from 'proptypes';
|
||||
import { centerGeometry, placeOnGround, createScene, slice, TabTemplate } from './utils.js';
|
||||
import injectSheet from 'react-jss';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
import FlatButton from 'material-ui/FlatButton';
|
||||
import Slider from 'material-ui/Slider';
|
||||
import LinearProgress from 'material-ui/LinearProgress';
|
||||
import { grey50, grey300, grey800, red500 } from 'material-ui/styles/colors';
|
||||
import Popover from 'material-ui/Popover/Popover';
|
||||
@ -14,14 +11,11 @@ import Menu from 'material-ui/Menu';
|
||||
import MenuItem from 'material-ui/MenuItem';
|
||||
import { Tabs, Tab } from 'material-ui/Tabs';
|
||||
import Settings from './Settings.js';
|
||||
// import MalyanControl from './MalyanControl.js';
|
||||
// import WifiBoxControl from './WifiBoxControl.js';
|
||||
import ReactResizeDetector from 'react-resize-detector';
|
||||
import JSONToSketchData from 'doodle3d-core/shape/JSONToSketchData';
|
||||
import createSceneData from 'doodle3d-core/d3/createSceneData.js';
|
||||
import { generateExportMesh } from 'doodle3d-core/utils/exportUtils.js';
|
||||
import muiThemeable from 'material-ui/styles/muiThemeable';
|
||||
import Dialog from 'material-ui/Dialog';
|
||||
import logo from '../../img/logo.png';
|
||||
|
||||
const MAX_FULLSCREEN_WIDTH = 720;
|
||||
@ -58,7 +52,7 @@ const styles = {
|
||||
borderLeft: `1px solid ${grey300}`
|
||||
},
|
||||
sliceActions: {
|
||||
flexShrink: 0,
|
||||
flexShrink: 0
|
||||
},
|
||||
sliceInfo: {
|
||||
margin: '10px 0',
|
||||
@ -232,7 +226,7 @@ class Interface extends React.Component {
|
||||
};
|
||||
|
||||
slice = async (action) => {
|
||||
const { isSlicing, settings, mesh, scene: { material, mesh: { matrix } } } = this.state;
|
||||
const { isSlicing, settings, mesh, scene: { mesh: { matrix } } } = this.state;
|
||||
const { name } = this.props;
|
||||
|
||||
if (isSlicing) return;
|
||||
@ -342,7 +336,7 @@ class Interface extends React.Component {
|
||||
|
||||
render() {
|
||||
const { classes, onCancel, selectedPrinter, actions } = this.props;
|
||||
const { isSlicing, progress, showFullScreen, error, objectDimensions, settings } = this.state;
|
||||
const { isSlicing, progress, showFullScreen, error, objectDimensions } = this.state;
|
||||
|
||||
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
||||
|
||||
@ -365,10 +359,6 @@ class Interface extends React.Component {
|
||||
className={`${classes.button}`}
|
||||
onTouchTap={onCancel}
|
||||
/>}
|
||||
{/* (settings && settings.ip) && ((settings.printer === 'doodle3d_printer') ?
|
||||
<MalyanControl ip={settings.ip} /> :
|
||||
<WifiBoxControl ip={settings.ip} />
|
||||
) */}
|
||||
{actions.length === 1 ? (
|
||||
<RaisedButton
|
||||
primary
|
||||
|
@ -4,7 +4,6 @@ import printerSettings from '../settings/printer.yml';
|
||||
import materialSettings from '../settings/material.yml';
|
||||
import qualitySettings from '../settings/quality.yml';
|
||||
import { sliceGeometry } from '../slicer.js';
|
||||
import { grey800, red500 } from 'material-ui/styles/colors';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import fileSaver from 'file-saver';
|
||||
@ -24,7 +23,7 @@ export function centerGeometry(mesh) {
|
||||
mesh.geometry.applyMatrix(new THREE.Matrix4().makeTranslation(-center.x, -center.y, -center.z));
|
||||
}
|
||||
|
||||
export function createScene({ pixelRatio, muiTheme }) {
|
||||
export function createScene({ muiTheme }) {
|
||||
const scene = new THREE.Scene();
|
||||
|
||||
const camera = new THREE.PerspectiveCamera(50, 1, 1, 10000);
|
||||
@ -52,7 +51,7 @@ export function createScene({ pixelRatio, muiTheme }) {
|
||||
let renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
|
||||
let editorControls = new THREE.EditorControls(camera, renderer.domElement);
|
||||
|
||||
box.scale.set(1., 1., 1.);
|
||||
box.scale.set(1, 1, 1);
|
||||
box.updateMatrix();
|
||||
|
||||
const render = () => renderer.render(scene, camera);
|
||||
@ -95,16 +94,16 @@ export function fetchProgress(url, data = {}, onProgress) {
|
||||
// const headers = new Headers(xhr.getAllResponseHeaders() || '');
|
||||
// const { status, statusText, response, responseText, responseURL: url = headers.get('X-Request-URL') } = xhr;
|
||||
// resolve(new Response(response || responseText, { headers, status, statusText, url }));
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => reject(new TypeError('Network request failed'));
|
||||
xhr.ontimeout = () => reject(new TypeError('Network request failed'));
|
||||
|
||||
xhr.open(request.method, url, true);
|
||||
|
||||
if (request.credentials === 'include') {
|
||||
xhr.withCredentials = true
|
||||
xhr.withCredentials = true;
|
||||
} else if (request.credentials === 'omit') {
|
||||
xhr.withCredentials = false
|
||||
xhr.withCredentials = false;
|
||||
}
|
||||
if (xhr.upload && onProgress) xhr.upload.onprogress = onProgress;
|
||||
if (xhr.responseType) xhr.responseType = 'blob';
|
||||
@ -134,7 +133,7 @@ export function getMalyanStatus(ip) {
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export function sleep(time) {
|
||||
@ -153,12 +152,11 @@ export async function slice(action, name, mesh, settings, updateProgress) {
|
||||
break;
|
||||
case 'WIFI_PRINT':
|
||||
if (settings.printer === 'doodle3d_printer') {
|
||||
const { state } = await getMalyanStatus(settings.ip);
|
||||
if (state !== 'idle') throw { message: 'printer is busy', code: 0 };
|
||||
|
||||
// const { state } = await getMalyanStatus(settings.ip);
|
||||
// if (state !== 'idle') throw { message: 'printer is busy', code: 0 };
|
||||
} else {
|
||||
wifiBox = new Doodle3DBox(settings.ip);
|
||||
if (!await wifiBox.checkAlive()) throw { message: `can't connect to printer`, code: 4 }
|
||||
if (! await wifiBox.checkAlive()) throw { message: `can't connect to printer`, code: 4 };
|
||||
|
||||
const { state } = await wifiBox.info.status();
|
||||
if (state !== 'idle') throw { message: 'printer is busy', code: 0 };
|
||||
@ -170,7 +168,6 @@ export async function slice(action, name, mesh, settings, updateProgress) {
|
||||
break;
|
||||
default:
|
||||
throw { message: 'unknown target', code: 1 };
|
||||
break;
|
||||
}
|
||||
|
||||
const { dimensions } = settings;
|
||||
@ -250,7 +247,7 @@ export async function slice(action, name, mesh, settings, updateProgress) {
|
||||
});
|
||||
currentStep ++;
|
||||
|
||||
const result = await wifiBox.printer.fetch(id);
|
||||
await wifiBox.printer.fetch(id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -270,7 +267,6 @@ export async function slice(action, name, mesh, settings, updateProgress) {
|
||||
|
||||
default:
|
||||
throw { message: 'unknown target', code: 1 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,5 +293,5 @@ export const TabTemplate = ({ children, selected, style }) => {
|
||||
TabTemplate.propTypes = {
|
||||
children: PropTypes.node,
|
||||
selected: PropTypes.bool,
|
||||
style: PropTypes.object,
|
||||
style: PropTypes.object
|
||||
};
|
||||
|
@ -20,8 +20,8 @@ export default function addBrim(slices, settings) {
|
||||
|
||||
const [firstLayer] = slices;
|
||||
|
||||
const brim = firstLayer.parts.reduce((brim, { shape }) => (
|
||||
brim.join(shape.offset(nozzleRadius, {
|
||||
const brim = firstLayer.parts.reduce((_brim, { shape }) => (
|
||||
_brim.join(shape.offset(nozzleRadius, {
|
||||
...OFFSET_OPTIONS,
|
||||
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
|
||||
}))
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { PRECISION } from '../constants.js';
|
||||
import { divide } from './helpers/vector2.js';
|
||||
import { PRECISION } from '../constants.js'
|
||||
|
||||
export default function applyPrecision(layers) {
|
||||
for (let layer = 0; layer < layers.length; layer ++) {
|
||||
|
@ -21,7 +21,8 @@ export default function calculateLayersIntersections(lines, settings) {
|
||||
if (layerIndex >= 0 && layerIndex < numLayers) {
|
||||
const y = layerIndex * layerHeight + Z_OFFSET;
|
||||
|
||||
let x, z;
|
||||
let x;
|
||||
let z;
|
||||
if (line.start.y === line.end.y) {
|
||||
x = line.start.x;
|
||||
z = line.start.z;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as vector2 from './helpers/vector2.js';
|
||||
import * as vector3 from './helpers/vector3.js';
|
||||
|
||||
export default function createLines(geometry, settings) {
|
||||
export default function createLines(geometry) {
|
||||
const faces = [];
|
||||
const lines = [];
|
||||
const lineLookup = {};
|
||||
@ -12,7 +12,7 @@ export default function createLines(geometry, settings) {
|
||||
const normal = calculateNormal(geometry.vertices, a, b, c);
|
||||
|
||||
// skip faces that point up or down
|
||||
if (normal.y > .999 || normal.y < -.999) {
|
||||
if (normal.y > 0.999 || normal.y < -0.999) {
|
||||
faces.push(null);
|
||||
continue;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { PRECISION } from '../constants.js'
|
||||
import { PRECISION } from '../constants.js';
|
||||
import getFillTemplate from './getFillTemplate.js';
|
||||
import Shape from 'clipper-js';
|
||||
|
||||
export default function generateInfills(slices, settings) {
|
||||
let {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { PRECISION } from '../constants.js'
|
||||
import { PRECISION } from '../constants.js';
|
||||
|
||||
const OFFSET_OPTIONS = {
|
||||
jointType: 'jtSquare',
|
||||
@ -10,7 +10,6 @@ const OFFSET_OPTIONS = {
|
||||
export default function generateInnerLines(slices, settings) {
|
||||
// need to scale up everything because of clipper rounding errors
|
||||
let {
|
||||
layerHeight,
|
||||
nozzleDiameter,
|
||||
thickness: { shell: shellThickness }
|
||||
} = settings;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Shape from 'clipper-js';
|
||||
|
||||
export default function calculateOutlines(slices, settings) {
|
||||
export default function calculateOutlines(slices) {
|
||||
for (let layer = 0; layer < slices.length; layer ++) {
|
||||
const slice = slices[layer];
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
export function hslToRgb(h, s, l) {
|
||||
let r, g, b;
|
||||
let r;
|
||||
let g;
|
||||
let b;
|
||||
|
||||
if (s === 0) {
|
||||
r = g = b = lightness;
|
||||
r = g = b = l;
|
||||
} else {
|
||||
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||||
const p = 2 * l - q;
|
||||
|
@ -45,9 +45,9 @@ export default function comb(outline, start, end) {
|
||||
|
||||
if (snappedCombPaths.length === 0) {
|
||||
snappedCombPaths.push([start], [end]);
|
||||
} else if (distanceTo(firstPath[0], start) > 1.) {
|
||||
} else if (distanceTo(firstPath[0], start) > 1.0) {
|
||||
snappedCombPaths.unshift([start]);
|
||||
} else if (distanceTo(lastPath[lastPath.length - 1], end) > 1.) {
|
||||
} else if (distanceTo(lastPath[lastPath.length - 1], end) > 1.0) {
|
||||
snappedCombPaths.push([end]);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { subtract, normal, normalize, dot, almostEquals } from './helpers/vector2.js';
|
||||
|
||||
export default function intersectionsToShapes(layerPoints, layerFaceIndexes, faces, openObjectIndexes, settings) {
|
||||
export default function intersectionsToShapes(layerPoints, layerFaceIndexes, faces, openObjectIndexes) {
|
||||
const layers = [];
|
||||
|
||||
for (let layer = 0; layer < layerPoints.length; layer ++) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { length, distanceTo } from './helpers/vector2.js';
|
||||
import { distanceTo } from './helpers/vector2.js';
|
||||
import Shape from 'clipper-js';
|
||||
|
||||
export default function optimizePaths(slices, settings) {
|
||||
export default function optimizePaths(slices) {
|
||||
let start = { x: 0, y: 0 };
|
||||
|
||||
for (let layer = 0; layer < slices.length; layer ++) {
|
||||
|
@ -3,7 +3,7 @@ import Slice from './helpers/Slice.js';
|
||||
|
||||
import { PRECISION, MIN_AREA } from '../constants.js';
|
||||
|
||||
export default function shapesToSlices(shapes, settings) {
|
||||
export default function shapesToSlices(shapes) {
|
||||
const sliceLayers = [];
|
||||
|
||||
for (let layer = 0; layer < shapes.length; layer ++) {
|
||||
|
@ -13,7 +13,7 @@ import applyPrecision from './applyPrecision.js';
|
||||
import { hslToRgb } from './helpers/color.js';
|
||||
// // import removePrecision from './removePrecision.js';
|
||||
|
||||
export default function(settings, geometry, openObjectIndexes, constructLinePreview, onProgress) {
|
||||
export default function slice(settings, geometry, openObjectIndexes, constructLinePreview, onProgress) {
|
||||
const total = 11;
|
||||
let done = -1;
|
||||
const updateProgress = action => {
|
||||
|
@ -10,14 +10,13 @@ export default function slicesToGCode(slices, settings) {
|
||||
layerHeight,
|
||||
filamentThickness,
|
||||
nozzleDiameter,
|
||||
travelSpeed,
|
||||
retraction,
|
||||
travel,
|
||||
combing
|
||||
} = settings;
|
||||
|
||||
const gcode = new GCode(settings);
|
||||
gcode.updateLayerHeight(Z_OFFSET, nozzleDiameter, filamentThickness)
|
||||
gcode.updateLayerHeight(Z_OFFSET, nozzleDiameter, filamentThickness);
|
||||
|
||||
if (settings.startCode) gcode.addGCode(settings.startCode, settings);
|
||||
|
||||
@ -37,12 +36,12 @@ export default function slicesToGCode(slices, settings) {
|
||||
isFirstLayer = false;
|
||||
}
|
||||
|
||||
const profiles = PROFILE_TYPES.reduce((profiles, profileType) => {
|
||||
profiles[profileType] = {
|
||||
const profiles = PROFILE_TYPES.reduce((_profiles, profileType) => {
|
||||
_profiles[profileType] = {
|
||||
...defaultProfile,
|
||||
lineProfile: isFirstLayer ? settings.firstLayer : settings[profileType]
|
||||
};
|
||||
return profiles;
|
||||
return _profiles;
|
||||
}, {});
|
||||
|
||||
if (typeof slice.brim !== 'undefined') {
|
||||
@ -82,7 +81,8 @@ export default function slicesToGCode(slices, settings) {
|
||||
return gcode.getGCode();
|
||||
}
|
||||
|
||||
function pathToGCode(outline, combing, gcode, shape, retract, unRetract, z, { lineProfile, travelProfile, retractionProfile }) {
|
||||
function pathToGCode(outline, combing, gcode, shape, retract, unRetract, z, profiles) {
|
||||
const { lineProfile, travelProfile, retractionProfile } = profiles;
|
||||
const { closed } = shape;
|
||||
const paths = shape.mapToLower();
|
||||
|
||||
|
@ -99,6 +99,9 @@ function sliceAsync(settings, geometry, openObjectIndexes, constructLinePreview,
|
||||
if (typeof onProgress !== 'undefined') onProgress(data);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -6,7 +6,7 @@ const onProgress = progress => {
|
||||
message: 'PROGRESS',
|
||||
data: progress
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.addEventListener('message', (event) => {
|
||||
const { message, data } = event.data;
|
||||
@ -28,5 +28,7 @@ self.addEventListener('message', (event) => {
|
||||
}, buffers);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, false);
|
||||
|
Loading…
Reference in New Issue
Block a user