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 # Usage
```javascript ```javascript
import 'three.js'; import * as THREE from 'three';
import * as SLICER from 'doodle3d-slicer'; import { defaultSettings, Slicer } from 'Doodle3D/Doodle3D-Slicer';
const settings = new SLICER.Settings({ const settings = {
...SLICER.printerSettings['ultimaker2go'], ...defaultSettings.base,
...SLICER.userSettings.low ...defaultSettings.material.pla,
}); ...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high
};
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone(); const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
const slicer = new SLICER.Slicer(); const slicer = new SLICER.Slicer();
slicer.setGeometry(geometry); slicer.setGeometry(geometry);
slicer.slice(settings, false).then(gcode => { const gcode = await slicer.slice(settings)
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />'); .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" src="../jspm.config.js"></script>
<script type="text/javascript"> <script type="text/javascript">
System.import('example/save.js'); System.import('./save.js');
</script> </script>
</head> </head>

View File

@ -1,25 +1,27 @@
import 'three.js'; import * as THREE from 'three';
import 'three.js/loaders/STLLoader'; import { defaultSettings, Slicer } from 'src/index.js';
import { Settings, printerSettings, userSettings, Slicer } from 'src/index.js';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
const settings = new Settings({ const settings = {
...printerSettings['ultimaker2go'], ...defaultSettings.base,
...userSettings ...defaultSettings.material.pla,
}); ...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high
const stlLoader = new THREE.STLLoader(); };
stlLoader.load('stl/traktor.stl', async (geometry) => {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
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().makeRotationX(Math.PI / -2));
geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50))); geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(50, -0.1, 50)));
geometry.mergeVertices();
geometry.computeFaceNormals(); geometry.computeFaceNormals();
const slicer = new Slicer().setGeometry(geometry); 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); saveAs(file);
}); });

View File

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

View File

