mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 07:24:57 +01:00
reorganize folders and make Slicer.slice promise
This commit is contained in:
parent
38a3c312e2
commit
c6a9d5adb8
@ -11,7 +11,6 @@ const geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
|||||||
const slicer = new SLICER.Slicer();
|
const slicer = new SLICER.Slicer();
|
||||||
|
|
||||||
slicer.setGeometry(geometry);
|
slicer.setGeometry(geometry);
|
||||||
slicer.addEventListener('finish', ({ gcode }) => {
|
const gcode = slicer.slice(settings).then(gcode => {
|
||||||
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
document.getElementById('gcode').innerHTML = gcode.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
||||||
});
|
});
|
||||||
slicer.slice(settings);
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
import THREE from 'three.js';
|
import THREE from 'three.js';
|
||||||
import EventDispatcher from 'EventDispatcher';
|
import slice from './sliceActions/index.js';
|
||||||
import calculateLayersIntersections from './sliceActions/calculateLayersIntersections.js';
|
|
||||||
import createLines from './sliceActions/createLines.js';
|
|
||||||
import generateInfills from './sliceActions/generateInfills.js';
|
|
||||||
import generateInnerLines from './sliceActions/generateInnerLines.js';
|
|
||||||
import generateSupport from './sliceActions/generateSupport.js';
|
|
||||||
import intersectionsToShapes from './sliceActions/intersectionsToShapes.js';
|
|
||||||
import addBrim from './sliceActions/addBrim.js';
|
|
||||||
import optimizePaths from './sliceActions/optimizePaths.js';
|
|
||||||
import shapesToSlices from './sliceActions/shapesToSlices.js';
|
|
||||||
import slicesToGCode from './sliceActions/slicesToGCode.js';
|
|
||||||
import applyPrecision from './sliceActions/applyPrecision.js';
|
|
||||||
import removePrecision from './sliceActions/removePrecision.js';
|
|
||||||
|
|
||||||
export default class extends EventDispatcher {
|
export default class {
|
||||||
setMesh(mesh) {
|
setMesh(mesh) {
|
||||||
mesh.updateMatrix();
|
mesh.updateMatrix();
|
||||||
|
|
||||||
@ -41,31 +29,7 @@ export default class extends EventDispatcher {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
slice(settings) {
|
async slice(settings) {
|
||||||
// get unique lines from geometry;
|
return slice(this.geometry, settings);
|
||||||
const lines = createLines(this.geometry, settings);
|
|
||||||
|
|
||||||
const {
|
|
||||||
layerIntersectionIndexes,
|
|
||||||
layerIntersectionPoints
|
|
||||||
} = calculateLayersIntersections(lines, settings);
|
|
||||||
|
|
||||||
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
|
|
||||||
|
|
||||||
applyPrecision(shapes);
|
|
||||||
|
|
||||||
const slices = shapesToSlices(shapes, settings);
|
|
||||||
|
|
||||||
generateInnerLines(slices, settings);
|
|
||||||
generateInfills(slices, settings);
|
|
||||||
generateSupport(slices, settings);
|
|
||||||
addBrim(slices, settings);
|
|
||||||
optimizePaths(slices, settings);
|
|
||||||
removePrecision(slices);
|
|
||||||
|
|
||||||
const gcode = slicesToGCode(slices, settings);
|
|
||||||
|
|
||||||
this.dispatchEvent({ type: 'finish', gcode });
|
|
||||||
return gcode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { PRECISION } from '../constants.js'
|
import { PRECISION } from '../constants.js'
|
||||||
import getFillTemplate from '../getFillTemplate.js';
|
import getFillTemplate from './getFillTemplate.js';
|
||||||
import Shape from 'Doodle3D/clipper-js';
|
import Shape from 'Doodle3D/clipper-js';
|
||||||
|
|
||||||
export default function generateInfills(slices, settings) {
|
export default function generateInfills(slices, settings) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import getFillTemplate from '../getFillTemplate.js';
|
import getFillTemplate from './getFillTemplate.js';
|
||||||
import Shape from 'Doodle3D/clipper-js';
|
import Shape from 'Doodle3D/clipper-js';
|
||||||
import { PRECISION } from '../constants.js';
|
import { PRECISION } from '../constants.js';
|
||||||
|
|
||||||
|
39
src/sliceActions/index.js
Normal file
39
src/sliceActions/index.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import calculateLayersIntersections from './calculateLayersIntersections.js';
|
||||||
|
import createLines from './createLines.js';
|
||||||
|
import generateInfills from './generateInfills.js';
|
||||||
|
import generateInnerLines from './generateInnerLines.js';
|
||||||
|
import generateSupport from './generateSupport.js';
|
||||||
|
import intersectionsToShapes from './intersectionsToShapes.js';
|
||||||
|
import addBrim from './addBrim.js';
|
||||||
|
import optimizePaths from './optimizePaths.js';
|
||||||
|
import shapesToSlices from './shapesToSlices.js';
|
||||||
|
import slicesToGCode from './slicesToGCode.js';
|
||||||
|
import applyPrecision from './applyPrecision.js';
|
||||||
|
import removePrecision from './removePrecision.js';
|
||||||
|
|
||||||
|
export default function(geometry, settings) {
|
||||||
|
// get unique lines from geometry;
|
||||||
|
const lines = createLines(geometry, settings);
|
||||||
|
|
||||||
|
const {
|
||||||
|
layerIntersectionIndexes,
|
||||||
|
layerIntersectionPoints
|
||||||
|
} = calculateLayersIntersections(lines, settings);
|
||||||
|
|
||||||
|
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
|
||||||
|
|
||||||
|
applyPrecision(shapes);
|
||||||
|
|
||||||
|
const slices = shapesToSlices(shapes, settings);
|
||||||
|
|
||||||
|
generateInnerLines(slices, settings);
|
||||||
|
generateInfills(slices, settings);
|
||||||
|
generateSupport(slices, settings);
|
||||||
|
addBrim(slices, settings);
|
||||||
|
optimizePaths(slices, settings);
|
||||||
|
removePrecision(slices);
|
||||||
|
|
||||||
|
const gcode = slicesToGCode(slices, settings);
|
||||||
|
|
||||||
|
return gcode;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user