Doodle3D-Slicer/simpleExample/index.js

20 lines
571 B
JavaScript
Raw Normal View History

2017-07-20 12:12:25 +02:00
import * as THREE from 'three';
import { defaultSettings, Slicer } from 'doodle3d-slicer';
2017-07-07 18:10:29 +02:00
2017-07-20 12:12:25 +02:00
const settings = {
...defaultSettings.base,
...defaultSettings.material.pla,
...defaultSettings.printer.ultimaker2go,
...defaultSettings.quality.high
};
2017-07-07 18:10:29 +02:00
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
2017-07-20 12:12:25 +02:00
const slicer = new Slicer();
2017-07-07 18:10:29 +02:00
slicer.setGeometry(geometry);
2017-07-20 12:12:25 +02:00
slicer.slice(settings, onProgress).then(gcode => {
document.body.innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
});
function onProgress(data) {
console.log('progress: ', data);
}