simple example fixed

This commit is contained in:
peteruithoven 2017-07-20 12:12:25 +02:00
parent 566c80f6e8
commit 167c2c67ca
6 changed files with 3509 additions and 27 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ node_modules
lib
module
dist

View File

@ -1,15 +0,0 @@
<!DOCTYPE>
<html>
<head>
<title>Doodle3D Slicer - Simple example</title>
<script type="text/javascript" src="../jspm_packages/system.js"></script>
<script type="text/javascript" src="../jspm.config.js"></script>
<script type="text/javascript">
System.import('simpleExample/index.js');
</script>
</head>
<body>
<div id="gcode"></div>
</body>
</html>

View File

@ -1,16 +1,20 @@
import 'three.js';
import * as SLICER from 'src/index.js';
import * as THREE from 'three';
import { defaultSettings, Slicer } from '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();
const slicer = new Slicer();
slicer.setGeometry(geometry);
slicer.slice(settings, false).then(gcode => {
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
slicer.slice(settings, onProgress).then(gcode => {
document.body.innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
});
function onProgress(data) {
console.log('progress: ', data);
}

3409
simpleExample/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
{
"name": "doodle3d-simple-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack -p",
"start": "webpack-dev-server -w"
},
"author": "",
"license": "ISC",
"dependencies": {
"Doodle3D-Slicer": "github:Doodle3D/Doodle3D-Slicer#webpack",
"babel-polyfill": "^6.23.0",
"three": "^0.83.0"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-latest": "^6.24.1",
"html-webpack-plugin": "^2.29.0",
"json-loader": "^0.5.4",
"webpack": "^3.3.0",
"worker-loader": "^0.8.1",
"yaml-frontmatter-loader": "^0.1.0"
}
}

View File

@ -0,0 +1,55 @@
const path = require('path');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const HTMLWebpackPlugin = require('html-webpack-plugin');
const babelLoader = {
loader: 'babel-loader',
options: {
presets: [
['latest', {
'modules': false,
'loose': true
}]
],
plugins: [require('babel-plugin-transform-object-rest-spread')]
}
}
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
alias: {
'doodle3d-slicer': path.resolve(__dirname, '../src/index.js')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: babelLoader
},
{
test: /\.yml$/,
use: [ 'json-loader', 'yaml-frontmatter-loader' ]
},
{
test: /\.worker\.js$/,
use: ['worker-loader', babelLoader]
}
]
},
plugins: [
new HTMLWebpackPlugin({
title: 'Doodle3D Slicer - Simple example'
}),
],
devtool: "source-map",
devServer: {
contentBase: 'dist'
}
};