mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-27 13:23:49 +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();
|
||||
|
||||
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 />');
|
||||
});
|
||||
slicer.slice(settings);
|
||||
|
@ -1,19 +1,7 @@
|
||||
import THREE from 'three.js';
|
||||
import EventDispatcher from 'EventDispatcher';
|
||||
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';
|
||||
import slice from './sliceActions/index.js';
|
||||
|
||||
export default class extends EventDispatcher {
|
||||
export default class {
|
||||
setMesh(mesh) {
|
||||
mesh.updateMatrix();
|
||||
|
||||
@ -41,31 +29,7 @@ export default class extends EventDispatcher {
|
||||
|
||||
return this;
|
||||
}
|
||||
slice(settings) {
|
||||
// get unique lines from geometry;
|
||||
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;
|
||||
async slice(settings) {
|
||||
return slice(this.geometry, settings);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { PRECISION } from '../constants.js'
|
||||
import getFillTemplate from '../getFillTemplate.js';
|
||||
import getFillTemplate from './getFillTemplate.js';
|
||||
import Shape from 'Doodle3D/clipper-js';
|
||||
|
||||
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 { 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