Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
peteruithoven 2017-07-19 17:36:25 +02:00
commit 2668c16500
32 changed files with 682 additions and 595 deletions

View File

@ -3,20 +3,23 @@ JavaScript gcode slicer, Intended to use with the Doodle3D WiFi-Box
# Usage
```javascript
import 'three.js';
import * as SLICER from 'doodle3d-slicer';
import * as THREE from 'three';
import { defaultSettings, Slicer } from 'Doodle3D/Doodle3D-Slicer';
const settings = new SLICER.Settings({
...SLICER.printerSettings['ultimaker2go'],
...SLICER.userSettings.low
});
const settings = {
...defaultSettings.base,
...defaultSettings.material.pla,
...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high
};
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
const slicer = new SLICER.Slicer();
slicer.setGeometry(geometry);
slicer.slice(settings, false).then(gcode => {
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
});
const gcode = await slicer.slice(settings)
.progress(({ progress: { done, total, action } }) => {
const percentage = `${(done / total * 100).toFixed()}%`
console.log(action, percentage);
});
```

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
<script type="text/javascript" src="../jspm.config.js"></script>
<script type="text/javascript">
System.import('example/save.js');
System.import('./save.js');
</script>
</head>

View File

@ -1,25 +1,27 @@
import 'three.js';
import 'three.js/loaders/STLLoader';
import { Settings, printerSettings, userSettings, Slicer } from 'src/index.js';
import * as THREE from 'three';
import { defaultSettings, Slicer } from 'src/index.js';
import { saveAs } from 'file-saver';
const settings = new Settings({
...printerSettings['ultimaker2go'],
...userSettings
});
const stlLoader = new THREE.STLLoader();
stlLoader.load('stl/traktor.stl', async (geometry) => {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
const settings = {
...defaultSettings.base,
...defaultSettings.material.pla,
...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high
};
const jsonLoader = new THREE.JSONLoader();
jsonLoader.load('models/airplane.json', async geometry => {
geometry.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI / -2));
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50)));
geometry.mergeVertices();
geometry.computeFaceNormals();
const slicer = new Slicer().setGeometry(geometry);
const gcode = await slicer.slice(settings);
const gcode = await slicer.slice(settings)
.progress(({ progress: { done, total, action } }) => {
const percentage = `${(done / total * 100).toFixed()}%`
document.write(`<p>${action}, ${percentage}</p>`);
});
const file = new File([gcode], 'traktor.gcode', { type: 'text/plain' });
const file = new File([gcode], 'gcode.gcode', { type: 'text/plain' });
saveAs(file);
});

View File

