Major routing improvements: - Refactor depth-first routing algorithm for better path optimization - Reimplemented outline, roughing, pocket, and trace as area operation wrappers - Add pocket shadow travel routing with optimized descent using travel bounds - Improve contour routing with arc detection and polyEmit arc strategy - Add area smoothing and ease-down options - Fix outline handling with thru holes and surface reversal on tip2tip - Move widget shadow methods into widget class for faster hole detection - Better camInnerFirst support and proper feed/plunge defaults Tool system improvements: - Implement taper ball tool type with full support - Add renderTool2() for profile-based visualization - Convert tool menu to init code with bound vars - Fix auto tool and auto spindle for prep operations - Update tool profile generation for taperball geometry - Add calcTaperBallExtent() for proper ball tangency calculations Code cleanup: - Remove duplicated slicer code from specialized slicers - Asyncify shadowAt operations - Deprecate pocket engrave operation - Simplify upNover implementation - Fix animation with new tool+settings requirements
74 lines
2.2 KiB
JavaScript
74 lines
2.2 KiB
JavaScript
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
|
|
|
import { CamOp } from './op.js';
|
|
import { Tool } from './tool.js';
|
|
import { newPolygon } from '../../../geo/polygon.js';
|
|
import { newSlice } from '../../core/slice.js';
|
|
import { newPoint } from '../../../geo/point.js';
|
|
|
|
class OpDrill extends CamOp {
|
|
constructor(state, op) {
|
|
super(state, op);
|
|
}
|
|
|
|
async slice(progress) {
|
|
let { op, state } = this;
|
|
let { settings, addSlices, widget, updateToolDiams } = state;
|
|
let { color } = state;
|
|
let { drills } = op
|
|
|
|
let drillTool = new Tool(settings, op.tool),
|
|
drillToolDiam = drillTool.fluteDiameter(),
|
|
sliceOut = this.sliceOut = [];
|
|
|
|
const allDrills = drills[widget.id] ?? []
|
|
if (allDrills.length === 0) return;
|
|
|
|
updateToolDiams(drillToolDiam);
|
|
|
|
// drill points to use center (average of all points) of the polygon
|
|
allDrills.forEach((drill) => {
|
|
if (!drill.selected) {
|
|
return
|
|
}
|
|
|
|
let slice = newSlice(0);
|
|
if (op.mark) {
|
|
// replace depth with single down peck
|
|
drill.depth = op.down
|
|
}
|
|
|
|
drill.zBottom = drill.z - drill.depth;
|
|
// for thru holes, follow z thru when set
|
|
if ((op.thru > 0)) {
|
|
drill.zBottom -= op.thru;
|
|
}
|
|
|
|
const poly = newPolygon()
|
|
poly.points.push(newPoint(drill.x, drill.y, drill.z))
|
|
poly.points.push(newPoint(drill.x, drill.y, drill.zBottom))
|
|
|
|
slice.camTrace = { tool: op.tool, rate: op.feed, plunge: op.rate };
|
|
slice.camLines = [poly];
|
|
slice.output()
|
|
.setLayer(state.layername, { face: color, line: color })
|
|
.addPolys(slice.camLines);
|
|
|
|
addSlices(slice);
|
|
sliceOut.push(slice);
|
|
});
|
|
}
|
|
|
|
prepare(ops, progress) {
|
|
let { op, sliceOut } = this;
|
|
let { setTool, setSpindle, setDrill, emitDrills } = ops;
|
|
|
|
if (sliceOut.length === 0) return;
|
|
|
|
setTool(op.tool, undefined, op.rate);
|
|
setDrill(op.down, op.lift, op.dwell);
|
|
emitDrills(sliceOut.map(slice => slice.camLines).flat());
|
|
}
|
|
}
|
|
|
|
export { OpDrill };
|