Doodle3D-Slicer/simpleExample/index.js

20 lines
657 B
JavaScript
Raw Normal View History

2017-07-20 12:12:25 +02:00
import * as THREE from 'three';
2017-07-20 16:32:48 +02:00
import { defaultSettings, sliceGeometry } 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 16:32:48 +02:00
const onProgress = ({ progress: { done, total, action } }) => {
const percentage = `${(done / total * 100).toFixed()}%`
document.write(`<p>${action}, ${percentage}</p>`);
};
sliceGeometry(settings, geometry, null, false, onProgress).then(gcode => {
2017-07-20 12:12:25 +02:00
document.body.innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
2017-07-20 16:32:48 +02:00
});