diff --git a/example/app.js b/example/app.js new file mode 100644 index 0000000..0c36939 --- /dev/null +++ b/example/app.js @@ -0,0 +1,45 @@ +import * as THREE from 'three.js'; +import stlLoader from 'three.js/loaders/STLLoader'; +import React from 'react'; +import ReactDOM, { render } from 'react-dom'; +import * as SLICER from 'src/index.js'; +import generateRawData from './generateRawData.js'; +import SlicerViewer from './SlicerViewer.js'; + +const settings = new SLICER.Settings({ + ...SLICER.printerSettings['ultimaker2go'], + ...SLICER.userSettings +}); + +const stlLoader = new THREE.STLLoader(); + +stlLoader.load('stl/Airplane.stl', (geometry) => { + 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().scale(0.8)); + geometry.mergeVertices(); + geometry.computeFaceNormals(); + + const rawData = generateRawData(geometry, settings); + + render(, document.getElementById('container')); +}); + +// const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone(); +// geometry.applyMatrix(new THREE.Matrix4().setPosition(new THREE.Vector3(60, 0, 60))); +// geometry.mergeVertices(); +// geometry.computeFaceNormals(); +// +// const rawData = generateRawData(geometry, settings); +// +// render(, document.getElementById('container')); diff --git a/jspm.config.js b/jspm.config.js index 967070a..504d761 100644 --- a/jspm.config.js +++ b/jspm.config.js @@ -14,9 +14,9 @@ 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": "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", + "domain": "npm:jspm-nodelibs-domain@0.2.0", + "zlib": "npm:jspm-nodelibs-zlib@0.2.0", + "https": "npm:jspm-nodelibs-https@0.2.0", "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", @@ -71,16 +71,6 @@ SystemJS.config({ "iconv-lite": "npm:iconv-lite@0.4.13" } }, - "github:jspm/nodelibs-domain@0.2.0-alpha": { - "map": { - "domain-browserify": "npm:domain-browser@1.1.7" - } - }, - "github:jspm/nodelibs-zlib@0.2.0-alpha": { - "map": { - "zlib-browserify": "npm:browserify-zlib@0.1.4" - } - }, "npm:browserify-zlib@0.1.4": { "map": { "readable-stream": "npm:readable-stream@2.1.5", @@ -115,6 +105,16 @@ SystemJS.config({ "esutils": "npm:esutils@2.0.2", "to-fast-properties": "npm:to-fast-properties@1.0.2" } + }, + "npm:jspm-nodelibs-zlib@0.2.0": { + "map": { + "zlib-browserify": "npm:browserify-zlib@0.1.4" + } + }, + "npm:jspm-nodelibs-domain@0.2.0": { + "map": { + "domain-browserify": "npm:domain-browser@1.1.7" + } } } }, @@ -159,27 +159,28 @@ SystemJS.config({ "github:*/*.json" ], map: { + "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", - "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", + "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", "json": "github:systemjs/plugin-json@0.1.2", "Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master", - "module": "github:jspm/nodelibs-module@0.2.0-alpha", - "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": "github:jspm/nodelibs-stream@0.2.0-alpha", - "string_decoder": "github:jspm/nodelibs-string_decoder@0.2.0-alpha", - "tty": "github:jspm/nodelibs-tty@0.2.0-alpha", - "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", + "module": "npm:jspm-nodelibs-module@0.2.0", + "os": "npm:jspm-nodelibs-os@0.2.0", + "path": "npm:jspm-nodelibs-path@0.2.0", + "process": "npm:jspm-nodelibs-process@0.2.0", + "stream": "npm:jspm-nodelibs-stream@0.2.0", + "string_decoder": "npm:jspm-nodelibs-string_decoder@0.2.0", + "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", "worker": "github:casperlamboo/plugin-worker@master" }, packages: { @@ -191,42 +192,12 @@ SystemJS.config({ "npm:clipper-lib@1.0.0": { "map": {} }, - "github:jspm/nodelibs-stream@0.2.0-alpha": { - "map": { - "stream-browserify": "npm:stream-browserify@2.0.1" - } - }, - "github:jspm/nodelibs-buffer@0.2.0-alpha": { - "map": { - "buffer-browserify": "npm:buffer@4.9.1" - } - }, - "github:jspm/nodelibs-string_decoder@0.2.0-alpha": { - "map": { - "string_decoder-browserify": "npm:string_decoder@0.10.31" - } - }, - "github:jspm/nodelibs-url@0.2.0-alpha": { - "map": { - "url-browserify": "npm:url@0.11.0" - } - }, - "github:jspm/nodelibs-http@0.2.0-alpha": { - "map": { - "http-browserify": "npm:stream-http@2.4.0" - } - }, "npm:stream-browserify@2.0.1": { "map": { "inherits": "npm:inherits@2.0.3", "readable-stream": "npm:readable-stream@2.1.5" } }, - "github:jspm/nodelibs-crypto@0.2.0-alpha": { - "map": { - "crypto-browserify": "npm:crypto-browserify@3.11.0" - } - }, "npm:buffer@4.9.1": { "map": { "base64-js": "npm:base64-js@1.2.0", @@ -377,11 +348,6 @@ SystemJS.config({ "inherits": "npm:inherits@2.0.3" } }, - "github:jspm/nodelibs-os@0.2.0-alpha": { - "map": { - "os-browserify": "npm:os-browserify@0.2.1" - } - }, "npm:pbkdf2@3.0.9": { "map": { "create-hmac": "npm:create-hmac@1.1.4" @@ -415,6 +381,46 @@ SystemJS.config({ "builtin-status-codes": "npm:builtin-status-codes@2.0.0", "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" + } } } }); diff --git a/package.json b/package.json index 3e66cc0..395566a 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ }, "dependencies": { "Doodle3D/clipper-js": "github:Doodle3D/clipper-js@master", + "clipper-js": "github:Doodle3D/clipper-js@1.0.2", "json": "github:systemjs/plugin-json@^0.1.2", "three.js": "github:mrdoob/three.js@r83", "worker": "github:casperlamboo/plugin-worker@master" @@ -15,33 +16,33 @@ "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": "github:jspm/nodelibs-domain@^0.2.0-alpha", "file-saver": "npm:file-saver@^1.3.3", - "https": "github:jspm/nodelibs-https@^0.2.0-alpha", + "domain": "npm:jspm-nodelibs-domain@^0.2.0", + "https": "npm:jspm-nodelibs-https@^0.2.0", "plugin-babel": "npm:systemjs-plugin-babel@^0.0.12", "react": "npm:react@^15.3.2", "react-dom": "npm:react-dom@^15.3.2", - "zlib": "github:jspm/nodelibs-zlib@^0.2.0-alpha" + "zlib": "npm:jspm-nodelibs-zlib@^0.2.0" }, "peerDependencies": { - "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": "github:jspm/nodelibs-module@^0.2.0-alpha", - "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": "github:jspm/nodelibs-stream@^0.2.0-alpha", - "string_decoder": "github:jspm/nodelibs-string_decoder@^0.2.0-alpha", - "tty": "github:jspm/nodelibs-tty@^0.2.0-alpha", - "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" + "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", + "module": "npm:jspm-nodelibs-module@^0.2.0", + "os": "npm:jspm-nodelibs-os@^0.2.0", + "path": "npm:jspm-nodelibs-path@^0.2.0", + "process": "npm:jspm-nodelibs-process@^0.2.0", + "stream": "npm:jspm-nodelibs-stream@^0.2.0", + "string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0", + "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" }, "overrides": { "github:mrdoob/three.js@r83": { diff --git a/src/GCode.js b/src/GCode.js index 4da4e9e..636854c 100644 --- a/src/GCode.js +++ b/src/GCode.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; const G_COMMAND = 'G'; const M_COMMAND = 'M'; diff --git a/src/Slicer.js b/src/Slicer.js index 20e76b1..08106a8 100644 --- a/src/Slicer.js +++ b/src/Slicer.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; import slice from './sliceActions/slice.js'; import SlicerWorker from './slicerWorker.js!worker'; diff --git a/src/sliceActions/addBrim.js b/src/sliceActions/addBrim.js index bea204c..6d3ffd5 100644 --- a/src/sliceActions/addBrim.js +++ b/src/sliceActions/addBrim.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; import { PRECISION } from '../constants.js'; const offsetOptions = { diff --git a/src/sliceActions/calculateLayersIntersections.js b/src/sliceActions/calculateLayersIntersections.js index fd6e18a..d7c869d 100644 --- a/src/sliceActions/calculateLayersIntersections.js +++ b/src/sliceActions/calculateLayersIntersections.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; export default function calculateLayersIntersections(lines, settings) { console.log('calculating layer intersections'); diff --git a/src/sliceActions/createLines.js b/src/sliceActions/createLines.js index e835797..bd53efa 100644 --- a/src/sliceActions/createLines.js +++ b/src/sliceActions/createLines.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; function addLine(geometry, lineLookup, lines, a, b) { const index = lines.length; diff --git a/src/sliceActions/intersectionsToShapes.js b/src/sliceActions/intersectionsToShapes.js index 624d0d6..9dd10e0 100644 --- a/src/sliceActions/intersectionsToShapes.js +++ b/src/sliceActions/intersectionsToShapes.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; import Shape from 'Doodle3D/clipper-js'; export default function intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings) { diff --git a/src/sliceActions/optimizePaths.js b/src/sliceActions/optimizePaths.js index 438f489..2e69933 100644 --- a/src/sliceActions/optimizePaths.js +++ b/src/sliceActions/optimizePaths.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; import Shape from 'Doodle3D/clipper-js'; export default function optimizePaths(slices, settings) { diff --git a/src/sliceActions/removePrecision.js b/src/sliceActions/removePrecision.js index 66d8743..bbf05e7 100644 --- a/src/sliceActions/removePrecision.js +++ b/src/sliceActions/removePrecision.js @@ -1,4 +1,4 @@ -import 'three.js'; +import * as THREE from 'three.js'; import { PRECISION } from '../constants.js'; export default function removePrecision(slices) { diff --git a/src/slicerWorker.js b/src/slicerWorker.js index de7e3b0..7218998 100644 --- a/src/slicerWorker.js +++ b/src/slicerWorker.js @@ -1,6 +1,6 @@ import Settings from './Settings.js'; import slice from './sliceActions/slice.js'; -import 'three.js'; +import * as THREE from 'three.js'; const loader = new THREE.JSONLoader();