Fixed simple example

This commit is contained in:
peteruithoven 2017-07-20 16:32:48 +02:00
parent 0f4434330b
commit 6744df1779

View File

@ -1,5 +1,5 @@
import * as THREE from 'three';
import { defaultSettings, Slicer } from 'doodle3d-slicer';
import { defaultSettings, sliceGeometry } from 'doodle3d-slicer';
const settings = {
...defaultSettings.base,
@ -10,11 +10,11 @@ const settings = {
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
const slicer = new Slicer();
slicer.setGeometry(geometry);
slicer.slice(settings, onProgress).then(gcode => {
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 => {
document.body.innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
});
function onProgress(data) {
console.log('progress: ', data);
}