@ -14,12 +14,11 @@ SystemJS.config({
"core-js": "npm:core-js@1.2.7", "core-js": "npm:core-js@1.2.7",
"plugin-babel": "npm:systemjs-plugin-babel@0.0.12", "plugin-babel": "npm:systemjs-plugin-babel@0.0.12",
"react": "npm:react@15.3.2", "react": "npm:react@15.3.2",
"domain": "npm:jspm-nodelibs-domain@0.2.0", "domain": "github:jspm/nodelibs-domain@0.2.0-alpha",
"zlib": "npm:jspm-nodelibs-zlib@0.2.0", "zlib": "github:jspm/nodelibs-zlib@0.2.0-alpha",
"https": "npm:jspm-nodelibs-https@0.2.0", "https": "github:jspm/nodelibs-https@0.2.0-alpha",
"react-dom": "npm:react-dom@15.3.2", "react-dom": "npm:react-dom@15.3.2",
"babel-plugin-transform-react-jsx": "npm:babel-plugin-transform-react-jsx@6.8.0", "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" "file-saver": "npm:file-saver@1.3.3"
}, },
"packages": { "packages": {
@ -106,12 +105,12 @@ SystemJS.config({
"to-fast-properties": "npm:to-fast-properties@1.0.2" "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": { "map": {
"zlib-browserify": "npm:browserify-zlib@0.1.4" "zlib-browserify": "npm:browserify-zlib@0.1.4"
} }
}, },
"npm:jspm-nodelibs-domain@0.2.0": { "github:jspm/nodelibs-domain@0.2.0-alpha": {
"map": { "map": {
"domain-browserify": "npm:domain-browser@1.1.7" "domain-browserify": "npm:domain-browser@1.1.7"
} }
@ -139,16 +138,8 @@ SystemJS.config({
} }
} }
}, },
meta: {
"three.js/loaders/STLLoader": {
"deps": [
"three.js"
]
}
},
map: { map: {
"babel": "npm:babel-core@5.8.38", "babel": "npm:babel-core@5.8.38"
"three.js/loaders/STLLoader": "github:mrdoob/three.js@r75/examples/js/loaders/STLLoader.js"
} }
}); });
@ -159,28 +150,31 @@ SystemJS.config({
"github:*/*.json" "github:*/*.json"
], ],
map: { 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", "clipper-js": "github:Doodle3D/clipper-js@1.0.2",
"three.js": "github:mrdoob/three.js@r83", "assert": "github:jspm/nodelibs-assert@0.2.0-alpha",
"assert": "npm:jspm-nodelibs-assert@0.2.0", "buffer": "github:jspm/nodelibs-buffer@0.2.0-alpha",
"buffer": "npm:jspm-nodelibs-buffer@0.2.0", "child_process": "github:jspm/nodelibs-child_process@0.2.0-alpha",
"child_process": "npm:jspm-nodelibs-child_process@0.2.0", "constants": "github:jspm/nodelibs-constants@0.2.0-alpha",
"constants": "npm:jspm-nodelibs-constants@0.2.0", "crypto": "github:jspm/nodelibs-crypto@0.2.0-alpha",
"crypto": "npm:jspm-nodelibs-crypto@0.2.0", "events": "github:jspm/nodelibs-events@0.2.2",
"events": "npm:jspm-nodelibs-events@0.2.0", "fs": "github:jspm/nodelibs-fs@0.2.0-alpha",
"fs": "npm:jspm-nodelibs-fs@0.2.0", "http": "github:jspm/nodelibs-http@0.2.0-alpha",
"http": "npm:jspm-nodelibs-http@0.2.0",
"json": "github:systemjs/plugin-json@0.1.2", "json": "github:systemjs/plugin-json@0.1.2",
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master", "Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"module": "npm:jspm-nodelibs-module@0.2.0", "module": "npm:jspm-nodelibs-module@0.2.0",
"os": "npm:jspm-nodelibs-os@0.2.0", "os": "github:jspm/nodelibs-os@0.2.2",
"path": "npm:jspm-nodelibs-path@0.2.0", "path": "github:jspm/nodelibs-path@0.2.3",
"process": "github:jspm/nodelibs-process@0.2.0-alpha", "process": "github:jspm/nodelibs-process@0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@0.2.0", "stream": "github:jspm/nodelibs-stream@0.2.0-alpha",
"string_decoder": "npm:jspm-nodelibs-string_decoder@0.2.0", "string_decoder": "github:jspm/nodelibs-string_decoder@0.2.0-alpha",
"tty": "npm:jspm-nodelibs-tty@0.2.0", "tty": "npm:jspm-nodelibs-tty@0.2.0",
"url": "npm:jspm-nodelibs-url@0.2.0", "url": "github:jspm/nodelibs-url@0.2.0-alpha",
"util": "npm:jspm-nodelibs-util@0.2.0", "util": "github:jspm/nodelibs-util@0.2.0-alpha",
"vm": "npm:jspm-nodelibs-vm@0.2.0", "vm": "github:jspm/nodelibs-vm@0.2.0-alpha",
"worker": "github:casperlamboo/plugin-worker@master" "worker": "github:casperlamboo/plugin-worker@master"
}, },
packages: { packages: {
@ -195,12 +189,12 @@ SystemJS.config({
"npm:stream-browserify@2.0.1": { "npm:stream-browserify@2.0.1": {
"map": { "map": {
"inherits": "npm:inherits@2.0.3", "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": { "npm:buffer@4.9.1": {
"map": { "map": {
"base64-js": "npm:base64-js@1.2.0", "base64-js": "npm:base64-js@1.2.1",
"isarray": "npm:isarray@1.0.0", "isarray": "npm:isarray@1.0.0",
"ieee754": "npm:ieee754@1.1.8" "ieee754": "npm:ieee754@1.1.8"
} }
@ -222,61 +216,22 @@ SystemJS.config({
"util-deprecate": "npm:util-deprecate@1.0.2" "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": { "npm:public-encrypt@4.0.0": {
"map": { "map": {
"randombytes": "npm:randombytes@2.0.3", "randombytes": "npm:randombytes@2.0.5",
"create-hash": "npm:create-hash@1.1.2", "create-hash": "npm:create-hash@1.1.3",
"parse-asn1": "npm:parse-asn1@5.0.0", "parse-asn1": "npm:parse-asn1@5.1.0",
"bn.js": "npm:bn.js@4.11.6", "bn.js": "npm:bn.js@4.11.7",
"browserify-rsa": "npm:browserify-rsa@4.0.1" "browserify-rsa": "npm:browserify-rsa@4.0.1"
} }
}, },
"npm:diffie-hellman@5.0.2": { "npm:diffie-hellman@5.0.2": {
"map": { "map": {
"randombytes": "npm:randombytes@2.0.3", "randombytes": "npm:randombytes@2.0.5",
"bn.js": "npm:bn.js@4.11.6", "bn.js": "npm:bn.js@4.11.7",
"miller-rabin": "npm:miller-rabin@4.0.0" "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": { "npm:browserify-cipher@1.0.0": {
"map": { "map": {
"browserify-des": "npm:browserify-des@1.0.0", "browserify-des": "npm:browserify-des@1.0.0",
@ -286,55 +241,41 @@ SystemJS.config({
}, },
"npm:create-ecdh@4.0.0": { "npm:create-ecdh@4.0.0": {
"map": { "map": {
"elliptic": "npm:elliptic@6.3.2", "elliptic": "npm:elliptic@6.4.0",
"bn.js": "npm:bn.js@4.11.6" "bn.js": "npm:bn.js@4.11.7"
}
},
"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"
} }
}, },
"npm:browserify-des@1.0.0": { "npm:browserify-des@1.0.0": {
"map": { "map": {
"inherits": "npm:inherits@2.0.3", "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" "des.js": "npm:des.js@1.0.0"
} }
}, },
"npm:evp_bytestokey@1.0.0": { "npm:evp_bytestokey@1.0.0": {
"map": { "map": {
"create-hash": "npm:create-hash@1.1.2" "create-hash": "npm:create-hash@1.1.3"
} }
}, },
"npm:browserify-aes@1.0.6": { "npm:browserify-aes@1.0.6": {
"map": { "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", "evp_bytestokey": "npm:evp_bytestokey@1.0.0",
"inherits": "npm:inherits@2.0.3", "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" "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": { "npm:browserify-rsa@4.0.1": {
"map": { "map": {
"bn.js": "npm:bn.js@4.11.6", "bn.js": "npm:bn.js@4.11.7",
"randombytes": "npm:randombytes@2.0.3" "randombytes": "npm:randombytes@2.0.5"
} }
}, },
"npm:miller-rabin@4.0.0": { "npm:miller-rabin@4.0.0": {
"map": { "map": {
"bn.js": "npm:bn.js@4.11.6", "bn.js": "npm:bn.js@4.11.7",
"brorand": "npm:brorand@1.0.6" "brorand": "npm:brorand@1.1.0"
} }
}, },
"npm:des.js@1.0.0": { "npm:des.js@1.0.0": {
@ -343,36 +284,6 @@ SystemJS.config({
"minimalistic-assert": "npm:minimalistic-assert@1.0.0" "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": { "npm:stream-http@2.4.0": {
"map": { "map": {
"inherits": "npm:inherits@2.0.3", "inherits": "npm:inherits@2.0.3",
@ -382,46 +293,187 @@ SystemJS.config({
"xtend": "npm:xtend@4.0.1" "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": { "github:Doodle3D/clipper-js@1.0.2": {
"map": { "map": {
"Breush/clipper-lib": "github:Breush/clipper-lib@patch-1", "Breush/clipper-lib": "github:Breush/clipper-lib@patch-1",
"clipper-lib": "npm:clipper-lib@6.2.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": { "jspm": {
"name": "slicer", "name": "slicer",
"main": "index.js", "main": "index.js",
@ -10,46 +8,46 @@
"dependencies": { "dependencies": {
"Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master", "Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master",
"clipper-js": "github:Doodle3D/clipper-js@1.0.2", "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", "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" "worker": "github:casperlamboo/plugin-worker@master"
}, },
"devDependencies": { "devDependencies": {
"babel-plugin-transform-react-jsx": "npm:babel-plugin-transform-react-jsx@^6.8.0", "babel-plugin-transform-react-jsx": "npm:babel-plugin-transform-react-jsx@^6.8.0",
"babel-runtime": "npm:babel-runtime@^5.1.13", "babel-runtime": "npm:babel-runtime@^5.1.13",
"core-js": "npm:core-js@^1.2.0", "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", "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", "plugin-babel": "npm:systemjs-plugin-babel@^0.0.12",
"react": "npm:react@^15.3.2", "react": "npm:react@^15.3.2",
"react-dom": "npm:react-dom@^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": { "peerDependencies": {
"assert": "npm:jspm-nodelibs-assert@^0.2.0", "assert": "github:jspm/nodelibs-assert@^0.2.0-alpha",
"buffer": "npm:jspm-nodelibs-buffer@^0.2.0", "buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha",
"child_process": "npm:jspm-nodelibs-child_process@^0.2.0", "child_process": "github:jspm/nodelibs-child_process@^0.2.0-alpha",
"constants": "npm:jspm-nodelibs-constants@^0.2.0", "constants": "github:jspm/nodelibs-constants@^0.2.0-alpha",
"crypto": "npm:jspm-nodelibs-crypto@^0.2.0", "crypto": "github:jspm/nodelibs-crypto@^0.2.0-alpha",
"events": "npm:jspm-nodelibs-events@^0.2.0", "events": "github:jspm/nodelibs-events@^0.2.0-alpha",
"fs": "npm:jspm-nodelibs-fs@^0.2.0", "fs": "github:jspm/nodelibs-fs@^0.2.0-alpha",
"http": "npm:jspm-nodelibs-http@^0.2.0", "http": "github:jspm/nodelibs-http@^0.2.0-alpha",
"module": "npm:jspm-nodelibs-module@^0.2.0", "module": "npm:jspm-nodelibs-module@^0.2.0",
"os": "npm:jspm-nodelibs-os@^0.2.0", "os": "github:jspm/nodelibs-os@^0.2.0-alpha",
"path": "npm:jspm-nodelibs-path@^0.2.0", "path": "github:jspm/nodelibs-path@^0.2.0-alpha",
"process": "github:jspm/nodelibs-process@^0.2.0-alpha", "process": "github:jspm/nodelibs-process@^0.2.0-alpha",
"stream": "npm:jspm-nodelibs-stream@^0.2.0", "stream": "github:jspm/nodelibs-stream@^0.2.0-alpha",
"string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0", "string_decoder": "github:jspm/nodelibs-string_decoder@^0.2.0-alpha",
"tty": "npm:jspm-nodelibs-tty@^0.2.0", "tty": "npm:jspm-nodelibs-tty@^0.2.0",
"url": "npm:jspm-nodelibs-url@^0.2.0", "url": "github:jspm/nodelibs-url@^0.2.0-alpha",
"util": "npm:jspm-nodelibs-util@^0.2.0", "util": "github:jspm/nodelibs-util@^0.2.0-alpha",
"vm": "npm:jspm-nodelibs-vm@^0.2.0" "vm": "github:jspm/nodelibs-vm@^0.2.0-alpha"
}, },
"overrides": { "overrides": {
"github:mrdoob/three.js@r83": {
"format": "global"
},
"npm:babel-runtime@5.8.38": { "npm:babel-runtime@5.8.38": {
"main": false, "main": false,
"dependencies": {}, "dependencies": {},
@ -76,10 +74,18 @@
"buffer": "@empty", "buffer": "@empty",
"process": "@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": { "devDependencies": {
"jspm": "^0.17.0-beta.28" "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 slice from './sliceActions/slice.js';
import SlicerWorker from './slicerWorker.js!worker'; import SlicerWorker from './slicerWorker.js!worker';
import ProgressPromise from 'progress-promise';
export default class { export default class {
setMesh(mesh) { setMesh(mesh) {
@ -11,9 +12,9 @@ export default class {
return this; return this;
} }
setGeometry(geometry, matrix) { setGeometry(geometry, matrix) {
if (geometry.type === 'BufferGeometry') { if (geometry.isBufferGeometry) {
geometry = new THREE.Geometry().fromBufferGeometry(geometry); geometry = new THREE.Geometry().fromBufferGeometry(geometry);
} else if (geometry.type === 'Geometry') { } else if (geometry.isGeometry) {
geometry = geometry.clone(); geometry = geometry.clone();
} else { } else {
throw new Error('Geometry is not an instance of BufferGeometry or Geometry'); throw new Error('Geometry is not an instance of BufferGeometry or Geometry');
@ -27,16 +28,15 @@ export default class {
return this; return this;
} }
sliceSync(settings) { sliceSync(settings, onprogress) {
return slice(this.geometry, settings); return slice(this.geometry, settings, onprogress);
} }
slice(settings) { slice(settings) {
const slicerWorker = new SlicerWorker(); const slicerWorker = new SlicerWorker();
const geometry = this.geometry.toJSON(); const geometry = this.geometry.toJSON();
const { config } = settings;
return new Promise((resolve, reject) => { return new ProgressPromise((resolve, reject, progress) => {
slicerWorker.onerror = reject; slicerWorker.onerror = reject;
slicerWorker.addEventListener('message', (event) => { slicerWorker.addEventListener('message', (event) => {
@ -47,12 +47,16 @@ export default class {
resolve(data.gcode); resolve(data.gcode);
break; break;
} }
case 'PROGRESS': {
progress(data);
break;
}
} }
}); });
slicerWorker.postMessage({ slicerWorker.postMessage({
message: 'SLICE', message: 'SLICE',
data: { geometry, config } data: { geometry, settings }
}); });
}); });
} }

View File

@ -1,6 +1,18 @@
import Slicer from './Slicer.js'; import Slicer from './Slicer.js';
import Settings from './Settings.js'; import baseSettings from './settings/default.yml!text';
import printerSettings from './settings/printer_settings.json!json'; import printerSettings from './settings/printer.yml!text';
import userSettings from './settings/user_settings.json!json'; 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 Shape from 'Doodle3D/clipper-js';
import * as THREE from 'three.js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
const offsetOptions = { const offsetOptions = {
@ -9,9 +8,9 @@ const offsetOptions = {
}; };
export default function addBrim(slices, settings) { export default function addBrim(slices, settings) {
console.log('add brim'); let {
brim: { offset: brimOffset }
let { brimOffset } = settings.config; } = settings;
brimOffset /= PRECISION; brimOffset /= PRECISION;
const [firstLayer] = slices; 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) { export default function calculateLayersIntersections(lines, settings) {
console.log('calculating layer intersections'); const {
layerHeight,
const { layerHeight, dimensionsZ } = settings.config; dimensions: { z: dimensionsZ }
} = settings;
const numLayers = Math.floor(dimensionsZ / layerHeight); const numLayers = Math.floor(dimensionsZ / layerHeight);
@ -11,7 +12,9 @@ export default function calculateLayersIntersections(lines, settings) {
const layerIntersectionPoints = Array.from(Array(numLayers)).map(() => []); const layerIntersectionPoints = Array.from(Array(numLayers)).map(() => []);
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) { 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 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); 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; const index = lines.length;
lineLookup[`${a}_${b}`] = index; 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]), line: new THREE.Line3(geometry.vertices[a], geometry.vertices[b]),
connects: [], connects: [],
normals: [], normals: [],
open: false isFlat
}); });
return index; return index;
} }
export default function createLines(geometry, settings, openClosed) { export default function createLines(geometry, settings) {
console.log('constructing unique lines from geometry');
const lines = []; const lines = [];
const lineLookup = {}; const lineLookup = {};
for (let i = 0; i < geometry.faces.length; i ++) { for (let i = 0; i < geometry.faces.length; i ++) {
const face = geometry.faces[i]; const face = geometry.faces[i];
const open = openClosed[i];
if (face.normal.y !== 1 && face.normal.y !== -1) { const lookupA = lineLookup[`${face.b}_${face.a}`];
const normal = new THREE.Vector2(face.normal.z, face.normal.x).normalize(); const lookupB = lineLookup[`${face.c}_${face.b}`];
const lookupC = lineLookup[`${face.a}_${face.c}`];
const lookupA = lineLookup[`${face.b}_${face.a}`]; const isFlat = face.normal.y > 0.999 || face.normal.y < -0.999;
const lookupB = lineLookup[`${face.c}_${face.b}`];
const lookupC = lineLookup[`${face.a}_${face.c}`];
// only add unique lines // only add unique lines
// returns index of said line // returns index of said line
const indexA = typeof lookupA !== 'undefined' ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b); const lineIndexA = typeof lookupA !== 'undefined' ? lookupA : addLine(geometry, lineLookup, lines, face.a, face.b, isFlat);
const indexB = typeof lookupB !== 'undefined' ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c); const lineIndexB = typeof lookupB !== 'undefined' ? lookupB : addLine(geometry, lineLookup, lines, face.b, face.c, isFlat);
const indexC = typeof lookupC !== 'undefined' ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a); const lineIndexC = typeof lookupC !== 'undefined' ? lookupC : addLine(geometry, lineLookup, lines, face.c, face.a, isFlat);
// set connecting lines (based on face) // set connecting lines (based on face)
lines[indexA].connects.push(indexB, indexC); lines[lineIndexA].connects.push(lineIndexB, lineIndexC);
lines[indexB].connects.push(indexC, indexA); lines[lineIndexB].connects.push(lineIndexC, lineIndexA);
lines[indexC].connects.push(indexA, indexB); lines[lineIndexC].connects.push(lineIndexA, lineIndexB);
lines[indexA].normals.push(normal); const normal = new THREE.Vector2(face.normal.z, face.normal.x).normalize();
lines[indexB].normals.push(normal); lines[lineIndexA].normals.push(normal);
lines[indexC].normals.push(normal); lines[lineIndexB].normals.push(normal);
lines[lineIndexC].normals.push(normal);
lines[indexA].open = open;
lines[indexB].open = open;
lines[indexC].open = open;
}
} }
return lines; return lines;

View File

@ -1,42 +1,43 @@
export default function detectOpenClosed(geometry) { export default function detectOpenClosed(lines) {
console.log('detecting open and closed 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 ++) { for (let i = 0; i < pools.length; i ++) {
const pool = pools[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 ++) { for (let i = 0; i < pools.length; i ++) {
const pool = pools[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; return pool;
} }
} }
// no pool found
// create new pool
const pool = []; const pool = [];
pools.push(pool); pools.push(pool);
return pool; return pool;
} }
function getPools(geometry) { function getPools(lines) {
const pools = []; const pools = [];
for (let i = 0; i < geometry.faces.length; i ++) { for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
const face = geometry.faces[i]; const pool = findPool(pools, lines, lineIndex);
const pool = findPool(pools, face); pool.push(lineIndex);
pool.push(face);
} }
for (let i = 0; i < pools.length; i ++) { for (let i = 0; i < pools.length; i ++) {
@ -46,8 +47,9 @@ function getPools(geometry) {
const poolB = pools[j]; const poolB = pools[j];
for (let k = 0; k < poolA.length; k ++) { for (let k = 0; k < poolA.length; k ++) {
const faceA = poolA[k]; const { connects } = lines[poolA[k]];
if (poolB.find(faceB => faceA.a === faceB.a || faceA.a === faceB.b || faceA.a === faceB.c)) {
if (poolB.find(lineIndex => connects.includes(lineIndex))) {
poolA.splice(poolA.length, 0, ...poolB); poolA.splice(poolA.length, 0, ...poolB);
poolB.splice(0, poolB.length); poolB.splice(0, poolB.length);
} }
@ -57,15 +59,3 @@ function getPools(geometry) {
return pools.filter(pool => pool.length > 0); 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'; import Shape from 'Doodle3D/clipper-js';
export default function generateInfills(slices, settings) { export default function generateInfills(slices, settings) {
console.log('generating infills');
let { let {
layerHeight, layerHeight,
fillGridSize, fill: { gridSize: fillGridSize },
bottomThickness, bottom: { thickness: bottomThickness },
topThickness, top: { thickness: topThickness },
nozzleDiameter, nozzleDiameter,
infillOverlap fill: { overlap: infillOverlap }
} = settings.config; } = settings;
fillGridSize /= PRECISION; fillGridSize /= PRECISION;
nozzleDiameter /= PRECISION; nozzleDiameter /= PRECISION;

View File

@ -8,10 +8,12 @@ const offsetOptions = {
}; };
export default function generateInnerLines(slices, settings) { export default function generateInnerLines(slices, settings) {
console.log('generating outer lines and inner lines');
// need to scale up everything because of clipper rounding errors // 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; nozzleDiameter /= PRECISION;
shellThickness /= PRECISION; shellThickness /= PRECISION;
const nozzleRadius = nozzleDiameter / 2; const nozzleRadius = nozzleDiameter / 2;

View File

@ -3,18 +3,18 @@ import Shape from 'Doodle3D/clipper-js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
export default function generateSupport(slices, settings) { export default function generateSupport(slices, settings) {
console.log('generating support'); if (!settings.support.enabled) return;
if (!settings.config.supportEnabled) return;
let { let {
layerHeight, layerHeight,
supportGridSize, support: {
supportAcceptanceMargin, gridSize: supportGridSize,
supportPlateSize: plateSize, margin: supportMargin,
supportDistanceY, plateSize: plateSize,
distanceY: supportDistanceY
},
nozzleDiameter nozzleDiameter
} = settings.config; } = settings;
supportGridSize /= PRECISION; supportGridSize /= PRECISION;
supportMargin /= PRECISION; supportMargin /= PRECISION;
@ -62,10 +62,10 @@ export default function generateSupport(slices, settings) {
var outerLine = slicePart.outerLine; var outerLine = slicePart.outerLine;
} }
else { 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); var overhang = outerLine.difference(overlap);
if (overlap.length === 0 || overhang.length > 0) { 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 MOVE = 'G';
const M_COMMAND = 'M'; const M_COMMAND = 'M';
@ -66,7 +66,7 @@ export default class {
const { const {
layerHeight, layerHeight,
travelSpeed travelSpeed
} = this._settings.config; } = this._settings;
const z = layer * layerHeight + 0.2; const z = layer * layerHeight + 0.2;
const speed = travelSpeed * 60; const speed = travelSpeed * 60;
@ -92,9 +92,9 @@ export default class {
nozzleDiameter, nozzleDiameter,
filamentThickness, filamentThickness,
travelSpeed travelSpeed
} = this._settings.config; } = this._settings;
const profile = this._settings.config[(this.bottom ? 'bottom' : type)]; const profile = this._settings[(this.bottom ? 'bottom' : type)];
let { let {
speed, speed,
@ -125,10 +125,12 @@ export default class {
unRetract() { unRetract() {
const { const {
retractionEnabled, retraction: {
retractionMinDistance, enabled: retractionEnabled,
retractionSpeed minDistance: retractionMinDistance,
} = this._settings.config; speed: retractionSpeed
}
} = this._settings;
if (this._isRetracted && retractionEnabled) { if (this._isRetracted && retractionEnabled) {
this._isRetracted = false; this._isRetracted = false;
@ -149,11 +151,13 @@ export default class {
retract() { retract() {
const { const {
retractionAmount, retraction: {
retractionEnabled, amount: retractionAmount,
retractionMinDistance, enabled: retractionEnabled,
retractionSpeed minDistance: retractionMinDistance,
} = this._settings.config; speed: retractionSpeed
}
} = this._settings;
if (!this._isRetracted && retractionEnabled) { if (!this._isRetracted && retractionEnabled) {
this._isRetracted = true; this._isRetracted = true;
@ -173,6 +177,6 @@ export default class {
} }
getGCode() { 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'; import Shape from 'Doodle3D/clipper-js';
export default function intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings) { export default function intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings) {
console.log('generating slices');
const layers = []; const layers = [];
for (let layer = 1; layer < layerIntersectionIndexes.length; layer ++) { for (let layer = 1; layer < layerIntersectionIndexes.length; layer ++) {
@ -22,7 +20,7 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
const shape = []; const shape = [];
const firstPoints = [index]; const firstPoints = [index];
const { open: openGeometry } = lines[index]; const { openGeometry } = lines[index];
let isFirstPoint = true; let isFirstPoint = true;
let openShape = 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'; import Shape from 'Doodle3D/clipper-js';
export default function optimizePaths(slices, settings) { export default function optimizePaths(slices, settings) {
console.log('optimize paths');
const start = new THREE.Vector2(0, 0); const start = new THREE.Vector2(0, 0);
for (let layer = 0; layer < slices.length; layer ++) { 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'; import { PRECISION } from '../constants.js';
const inversePrecision = 1 / PRECISION; const inversePrecision = 1 / PRECISION;
export default function removePrecision(slices) { export default function removePrecision(slices) {
console.log('remove precision');
for (let layer = 0; layer < slices.length; layer ++) { for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[layer]; const slice = slices[layer];

View File

@ -1,5 +1,5 @@
import Shape from 'Doodle3D/clipper-js'; import Shape from 'Doodle3D/clipper-js';
import Slice from '../Slice.js'; import Slice from './helpers/Slice.js';
import { CLEAN_DELTA, PRECISION } from '../constants.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 applyPrecision from './applyPrecision.js';
import removePrecision from './removePrecision.js'; import removePrecision from './removePrecision.js';
export default function(geometry, settings) { export default function(geometry, settings, onProgress) {
geometry.mergeVertices(); const totalStages = 11;
let current = -1;
const updateProgress = (action) => {
current ++;
if (onProgress) onProgress({ done: current, total: totalStages, action });
};
geometry.computeFaceNormals(); geometry.computeFaceNormals();
// get unique lines from geometry; // get unique lines from geometry;
const openClosed = detectOpenClosed(geometry); updateProgress('Constructing unique lines from geometry');
const lines = createLines(geometry, settings, openClosed); const lines = createLines(geometry, settings);
updateProgress('Detecting open vs closed shapes');
const openClosed = detectOpenClosed(lines);
updateProgress('Calculating layer intersections');
const { const {
layerIntersectionIndexes, layerIntersectionIndexes,
layerIntersectionPoints layerIntersectionPoints
} = calculateLayersIntersections(lines, settings); } = calculateLayersIntersections(lines, settings);
updateProgress('Constructing shapes from intersections');
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings); const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
applyPrecision(shapes); applyPrecision(shapes);
updateProgress('Constructing slices from shapes');
const slices = shapesToSlices(shapes, settings); const slices = shapesToSlices(shapes, settings);
updateProgress('Generating inner lines');
generateInnerLines(slices, settings); generateInnerLines(slices, settings);
updateProgress('Generating infills');
generateInfills(slices, settings); generateInfills(slices, settings);
updateProgress('Generating support');
generateSupport(slices, settings); generateSupport(slices, settings);
updateProgress('Adding brim');
addBrim(slices, settings); addBrim(slices, settings);
updateProgress('Optimizing paths');
optimizePaths(slices, settings); optimizePaths(slices, settings);
removePrecision(slices); removePrecision(slices);
updateProgress('Constructing gcode');
const gcode = slicesToGCode(slices, settings); const gcode = slicesToGCode(slices, settings);
updateProgress('Finished');
return gcode; 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) { export default function slicesToGCode(slices, settings) {
console.log('slices to gcode');
const gcode = new GCode(settings); const gcode = new GCode(settings);
for (let layer = 0; layer < slices.length; layer ++) { 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 slice from './sliceActions/slice.js';
import * as THREE from 'three.js'; import * as THREE from 'three';
const loader = new THREE.JSONLoader(); const loader = new THREE.JSONLoader();
const onProgress = progress => {
self.postMessage({
message: 'PROGRESS',
data: { progress }
});
}
self.addEventListener('message', (event) => { self.addEventListener('message', (event) => {
const { message, data } = event.data; const { message, data } = event.data;
switch (message) { switch (message) {
case 'SLICE': { case 'SLICE': {
const { geometry: JSONGeometry, config } = data; const { geometry: JSONGeometry, settings } = data;
const { geometry } = new loader.parse(JSONGeometry.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({ self.postMessage({
message: 'SLICE', message: 'SLICE',