mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 15:34: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 * as THREE from 'three';
|
||||||
import { defaultSettings, Slicer } from 'doodle3d-slicer';
|
import { defaultSettings, sliceGeometry } from 'doodle3d-slicer';
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
...defaultSettings.base,
|
...defaultSettings.base,
|
||||||
@ -10,11 +10,11 @@ const settings = {
|
|||||||
|
|
||||||
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
|
const geometry = new THREE.TorusGeometry(20, 10, 30, 30).clone();
|
||||||
|
|
||||||
const slicer = new Slicer();
|
const onProgress = ({ progress: { done, total, action } }) => {
|
||||||
slicer.setGeometry(geometry);
|
const percentage = `${(done / total * 100).toFixed()}%`
|
||||||
slicer.slice(settings, onProgress).then(gcode => {
|
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 />');
|
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