mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 07:24:57 +01:00
Fixed simple example
This commit is contained in:
parent
0f4434330b
commit
6744df1779
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user