CAM routing refactor, area operation, and taper ball tool implementation

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
This commit is contained in:
Stewart Allen 2025-12-06 00:09:17 -05:00
commit e0b1c4e31f
44 changed files with 1607 additions and 2894 deletions

View file

@ -12,6 +12,7 @@ let nextMeshID = 1,
tool,
tools,
last,
settings,
stockZ,
stockIndexMsg = false,
stockSlices,
@ -34,10 +35,10 @@ export function init(worker) {
const { dispatch } = worker;
dispatch.animate_setup2 = function (data, send) {
const { settings } = data;
settings = data.settings;
const { controller, process } = settings;
const print = worker.current.print;
const density = parseInt(settings.controller.animesh) * 1000;
const { print } = worker.current;
const isIndexed = process.camStockIndexed;
pathIndex = 0;
@ -141,7 +142,7 @@ function renderPath(send) {
}
const id = toolID;
const rezstep = Math.min(tool.maxDiameter(), 1) / 4;
const rezstep = tool ? Math.min(tool.maxDiameter(), 1) / 4 : 1;
// console.log({ rezstep });
if (last) {
@ -273,7 +274,7 @@ function toolUpdate(toolid, send) {
if (tool) {
send.data({ mesh_del: toolID });
}
tool = new Tool({ tools }, toolid);
tool = new Tool(settings, toolid);
const Instance = CSG.Instance();
const slen = tool.shaftLength() || 15;
const srad = tool.shaftDiameter() / 2;
@ -286,6 +287,16 @@ function toolUpdate(toolid, send) {
mesh = cylinder(tlen - frad * 2, frad, frad, 20, true)
.add(sphere(frad, 20).translate(0, 0, -(tlen - frad * 2) / 2))
.add(cylinder(slen, srad, srad, 20, true).translate(0, 0, flen / 2));
} else if (tool.isTaperBall()) {
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
const brad = trad; // ball radius equals tip radius
const taperLen = flen - brad; // taper length excludes ball
// shaft at top
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen / 2)
// taper cone in middle
.add(cylinder(taperLen, trad, frad, 20, true).translate(0, 0, -taperLen / 2))
// ball at bottom
.add(sphere(brad, 20).translate(0, 0, -(taperLen + brad)));
} else if (tool.isTaperMill()) {
const trad = Math.max(tool.tipDiameter() / 2, 0.001);
mesh = cylinder(slen, srad, srad, 20, true).translate(0, 0, slen / 2)