@ -1,5 +1,5 @@
import * as THREE from 'three.js';
import stlLoader from 'three.js/loaders/STLLoader';
import 'three.js';
import 'three.js/loaders/STLLoader';
import React from 'react';
import ReactDOM, { render } from 'react-dom';
import * as SLICER from 'src/index.js';
@ -28,7 +28,7 @@ stlLoader.load('stl/Airplane.stl', (geometry) => {
layerIntersectionPoints={rawData.layerIntersectionPoints}
layerShapes={rawData.layerShapes}
slices={rawData.slices}
settings={settings.config}
settings={settings}
/>,
document.getElementById('container')
);

View File

@ -14,12 +14,11 @@ SystemJS.config({
"core-js": "npm:core-js@1.2.7",
"plugin-babel": "npm:systemjs-plugin-babel@0.0.12",
"react": "npm:react@15.3.2",
"domain": "npm:jspm-nodelibs-domain@0.2.0",
"zlib": "npm:jspm-nodelibs-zlib@0.2.0",
"https": "npm:jspm-nodelibs-https@0.2.0",
"domain": "github:jspm/nodelibs-domain@0.2.0-alpha",
"zlib": "github:jspm/nodelibs-zlib@0.2.0-alpha",
"https": "github:jspm/nodelibs-https@0.2.0-alpha",
"react-dom": "npm:react-dom@15.3.2",
"babel-plugin-transform-react-jsx": "npm:babel-plugin-transform-react-jsx@6.8.0",
"three.js/loaders/STLLoader": "github:mrdoob/three.js@r83/examples/js/loaders/STLLoader.js",
"file-saver": "npm:file-saver@1.3.3"
},
"packages": {
@ -106,12 +105,12 @@ SystemJS.config({
"to-fast-properties": "npm:to-fast-properties@1.0.2"
}
},
"npm:jspm-nodelibs-zlib@0.2.0": {
"github:jspm/nodelibs-zlib@0.2.0-alpha": {
"map": {
"zlib-browserify": "npm:browserify-zlib@0.1.4"
}
},
"npm:jspm-nodelibs-domain@0.2.0": {
"github:jspm/nodelibs-domain@0.2.0-alpha": {
"map": {
"domain-browserify": "npm:domain-browser@1.1.7"
}
@ -139,16 +138,8 @@ SystemJS.config({
}
}
},
meta: {
"three.js/loaders/STLLoader": {
"deps": [
"three.js"
]
}
},
map: {
"babel": "npm:babel-core@5.8.38",
"three.js/loaders/STLLoader": "github:mrdoob/three.js@r75/examples/js/loaders/STLLoader.js"
"babel": "npm:babel-core@5.8.38"
}
});
@ -159,28 +150,31 @@ SystemJS.config({
"github:*/*.json"
],
map: {
"three": "npm:three@0.83.0",
"progress-promise": "npm:progress-promise@0.0.6",
"text": "github:systemjs/plugin-text@0.0.11",
"js-yaml": "npm:js-yaml@3.9.0",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"three.js": "github:mrdoob/three.js@r83",
"assert": "npm:jspm-nodelibs-assert@0.2.0",
"buffer": "npm:jspm-nodelibs-buffer@0.2.0",
"child_process": "npm:jspm-nodelibs-child_process@0.2.0",
"constants": "npm:jspm-nodelibs-constants@0.2.0",
"crypto": "npm:jspm-nodelibs-crypto@0.2.0",
"events": "npm:jspm-nodelibs-events@0.2.0",
"fs": "npm:jspm-nodelibs-fs@0.2.0",
"http": "npm:jspm-nodelibs-http@0.2.0",
"assert": "github:jspm/nodelibs-assert@0.2.0-alpha",
"buffer": "github:jspm/nodelibs-buffer@0.2.0-alpha",
"child_process": "github:jspm/nodelibs-child_process@0.2.0-alpha",
"constants": "github:jspm/nodelibs-constants@0.2.0-alpha",
"crypto": "github:jspm/nodelibs-crypto@0.2.0-alpha",
"events": "github:jspm/nodelibs-events@0.2.2",
"fs": "github:jspm/nodelibs-fs@0.2.0-alpha",
"http": "github:jspm/nodelibs-http@0.2.0-alpha",
"json": "github:systemjs/plugin-json@0.1.2",
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"module": "npm:jspm-nodelibs-module@0.2.0",
"os": "npm:jspm-nodelibs-os@0.2.0",
"path": "npm:jspm-nodelibs-path@0.2.0",
"os": "github:jspm/nodelibs-os@0.2.2",
"path": "github:jspm/nodelibs-path@0.2.3",
"process": "github:jspm/nodelibs-process@0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@0.2.0",
"string_decoder": "npm:jspm-nodelibs-string_decoder@0.2.0",
"stream": "github:jspm/nodelibs-stream@0.2.0-alpha",
"string_decoder": "github:jspm/nodelibs-string_decoder@0.2.0-alpha",
"tty": "npm:jspm-nodelibs-tty@0.2.0",
"url": "npm:jspm-nodelibs-url@0.2.0",
"util": "npm:jspm-nodelibs-util@0.2.0",
"vm": "npm:jspm-nodelibs-vm@0.2.0",
"url": "github:jspm/nodelibs-url@0.2.0-alpha",
"util": "github:jspm/nodelibs-util@0.2.0-alpha",
"vm": "github:jspm/nodelibs-vm@0.2.0-alpha",
"worker": "github:casperlamboo/plugin-worker@master"
},
packages: {
@ -195,12 +189,12 @@ SystemJS.config({
"npm:stream-browserify@2.0.1": {
"map": {
"inherits": "npm:inherits@2.0.3",
"readable-stream": "npm:readable-stream@2.1.5"
"readable-stream": "npm:readable-stream@2.3.3"
}
},
"npm:buffer@4.9.1": {
"map": {
"base64-js": "npm:base64-js@1.2.0",
"base64-js": "npm:base64-js@1.2.1",
"isarray": "npm:isarray@1.0.0",
"ieee754": "npm:ieee754@1.1.8"
}
@ -222,61 +216,22 @@ SystemJS.config({
"util-deprecate": "npm:util-deprecate@1.0.2"
}
},
"npm:crypto-browserify@3.11.0": {
"map": {
"inherits": "npm:inherits@2.0.3",
"browserify-cipher": "npm:browserify-cipher@1.0.0",
"create-hash": "npm:create-hash@1.1.2",
"browserify-sign": "npm:browserify-sign@4.0.0",
"pbkdf2": "npm:pbkdf2@3.0.9",
"public-encrypt": "npm:public-encrypt@4.0.0",
"randombytes": "npm:randombytes@2.0.3",
"diffie-hellman": "npm:diffie-hellman@5.0.2",
"create-ecdh": "npm:create-ecdh@4.0.0",
"create-hmac": "npm:create-hmac@1.1.4"
}
},
"npm:browserify-sign@4.0.0": {
"map": {
"create-hash": "npm:create-hash@1.1.2",
"inherits": "npm:inherits@2.0.3",
"create-hmac": "npm:create-hmac@1.1.4",
"parse-asn1": "npm:parse-asn1@5.0.0",
"elliptic": "npm:elliptic@6.3.2",
"bn.js": "npm:bn.js@4.11.6",
"browserify-rsa": "npm:browserify-rsa@4.0.1"
}
},
"npm:create-hash@1.1.2": {
"map": {
"inherits": "npm:inherits@2.0.3",
"ripemd160": "npm:ripemd160@1.0.1",
"cipher-base": "npm:cipher-base@1.0.3",
"sha.js": "npm:sha.js@2.4.5"
}
},
"npm:public-encrypt@4.0.0": {
"map": {
"randombytes": "npm:randombytes@2.0.3",
"create-hash": "npm:create-hash@1.1.2",
"parse-asn1": "npm:parse-asn1@5.0.0",
"bn.js": "npm:bn.js@4.11.6",
"randombytes": "npm:randombytes@2.0.5",
"create-hash": "npm:create-hash@1.1.3",
"parse-asn1": "npm:parse-asn1@5.1.0",
"bn.js": "npm:bn.js@4.11.7",
"browserify-rsa": "npm:browserify-rsa@4.0.1"
}
},
"npm:diffie-hellman@5.0.2": {
"map": {
"randombytes": "npm:randombytes@2.0.3",
"bn.js": "npm:bn.js@4.11.6",
"randombytes": "npm:randombytes@2.0.5",
"bn.js": "npm:bn.js@4.11.7",
"miller-rabin": "npm:miller-rabin@4.0.0"
}
},
"npm:create-hmac@1.1.4": {
"map": {
"create-hash": "npm:create-hash@1.1.2",
"inherits": "npm:inherits@2.0.3"
}
},
"npm:browserify-cipher@1.0.0": {
"map": {
"browserify-des": "npm:browserify-des@1.0.0",
@ -286,55 +241,41 @@ SystemJS.config({
},
"npm:create-ecdh@4.0.0": {
"map": {
"elliptic": "npm:elliptic@6.3.2",
"bn.js": "npm:bn.js@4.11.6"
}
},
"npm:parse-asn1@5.0.0": {
"map": {
"create-hash": "npm:create-hash@1.1.2",
"pbkdf2": "npm:pbkdf2@3.0.9",
"browserify-aes": "npm:browserify-aes@1.0.6",
"evp_bytestokey": "npm:evp_bytestokey@1.0.0",
"asn1.js": "npm:asn1.js@4.8.1"
"elliptic": "npm:elliptic@6.4.0",
"bn.js": "npm:bn.js@4.11.7"
}
},
"npm:browserify-des@1.0.0": {
"map": {
"inherits": "npm:inherits@2.0.3",
"cipher-base": "npm:cipher-base@1.0.3",
"cipher-base": "npm:cipher-base@1.0.4",
"des.js": "npm:des.js@1.0.0"
}
},
"npm:evp_bytestokey@1.0.0": {
"map": {
"create-hash": "npm:create-hash@1.1.2"
"create-hash": "npm:create-hash@1.1.3"
}
},
"npm:browserify-aes@1.0.6": {
"map": {
"create-hash": "npm:create-hash@1.1.2",
"create-hash": "npm:create-hash@1.1.3",
"evp_bytestokey": "npm:evp_bytestokey@1.0.0",
"inherits": "npm:inherits@2.0.3",
"cipher-base": "npm:cipher-base@1.0.3",
"cipher-base": "npm:cipher-base@1.0.4",
"buffer-xor": "npm:buffer-xor@1.0.3"
}
},
"npm:sha.js@2.4.5": {
"map": {
"inherits": "npm:inherits@2.0.3"
}
},
"npm:browserify-rsa@4.0.1": {
"map": {
"bn.js": "npm:bn.js@4.11.6",
"randombytes": "npm:randombytes@2.0.3"
"bn.js": "npm:bn.js@4.11.7",
"randombytes": "npm:randombytes@2.0.5"
}
},
"npm:miller-rabin@4.0.0": {
"map": {
"bn.js": "npm:bn.js@4.11.6",
"brorand": "npm:brorand@1.0.6"
"bn.js": "npm:bn.js@4.11.7",
"brorand": "npm:brorand@1.1.0"
}
},
"npm:des.js@1.0.0": {
@ -343,36 +284,6 @@ SystemJS.config({
"minimalistic-assert": "npm:minimalistic-assert@1.0.0"
}
},
"npm:hash.js@1.0.3": {
"map": {
"inherits": "npm:inherits@2.0.3"
}
},
"npm:pbkdf2@3.0.9": {
"map": {
"create-hmac": "npm:create-hmac@1.1.4"
}
},
"npm:elliptic@6.3.2": {
"map": {
"bn.js": "npm:bn.js@4.11.6",
"inherits": "npm:inherits@2.0.3",
"brorand": "npm:brorand@1.0.6",
"hash.js": "npm:hash.js@1.0.3"
}
},
"npm:cipher-base@1.0.3": {
"map": {
"inherits": "npm:inherits@2.0.3"
}
},
"npm:asn1.js@4.8.1": {
"map": {
"bn.js": "npm:bn.js@4.11.6",
"inherits": "npm:inherits@2.0.3",
"minimalistic-assert": "npm:minimalistic-assert@1.0.0"
}
},
"npm:stream-http@2.4.0": {
"map": {
"inherits": "npm:inherits@2.0.3",
@ -382,46 +293,187 @@ SystemJS.config({
"xtend": "npm:xtend@4.0.1"
}
},
"npm:jspm-nodelibs-crypto@0.2.0": {
"map": {
"crypto-browserify": "npm:crypto-browserify@3.11.0"
}
},
"npm:jspm-nodelibs-http@0.2.0": {
"map": {
"http-browserify": "npm:stream-http@2.4.0"
}
},
"npm:jspm-nodelibs-os@0.2.0": {
"map": {
"os-browserify": "npm:os-browserify@0.2.1"
}
},
"npm:jspm-nodelibs-buffer@0.2.0": {
"map": {
"buffer-browserify": "npm:buffer@4.9.1"
}
},
"npm:jspm-nodelibs-stream@0.2.0": {
"map": {
"stream-browserify": "npm:stream-browserify@2.0.1"
}
},
"npm:jspm-nodelibs-string_decoder@0.2.0": {
"map": {
"string_decoder-browserify": "npm:string_decoder@0.10.31"
}
},
"npm:jspm-nodelibs-url@0.2.0": {
"map": {
"url-browserify": "npm:url@0.11.0"
}
},
"github:Doodle3D/clipper-js@1.0.2": {
"map": {
"Breush/clipper-lib": "github:Breush/clipper-lib@patch-1",
"clipper-lib": "npm:clipper-lib@6.2.1"
}
},
"npm:js-yaml@3.9.0": {
"map": {
"argparse": "npm:argparse@1.0.9",
"esprima": "npm:esprima@4.0.0"
}
},
"npm:argparse@1.0.9": {
"map": {
"sprintf-js": "npm:sprintf-js@1.0.3"
}
},
"github:jspm/nodelibs-buffer@0.2.0-alpha": {
"map": {
"buffer-browserify": "npm:buffer@4.9.1"
}
},
"github:jspm/nodelibs-crypto@0.2.0-alpha": {
"map": {
"crypto-browserify": "npm:crypto-browserify@3.11.1"
}
},
"npm:crypto-browserify@3.11.1": {
"map": {
"browserify-cipher": "npm:browserify-cipher@1.0.0",
"browserify-sign": "npm:browserify-sign@4.0.4",
"create-ecdh": "npm:create-ecdh@4.0.0",
"create-hash": "npm:create-hash@1.1.3",
"create-hmac": "npm:create-hmac@1.1.6",
"diffie-hellman": "npm:diffie-hellman@5.0.2",
"inherits": "npm:inherits@2.0.3",
"pbkdf2": "npm:pbkdf2@3.0.12",
"public-encrypt": "npm:public-encrypt@4.0.0",
"randombytes": "npm:randombytes@2.0.5"
}
},
"npm:browserify-sign@4.0.4": {
"map": {
"create-hash": "npm:create-hash@1.1.3",
"create-hmac": "npm:create-hmac@1.1.6",
"inherits": "npm:inherits@2.0.3",
"elliptic": "npm:elliptic@6.4.0",
"bn.js": "npm:bn.js@4.11.7",
"parse-asn1": "npm:parse-asn1@5.1.0",
"browserify-rsa": "npm:browserify-rsa@4.0.1"
}
},
"npm:create-hash@1.1.3": {
"map": {
"inherits": "npm:inherits@2.0.3",
"ripemd160": "npm:ripemd160@2.0.1",
"sha.js": "npm:sha.js@2.4.8",
"cipher-base": "npm:cipher-base@1.0.4"
}
},
"npm:create-hmac@1.1.6": {
"map": {
"create-hash": "npm:create-hash@1.1.3",
"inherits": "npm:inherits@2.0.3",
"ripemd160": "npm:ripemd160@2.0.1",
"safe-buffer": "npm:safe-buffer@5.1.1",
"sha.js": "npm:sha.js@2.4.8",
"cipher-base": "npm:cipher-base@1.0.4"
}
},
"npm:randombytes@2.0.5": {
"map": {
"safe-buffer": "npm:safe-buffer@5.1.1"
}
},
"npm:pbkdf2@3.0.12": {
"map": {
"create-hmac": "npm:create-hmac@1.1.6",
"ripemd160": "npm:ripemd160@2.0.1",
"safe-buffer": "npm:safe-buffer@5.1.1",
"sha.js": "npm:sha.js@2.4.8",
"create-hash": "npm:create-hash@1.1.3"
}
},
"npm:ripemd160@2.0.1": {
"map": {
"inherits": "npm:inherits@2.0.3",
"hash-base": "npm:hash-base@2.0.2"
}
},
"npm:sha.js@2.4.8": {
"map": {
"inherits": "npm:inherits@2.0.3"
}
},
"npm:elliptic@6.4.0": {
"map": {
"inherits": "npm:inherits@2.0.3",
"bn.js": "npm:bn.js@4.11.7",
"hmac-drbg": "npm:hmac-drbg@1.0.1",
"hash.js": "npm:hash.js@1.1.3",
"brorand": "npm:brorand@1.1.0",
"minimalistic-crypto-utils": "npm:minimalistic-crypto-utils@1.0.1",
"minimalistic-assert": "npm:minimalistic-assert@1.0.0"
}
},
"npm:parse-asn1@5.1.0": {
"map": {
"browserify-aes": "npm:browserify-aes@1.0.6",
"create-hash": "npm:create-hash@1.1.3",
"evp_bytestokey": "npm:evp_bytestokey@1.0.0",
"pbkdf2": "npm:pbkdf2@3.0.12",
"asn1.js": "npm:asn1.js@4.9.1"
}
},
"npm:cipher-base@1.0.4": {
"map": {
"safe-buffer": "npm:safe-buffer@5.1.1",
"inherits": "npm:inherits@2.0.3"
}
},
"npm:hash-base@2.0.2": {
"map": {
"inherits": "npm:inherits@2.0.3"
}
},
"npm:hmac-drbg@1.0.1": {
"map": {
"hash.js": "npm:hash.js@1.1.3",
"minimalistic-assert": "npm:minimalistic-assert@1.0.0",
"minimalistic-crypto-utils": "npm:minimalistic-crypto-utils@1.0.1"
}
},
"npm:hash.js@1.1.3": {
"map": {
"inherits": "npm:inherits@2.0.3",
"minimalistic-assert": "npm:minimalistic-assert@1.0.0"
}
},
"npm:asn1.js@4.9.1": {
"map": {
"bn.js": "npm:bn.js@4.11.7",
"inherits": "npm:inherits@2.0.3",
"minimalistic-assert": "npm:minimalistic-assert@1.0.0"
}
},
"github:jspm/nodelibs-stream@0.2.0-alpha": {
"map": {
"stream-browserify": "npm:stream-browserify@2.0.1"
}
},
"npm:readable-stream@2.3.3": {
"map": {
"inherits": "npm:inherits@2.0.3",
"isarray": "npm:isarray@1.0.0",
"safe-buffer": "npm:safe-buffer@5.1.1",
"string_decoder": "npm:string_decoder@1.0.3",
"util-deprecate": "npm:util-deprecate@1.0.2",
"process-nextick-args": "npm:process-nextick-args@1.0.7",
"core-util-is": "npm:core-util-is@1.0.2"
}
},
"npm:string_decoder@1.0.3": {
"map": {
"safe-buffer": "npm:safe-buffer@5.1.1"
}
},
"github:jspm/nodelibs-string_decoder@0.2.0-alpha": {
"map": {
"string_decoder-browserify": "npm:string_decoder@0.10.31"
}
},
"github:jspm/nodelibs-http@0.2.0-alpha": {
"map": {
"http-browserify": "npm:stream-http@2.4.0"
}
},
"github:jspm/nodelibs-url@0.2.0-alpha": {
"map": {
"url-browserify": "npm:url@0.11.0"
}
}
}
});

View File

@ -1,6 +1,4 @@
{
"name": "Doodle3D-Slicer",
"version": "0.0.1",
"jspm": {
"name": "slicer",
"main": "index.js",
@ -10,46 +8,46 @@
"dependencies": {
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"js-yaml": "npm:js-yaml@^3.9.0",
"json": "github:systemjs/plugin-json@^0.1.2",
"three.js": "github:mrdoob/three.js@r83",
"progress-promise": "npm:progress-promise@^0.0.6",
"text": "github:systemjs/plugin-text@^0.0.11",
"three": "npm:three@0.83.0",
"worker": "github:casperlamboo/plugin-worker@master"
},
"devDependencies": {
"babel-plugin-transform-react-jsx": "npm:babel-plugin-transform-react-jsx@^6.8.0",
"babel-runtime": "npm:babel-runtime@^5.1.13",
"core-js": "npm:core-js@^1.2.0",
"domain": "npm:jspm-nodelibs-domain@^0.2.0",
"https": "npm:jspm-nodelibs-https@^0.2.0",
"file-saver": "npm:file-saver@^1.3.3",
"domain": "github:jspm/nodelibs-domain@^0.2.0-alpha",
"https": "github:jspm/nodelibs-https@^0.2.0-alpha",
"plugin-babel": "npm:systemjs-plugin-babel@^0.0.12",
"react": "npm:react@^15.3.2",
"react-dom": "npm:react-dom@^15.3.2",
"zlib": "npm:jspm-nodelibs-zlib@^0.2.0"
"zlib": "github:jspm/nodelibs-zlib@^0.2.0-alpha"
},
"peerDependencies": {
"assert": "npm:jspm-nodelibs-assert@^0.2.0",
"buffer": "npm:jspm-nodelibs-buffer@^0.2.0",
"child_process": "npm:jspm-nodelibs-child_process@^0.2.0",
"constants": "npm:jspm-nodelibs-constants@^0.2.0",
"crypto": "npm:jspm-nodelibs-crypto@^0.2.0",
"events": "npm:jspm-nodelibs-events@^0.2.0",
"fs": "npm:jspm-nodelibs-fs@^0.2.0",
"http": "npm:jspm-nodelibs-http@^0.2.0",
"assert": "github:jspm/nodelibs-assert@^0.2.0-alpha",
"buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha",
"child_process": "github:jspm/nodelibs-child_process@^0.2.0-alpha",
"constants": "github:jspm/nodelibs-constants@^0.2.0-alpha",
"crypto": "github:jspm/nodelibs-crypto@^0.2.0-alpha",
"events": "github:jspm/nodelibs-events@^0.2.0-alpha",
"fs": "github:jspm/nodelibs-fs@^0.2.0-alpha",
"http": "github:jspm/nodelibs-http@^0.2.0-alpha",
"module": "npm:jspm-nodelibs-module@^0.2.0",
"os": "npm:jspm-nodelibs-os@^0.2.0",
"path": "npm:jspm-nodelibs-path@^0.2.0",
"os": "github:jspm/nodelibs-os@^0.2.0-alpha",
"path": "github:jspm/nodelibs-path@^0.2.0-alpha",
"process": "github:jspm/nodelibs-process@^0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@^0.2.0",
"string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0",
"stream": "github:jspm/nodelibs-stream@^0.2.0-alpha",
"string_decoder": "github:jspm/nodelibs-string_decoder@^0.2.0-alpha",
"tty": "npm:jspm-nodelibs-tty@^0.2.0",
"url": "npm:jspm-nodelibs-url@^0.2.0",
"util": "npm:jspm-nodelibs-util@^0.2.0",
"vm": "npm:jspm-nodelibs-vm@^0.2.0"
"url": "github:jspm/nodelibs-url@^0.2.0-alpha",
"util": "github:jspm/nodelibs-util@^0.2.0-alpha",
"vm": "github:jspm/nodelibs-vm@^0.2.0-alpha"
},
"overrides": {
"github:mrdoob/three.js@r83": {
"format": "global"
},
"npm:babel-runtime@5.8.38": {
"main": false,
"dependencies": {},
@ -76,10 +74,18 @@
"buffer": "@empty",
"process": "@empty"
}
},
"npm:pbkdf2@3.0.12": {
"main": "browser.js"
},
"npm:safe-buffer@5.1.1": {
"browser": "index.js"
}
}
},
"dependencies": {},
"dependencies": {
"js-yaml": "^3.9.0"
},
"devDependencies": {
"jspm": "^0.17.0-beta.28"
}

View File

@ -1,53 +0,0 @@
export default class {
constructor(config = {}) {
this.config = config;
}
updateConfig(config) {
this.config = { ...this.config, ...config };
return this;
}
startCode() {
const { startCode } = this.config;
const gcode = this._subsituteVariables(startCode);
return gcode;
}
endCode() {
const { endCode } = this.config;
const gcode = this._subsituteVariables(endCode);
return gcode;
}
_subsituteVariables(gcode) {
let {
temperature,
bedTemperature,
heatTemperature,
heatBedTemperature,
travelSpeed,
printerType,
heatedBed
} = this.config;
travelSpeed *= 60;
switch (printerType) {
case 'makerbot_replicator2': printerType = 'r2'; break;
case 'makerbot_replicator2x': printerType = 'r2x'; break;
case 'makerbot_thingomatic': printerType = 't6'; break;
case 'makerbot_generic': printerType = 'r2'; break;
case '_3Dison_plus': printerType = 'r2'; break;
}
const heatedBedReplacement = heatedBed ? '' : ';';
gcode = gcode.replace(/{printingTemp}/gi, temperature);
gcode = gcode.replace(/{printingBedTemp}/gi, bedTemperature);
gcode = gcode.replace(/{preheatTemp}/gi, heatTemperature);
gcode = gcode.replace(/{preheatBedTemp}/gi, heatBedTemperature);
gcode = gcode.replace(/{printerType}/gi, printerType);
gcode = gcode.replace(/{travelSpeed}/gi, travelSpeed);
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement);
return gcode;
}
}

View File

@ -1,6 +1,7 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
import slice from './sliceActions/slice.js';
import SlicerWorker from './slicerWorker.js!worker';
import ProgressPromise from 'progress-promise';
export default class {
setMesh(mesh) {
@ -11,9 +12,9 @@ export default class {
return this;
}
setGeometry(geometry, matrix) {
if (geometry.type === 'BufferGeometry') {
if (geometry.isBufferGeometry) {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
} else if (geometry.type === 'Geometry') {
} else if (geometry.isGeometry) {
geometry = geometry.clone();
} else {
throw new Error('Geometry is not an instance of BufferGeometry or Geometry');
@ -27,16 +28,15 @@ export default class {
return this;
}
sliceSync(settings) {
return slice(this.geometry, settings);
sliceSync(settings, onprogress) {
return slice(this.geometry, settings, onprogress);
}
slice(settings) {
const slicerWorker = new SlicerWorker();
const geometry = this.geometry.toJSON();
const { config } = settings;
return new Promise((resolve, reject) => {
return new ProgressPromise((resolve, reject, progress) => {
slicerWorker.onerror = reject;
slicerWorker.addEventListener('message', (event) => {
@ -47,12 +47,16 @@ export default class {
resolve(data.gcode);
break;
}
case 'PROGRESS': {
progress(data);
break;
}
}
});
slicerWorker.postMessage({
message: 'SLICE',
data: { geometry, config }
data: { geometry, settings }
});
});
}

View File

@ -1,6 +1,18 @@
import Slicer from './Slicer.js';
import Settings from './Settings.js';
import printerSettings from './settings/printer_settings.json!json';
import userSettings from './settings/user_settings.json!json';
import baseSettings from './settings/default.yml!text';
import printerSettings from './settings/printer.yml!text';
import materialSettings from './settings/material.yml!text';
import qualitySettings from './settings/quality.yml!text';
import yaml from 'js-yaml';
export { Slicer, Settings, printerSettings, userSettings };
const defaultSettings = {
base: yaml.safeLoad(baseSettings),
printer: yaml.safeLoad(printerSettings),
material: yaml.safeLoad(materialSettings),
quality: yaml.safeLoad(qualitySettings)
};
export {
Slicer,
defaultSettings
};

51
src/settings/default.yml Normal file
View File

@ -0,0 +1,51 @@
dimensions:
x: 200
y: 200
z: 200
temperature: 210
bedTemperature: 70
# heatBedTemperature: 20
# heatTemperature: 20
# heatupEnabled: true
travelSpeed: 200.0
layerHeight: 0.15
heatedBed: false
nozzleDiameter: 0.4
filamentThickness: 2.85
retraction:
amount: 3.0
enabled: true
speed: 50.0
minDistance: 0.0
support:
acceptanceMargin: 1.5
distanceY: 0.4
enabled: false
gridSize: 6.0
margin: 2.0
plateSize: 4.0
flowRate: 0.8
speed: 40.0
outerLine:
flowRate: 1.0
speed: 40.0
innerLine:
flowRate: 1.0
speed: 50.0
fill:
flowRate: 1.0
speed: 50.0
overlap: 0.0
gridSize: 5.0
brim:
flowRate: 1.0
speed: 40.0
offset: 4.0
top:
thickness: 1.2
bottom:
flowRate: 1.2
speed: 40.0
thickness: 0.4
shell:
thickness: 0.4

View File

@ -0,0 +1,6 @@
pla:
title: PLA
temperature: 210
abs:
title: ABS
temperature: 240

171
src/settings/printer.yml Normal file
View File

@ -0,0 +1,171 @@
_3Dison_plus:
title: 3Dison plus
dimensions:
x: 227
y: 147
z: 150
bigbuilder3d:
title: Big Builder 3D
builder3d:
title: Builder 3D
bukobot:
title: Bukobot
cartesio:
title: Cartesio
colido_2_0_plus:
title: ColiDo 2.0 Plus
heatedBed: true
dimensions:
x: 230
y: 150
z: 140
colido_compact:
title: ColiDo Compact
dimensions:
x: 130
y: 130
z: 115
colido_diy:
title: ColiDo DIY
dimensions:
z: 170
colido_m2020:
title: ColiDo M2020
heatedBed: true
colido_x3045:
title: ColiDo X3045
heatedBed: true
dimensions:
x: 300
y: 300
z: 450
craftbot_plus:
title: CraftBot PLUS
heatedBed: true
filamentThickness: 1.75
dimensions:
x: 250
cyrus:
title: Cyrus
delta_rostockmax:
title: Delta RostockMax
dimensions:
x: 0
y: 0
deltamaker:
title: Deltamaker
dimensions:
x: 0
y: 0
doodle_dream:
title: Doodle Dream
filamentThickness: 1.75
dimensions:
x: 120
y: 120
z: 80
eventorbot:
title: EventorBot
felix:
title: Felix
gigabot:
title: Gigabot
kossel:
title: Kossel
dimensions:
x: 0
y: 0
leapfrog_creatr:
title: LeapFrog Creatr
lulzbot_aO_101:
title: LulzBot AO-101
lulzbot_taz_4:
title: LulzBot TAZ 4
dimensions:
x: 298
y: 275
z: 250
heatedBed: true
makerbot_generic:
title: Generic Makerbot Printer
makerbot_replicator2:
title: MakerBot Replicator2
makerbot_replicator2x:
title: MakerBot Replicator2x
heatedBed: true
makerbot_thingomatic:
title: MakerBot Thing-o-matic
makergear_m2:
title: MakerGear M2
makergear_prusa:
title: MakerGear Prusa
makibox:
title: Makibox
mamba3d:
title: Mamba3D
marlin_generic:
title: Generic Marlin Printer
minifactory:
title: miniFactory
dimensions:
x: 150
y: 150
z: 155
heatedBed: true
orca_0_3:
title: Orca 0.3
ord_bot_hadron:
title: ORD Bot Hadron
printrbot:
title: Printrbot
printxel_3d:
title: Printxel 3D
prusa_i3:
title: Prusa I3
prusa_iteration_2:
title: Prusa Iteration 2
rapman:
title: RapMan
renkforce_rf100:
title: Renkforce RF100
filamentThickness: 1.75
dimensions:
x: 100
y: 100
z: 100
reprappro_huxley:
title: RepRapPro Huxley
reprappro_mendel:
title: RepRapPro Mendel
rigidbot:
title: Rigidbot
robo_3d_printer:
title: RoBo 3D Printer
shapercube:
title: ShaperCube
tantillus:
title: Tantillus
ultimaker:
title: Ultimaker Original
ultimaker2:
title: Ultimaker 2
heatedBed: true
ultimaker2go:
title: Ultimaker 2 Go
dimensions:
x: 120
y: 120
z: 112
ultimaker_original_plus:
title: Ultimaker Original Plus
heatedBed: true
vision_3d_printer:
title: Vision 3D Printer
wanhao_duplicator4:
title: Wanhao Duplicator 4
filamentThickness: 1.75
heatedBed: true
dimensions:
x: 210
y: 140
z: 140

View File

@ -1,38 +0,0 @@
{
"ultimaker": {
"dimensionsX": 200,
"dimensionsY": 200,
"dimensionsZ": 200,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker"
},
"ultimaker2": {
"dimensionsX": 223,
"dimensionsY": 223,
"dimensionsZ": 205,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+5.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": true,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2"
},
"ultimaker2go": {
"dimensionsX": 120,
"dimensionsY": 120,
"dimensionsZ": 115,
"endCode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 ;home the printer\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)\n",
"filamentThickness": 2.85,
"heatedBed": false,
"heatupEnabled": true,
"nozzleDiameter": 0.4,
"startCode": ";Generated with Doodle3D (ultimaker2go)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG90 ;absolute positioning\nM107 ;start with the fan off\nG28 ; home to endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG0 X0 Y0 F{travelSpeed} ;home position is not X0 Y0\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)\n",
"type": "ultimaker2g0"
}
}

11
src/settings/quality.yml Normal file
View File

@ -0,0 +1,11 @@
low:
title: "Low"
layerHeight: .2
fill:
gridSize: 15.0
medium:
title: "Medium"
layerHeight: .15
high:
title: "High"
layerHeight: .1

View File

@ -1,146 +0,0 @@
{
"low": {
"temperature": 210.0,
"bedTemperature": 70,
"heatBedTemperature": 20,
"heatTemperature": 20,
"layerHeight": 0.15,
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.0,
"travelSpeed": 200.0,
"retractionAmount": 3.0,
"retractionEnabled": true,
"retractionSpeed": 50.0,
"retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4,
"supportEnabled": false,
"supportGridSize": 6.0,
"supportMargin": 2.0,
"supportPlateSize": 4.0,
"outerLine": {
"flowRate": 1.0,
"speed": 40.0
},
"innerLine": {
"flowRate": 1.0,
"speed": 50.0
},
"fill": {
"flowRate": 1.0,
"speed": 50.0
},
"brim": {
"flowRate": 1.0,
"speed": 40.0
},
"support": {
"flowRate": 0.8,
"speed": 40.0
},
"bottom": {
"flowRate": 1.2,
"speed": 40.0
}
},
"medium": {
"temperature": 210.0,
"bedTemperature": 70,
"heatBedTemperature": 20,
"heatTemperature": 20,
"layerHeight": 0.15,
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.0,
"travelSpeed": 200.0,
"retractionAmount": 3.0,
"retractionEnabled": true,
"retractionSpeed": 50.0,
"retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4,
"supportEnabled": false,
"supportGridSize": 6.0,
"supportMargin": 2.0,
"supportPlateSize": 4.0,
"outerLine": {
"flowRate": 1.0,
"speed": 40.0
},
"innerLine": {
"flowRate": 1.0,
"speed": 50.0
},
"fill": {
"flowRate": 1.0,
"speed": 50.0
},
"brim": {
"flowRate": 1.0,
"speed": 40.0
},
"support": {
"flowRate": 0.8,
"speed": 40.0
},
"bottom": {
"flowRate": 1.2,
"speed": 40.0
}
},
"high": {
"temperature": 210.0,
"bedTemperature": 70,
"heatBedTemperature": 20,
"heatTemperature": 20,
"layerHeight": 0.15,
"bottomThickness": 0.4,
"topThickness": 0.8,
"shellThickness": 0.4,
"brimOffset": 4.0,
"fillGridSize": 5.0,
"infillOverlap": 0.0,
"travelSpeed": 200.0,
"retractionAmount": 3.0,
"retractionEnabled": true,
"retractionSpeed": 50.0,
"retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4,
"supportEnabled": false,
"supportGridSize": 6.0,
"supportMargin": 2.0,
"supportPlateSize": 4.0,
"outerLine": {
"flowRate": 1.0,
"speed": 40.0
},
"innerLine": {
"flowRate": 1.0,
"speed": 50.0
},
"fill": {
"flowRate": 1.0,
"speed": 50.0
},
"brim": {
"flowRate": 1.0,
"speed": 40.0
},
"support": {
"flowRate": 0.8,
"speed": 40.0
},
"bottom": {
"flowRate": 1.2,
"speed": 40.0
}
}
}

View File

@ -1,5 +1,4 @@
import Shape from 'Doodle3D/clipper-js';
import * as THREE from 'three.js';
import { PRECISION } from '../constants.js';
const offsetOptions = {
@ -9,9 +8,9 @@ const offsetOptions = {
};
export default function addBrim(slices, settings) {
console.log('add brim');
let { brimOffset } = settings.config;
let {
brim: { offset: brimOffset }
} = settings;
brimOffset /= PRECISION;
const [firstLayer] = slices;

View File

@ -1,9 +1,10 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
export default function calculateLayersIntersections(lines, settings) {
console.log('calculating layer intersections');
const { layerHeight, dimensionsZ } = settings.config;
const {
layerHeight,
dimensions: { z: dimensionsZ }
} = settings;
const numLayers = Math.floor(dimensionsZ / layerHeight);
@ -11,7 +12,9 @@ export default function calculateLayersIntersections(lines, settings) {
const layerIntersectionPoints = Array.from(Array(numLayers)).map(() => []);
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
const line = lines[lineIndex].line;
const { line, isFlat } = lines[lineIndex];
if (isFlat) continue;
const min = Math.ceil(Math.min(line.start.y, line.end.y) / layerHeight);
const max = Math.floor(Math.max(line.start.y, line.end.y) / layerHeight);

View File

@ -1,6 +1,6 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
function addLine(geometry, lineLookup, lines, a, b) {
function addLine(geometry, lineLookup, lines, a, b, isFlat) {
const index = lines.length;
lineLookup[`${a}_${b}`] = index;
@ -8,48 +8,40 @@ function addLine(geometry, lineLookup, lines, a, b) {
line: new THREE.Line3(geometry.vertices[a], geometry.vertices[b]),
connects: [],
normals: [],
open: false
isFlat
});
return index;
}
export default function createLines(geometry, settings, openClosed) {
console.log('constructing unique lines from geometry');
export default function createLines(geometry, settings) {
const lines = [];
const lineLookup = {};
for (let i = 0; i < geometry.faces.length; i ++) {
const face = geometry.faces[i];
const open = openClosed[i];
if (face.normal.y !== 1 && face.normal.y !== -1) {
const normal = new THREE.Vector2(face.normal.z, face.normal.x).normalize();
const lookupA = lineLookup[`${face.b}_${face.a}`];
const lookupB = lineLookup[`${face.c}_${face.b}`];
const lookupC = lineLookup[`${face.a}_${face.c}`];
const lookupA = lineLookup[`${face.b}_${face.a}`];
const lookupB = lineLookup[`${face.c}_${face.b}`];
const lookupC = lineLookup[`${face.a}_${face.c}`];
const isFlat = face.normal.y > 0.999 || face.normal.y < -0.999;
// only add unique lines
// returns index of said line
const indexA = typeof lookupA !== 'undefined' ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b);
const indexB = typeof lookupB !== 'undefined' ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c);
const indexC = typeof lookupC !== 'undefined' ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a);
// only add unique lines
// returns index of said line
const lineIndexA = typeof lookupA !== 'undefined' ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b, isFlat);
const lineIndexB = typeof lookupB !== 'undefined' ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c, isFlat);
const lineIndexC = typeof lookupC !== 'undefined' ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a, isFlat);
// set connecting lines (based on face)
lines[indexA].connects.push(indexB, indexC);
lines[indexB].connects.push(indexC, indexA);
lines[indexC].connects.push(indexA, indexB);
// set connecting lines (based on face)
lines[lineIndexA].connects.push(lineIndexB, lineIndexC);
lines[lineIndexB].connects.push(lineIndexC, lineIndexA);
lines[lineIndexC].connects.push(lineIndexA, lineIndexB);
lines[indexA].normals.push(normal);
lines[indexB].normals.push(normal);
lines[indexC].normals.push(normal);
lines[indexA].open = open;
lines[indexB].open = open;
lines[indexC].open = open;
}
const normal = new THREE.Vector2(face.normal.z, face.normal.x).normalize();
lines[lineIndexA].normals.push(normal);
lines[lineIndexB].normals.push(normal);
lines[lineIndexC].normals.push(normal);
}
return lines;

View File

@ -1,42 +1,43 @@
export default function detectOpenClosed(geometry) {
console.log('detecting open and closed lines');
export default function detectOpenClosed(lines) {
const pools = getPools(lines);
const openLines = lines.map(line => line.connects.length === 2);
const pools = getPools(geometry);
const openVertices = getOpenVertices(geometry);
const openFaces = [];
for (let i = 0; i < pools.length; i ++) {
const pool = pools[i];
const isOpen = pool.some(face => openVertices[face.a] || openVertices[face.b] || openVertices[face.c]);
const isOpenGeometry = pool.some(lineIndex => openLines[lineIndex]);
if (isOpen) openFaces.splice(openFaces.length, 0, ...pool);
for (let j = 0; j < pool.length; j ++) {
const lineIndex = pool[j];
const line = lines[lineIndex];
line.openGeometry = isOpenGeometry;
}
}
return geometry.faces.map(face => openFaces.includes(face));
}
function findPool(pools, faceA) {
function findPool(pools, lines, lineIndex) {
const { connects } = lines[lineIndex];
for (let i = 0; i < pools.length; i ++) {
const pool = pools[i];
if (pool.find(faceB => faceA.a === faceB.a || faceA.a === faceB.b || faceA.a === faceB.c)) {
if (pool.find(lineIndex => connects.includes(lineIndex))) {
return pool;
}
}
// no pool found
// create new pool
const pool = [];
pools.push(pool);
return pool;
}
function getPools(geometry) {
function getPools(lines) {
const pools = [];
for (let i = 0; i < geometry.faces.length; i ++) {
const face = geometry.faces[i];
const pool = findPool(pools, face);
pool.push(face);
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
const pool = findPool(pools, lines, lineIndex);
pool.push(lineIndex);
}
for (let i = 0; i < pools.length; i ++) {
@ -46,8 +47,9 @@ function getPools(geometry) {
const poolB = pools[j];
for (let k = 0; k < poolA.length; k ++) {
const faceA = poolA[k];
if (poolB.find(faceB => faceA.a === faceB.a || faceA.a === faceB.b || faceA.a === faceB.c)) {
const { connects } = lines[poolA[k]];
if (poolB.find(lineIndex => connects.includes(lineIndex))) {
poolA.splice(poolA.length, 0, ...poolB);
poolB.splice(0, poolB.length);
}
@ -57,15 +59,3 @@ function getPools(geometry) {
return pools.filter(pool => pool.length > 0);
}
function getOpenVertices(geometry) {
const vertices = Array(geometry.vertices.length).fill(0);
for (let i = 0; i < geometry.faces.length; i ++) {
const face = geometry.faces[i];
vertices[face.a] ++;
vertices[face.b] ++;
vertices[face.c] ++;
}
return vertices.map(numFaces => numFaces < 4);
}

View File

@ -3,16 +3,14 @@ import getFillTemplate from './getFillTemplate.js';
import Shape from 'Doodle3D/clipper-js';
export default function generateInfills(slices, settings) {
console.log('generating infills');
let {
layerHeight,
fillGridSize,
bottomThickness,
topThickness,
fill: { gridSize: fillGridSize },
bottom: { thickness: bottomThickness },
top: { thickness: topThickness },
nozzleDiameter,
infillOverlap
} = settings.config;
fill: { overlap: infillOverlap }
} = settings;
fillGridSize /= PRECISION;
nozzleDiameter /= PRECISION;

View File

@ -8,10 +8,12 @@ const offsetOptions = {
};
export default function generateInnerLines(slices, settings) {
console.log('generating outer lines and inner lines');
// need to scale up everything because of clipper rounding errors
let { layerHeight, nozzleDiameter, shellThickness } = settings.config;
let {
layerHeight,
nozzleDiameter,
shell: { thickness: shellThickness }
} = settings;
nozzleDiameter /= PRECISION;
shellThickness /= PRECISION;
const nozzleRadius = nozzleDiameter / 2;

View File

@ -3,18 +3,18 @@ import Shape from 'Doodle3D/clipper-js';
import { PRECISION } from '../constants.js';
export default function generateSupport(slices, settings) {
console.log('generating support');
if (!settings.config.supportEnabled) return;
if (!settings.support.enabled) return;
let {
layerHeight,
supportGridSize,
supportAcceptanceMargin,
supportPlateSize: plateSize,
supportDistanceY,
support: {
gridSize: supportGridSize,
margin: supportMargin,
plateSize: plateSize,
distanceY: supportDistanceY
},
nozzleDiameter
} = settings.config;
} = settings;
supportGridSize /= PRECISION;
supportMargin /= PRECISION;
@ -62,10 +62,10 @@ export default function generateSupport(slices, settings) {
var outerLine = slicePart.outerLine;
}
else {
var outerLine = slicePart.intersect.offset(supportAcceptanceMargin);
var outerLine = slicePart.intersect.offset(supportMargin);
}
var overlap = supportSkin.offset(supportAcceptanceMargin).intersect(outerLine);
var overlap = supportSkin.offset(supportMargin).intersect(outerLine);
var overhang = outerLine.difference(overlap);
if (overlap.length === 0 || overhang.length > 0) {

View File

@ -1,4 +1,4 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
const MOVE = 'G';
const M_COMMAND = 'M';
@ -66,7 +66,7 @@ export default class {
const {
layerHeight,
travelSpeed
} = this._settings.config;
} = this._settings;
const z = layer * layerHeight + 0.2;
const speed = travelSpeed * 60;
@ -92,9 +92,9 @@ export default class {
nozzleDiameter,
filamentThickness,
travelSpeed
} = this._settings.config;
} = this._settings;
const profile = this._settings.config[(this.bottom ? 'bottom' : type)];
const profile = this._settings[(this.bottom ? 'bottom' : type)];
let {
speed,
@ -125,10 +125,12 @@ export default class {
unRetract() {
const {
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this._settings.config;
retraction: {
enabled: retractionEnabled,
minDistance: retractionMinDistance,
speed: retractionSpeed
}
} = this._settings;
if (this._isRetracted && retractionEnabled) {
this._isRetracted = false;
@ -149,11 +151,13 @@ export default class {
retract() {
const {
retractionAmount,
retractionEnabled,
retractionMinDistance,
retractionSpeed
} = this._settings.config;
retraction: {
amount: retractionAmount,
enabled: retractionEnabled,
minDistance: retractionMinDistance,
speed: retractionSpeed
}
} = this._settings;
if (!this._isRetracted && retractionEnabled) {
this._isRetracted = true;
@ -173,6 +177,6 @@ export default class {
}
getGCode() {
return this._settings.startCode() + this._gcode + this._settings.endCode();
return this._gcode;
}
}

View File

@ -1,9 +1,7 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
import Shape from 'Doodle3D/clipper-js';
export default function intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings) {
console.log('generating slices');
const layers = [];
for (let layer = 1; layer < layerIntersectionIndexes.length; layer ++) {
@ -22,7 +20,7 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
const shape = [];
const firstPoints = [index];
const { open: openGeometry } = lines[index];
const { openGeometry } = lines[index];
let isFirstPoint = true;
let openShape = true;

View File

@ -1,9 +1,7 @@
import * as THREE from 'three.js';
import * as THREE from 'three';
import Shape from 'Doodle3D/clipper-js';
export default function optimizePaths(slices, settings) {
console.log('optimize paths');
const start = new THREE.Vector2(0, 0);
for (let layer = 0; layer < slices.length; layer ++) {

View File

@ -1,11 +1,8 @@
import * as THREE from 'three.js';
import { PRECISION } from '../constants.js';
const inversePrecision = 1 / PRECISION;
export default function removePrecision(slices) {
console.log('remove precision');
for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[layer];

View File

@ -1,5 +1,5 @@
import Shape from 'Doodle3D/clipper-js';
import Slice from '../Slice.js';
import Slice from './helpers/Slice.js';
import { CLEAN_DELTA, PRECISION } from '../constants.js';

View File

@ -12,33 +12,54 @@ import detectOpenClosed from './detectOpenClosed.js';
import applyPrecision from './applyPrecision.js';
import removePrecision from './removePrecision.js';
export default function(geometry, settings) {
geometry.mergeVertices();
export default function(geometry, settings, onProgress) {
const totalStages = 11;
let current = -1;
const updateProgress = (action) => {
current ++;
if (onProgress) onProgress({ done: current, total: totalStages, action });
};
geometry.computeFaceNormals();
// get unique lines from geometry;
const openClosed = detectOpenClosed(geometry);
const lines = createLines(geometry, settings, openClosed);
updateProgress('Constructing unique lines from geometry');
const lines = createLines(geometry, settings);
updateProgress('Detecting open vs closed shapes');
const openClosed = detectOpenClosed(lines);
updateProgress('Calculating layer intersections');
const {
layerIntersectionIndexes,
layerIntersectionPoints
} = calculateLayersIntersections(lines, settings);
updateProgress('Constructing shapes from intersections');
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
applyPrecision(shapes);
updateProgress('Constructing slices from shapes');
const slices = shapesToSlices(shapes, settings);
updateProgress('Generating inner lines');
generateInnerLines(slices, settings);
updateProgress('Generating infills');
generateInfills(slices, settings);
updateProgress('Generating support');
generateSupport(slices, settings);
updateProgress('Adding brim');
addBrim(slices, settings);
updateProgress('Optimizing paths');
optimizePaths(slices, settings);
removePrecision(slices);
updateProgress('Constructing gcode');
const gcode = slicesToGCode(slices, settings);
updateProgress('Finished');
return gcode;
}

View File

@ -1,8 +1,6 @@
import GCode from '../GCode.js';
import GCode from './helpers/GCode.js';
export default function slicesToGCode(slices, settings) {
console.log('slices to gcode');
const gcode = new GCode(settings);
for (let layer = 0; layer < slices.length; layer ++) {

View File

@ -1,19 +1,24 @@
import Settings from './Settings.js';
import slice from './sliceActions/slice.js';
import * as THREE from 'three.js';
import * as THREE from 'three';
const loader = new THREE.JSONLoader();
const onProgress = progress => {
self.postMessage({
message: 'PROGRESS',
data: { progress }
});
}
self.addEventListener('message', (event) => {
const { message, data } = event.data;
switch (message) {
case 'SLICE': {
const { geometry: JSONGeometry, config } = data;
const { geometry: JSONGeometry, settings } = data;
const { geometry } = new loader.parse(JSONGeometry.data);
const settings = new Settings(config);
const gcode = slice(geometry, settings);
const gcode = slice(geometry, settings, onProgress);
self.postMessage({
message: 'SLICE',