diff --git a/src/kiri/core/print.js b/src/kiri/core/print.js index 6be1665d..848229f3 100644 --- a/src/kiri/core/print.js +++ b/src/kiri/core/print.js @@ -88,7 +88,7 @@ class Print { } output.appendAll(input); } - + /** * Prints a polygon to a given output array, possibly with a given extrude factor, * and starting from a given point. The last point is returned. diff --git a/src/kiri/mode/cam/export.js b/src/kiri/mode/cam/export.js index 04a8bdb3..a8354161 100644 --- a/src/kiri/mode/cam/export.js +++ b/src/kiri/mode/cam/export.js @@ -234,7 +234,7 @@ export function cam_export(print, online) { // speed: Infinity, tool: out.tool, point: { x: newpos.x, y: newpos.y, z: newpos.z, a: pos.a }, - emit: 1, + emit: out.emit, }, { dx: 1, dy: 1, dz: 0, time: 0 }); @@ -251,7 +251,7 @@ export function cam_export(print, online) { // speed: Infinity, tool: out.tool, point: { x: newpos.x, y: newpos.y, z: newpos.z, a: newpos.a }, - emit: 1 + emit: out.emit }, { dx: 0, dy: 0, dz: 1, time: 0 }); diff --git a/src/kiri/mode/cam/prepare.js b/src/kiri/mode/cam/prepare.js index 7ad44092..7faa3e21 100644 --- a/src/kiri/mode/cam/prepare.js +++ b/src/kiri/mode/cam/prepare.js @@ -393,8 +393,19 @@ export function prepEach(widget, settings, print, firstPoint, update) { let deltaXY = lastPoint.distTo2D(point), deltaZ = point.z - lastPoint.z, absDeltaZ = Math.abs(deltaZ), + hasDelta = deltaXY >= 0.001 && absDeltaZ >= 0, isMove = emit == 0; + // when rapid pluge could cut thru stock, rapid to just above stock + // then continue plunge as a plunge cut + if (deltaZ < 0 && lastPoint.z > stockz && point.z < stockz && emit === 0) { + // console.log('detected plunge cut as rapid move', lastPoint.z, point.z); + let above = point.clone().setZ(stockz + 0.1); + layerPush(above, 0, 0, tool); + // change to cutting move for remainder of plunge + emit = 1; + } + // drop points too close together if (!isLathe && !isArc && deltaXY < 0.001 && point.z === lastPoint.z) { // console.trace(["drop dup",lastPoint,point]); @@ -402,7 +413,7 @@ export function prepEach(widget, settings, print, firstPoint, update) { } // convert short planar moves to cuts in some cases - if (!isRough && !isArc && isMove && deltaXY <= moveLen && deltaZ <= 0 && !lasering) { + if (hasDelta && !isRough && !isArc && isMove && deltaXY <= moveLen && deltaZ <= 0 && !lasering) { let iscontour = tolerance > 0; let isflat = absDeltaZ < 0.001; // restrict this to contouring @@ -718,8 +729,6 @@ export function prepEach(widget, settings, print, firstPoint, update) { function emitTrace(slice) { let { tool, rate, plunge } = slice.camTrace; setTool(tool, rate, plunge); - let traceTool = new Tool(settings, tool); - let traceToolDiam = traceTool.fluteDiameter(); printPoint = poly2polyEmit(slice.camLines, printPoint, polyEmit, { swapdir: false, weight: innerFirst @@ -743,7 +752,7 @@ export function prepEach(widget, settings, print, firstPoint, update) { * @param {boolean} ops.cutFromLast - whether to emit a 1 when moving from last point. Defaults to false * @returns {Point} - the last point of the polygon */ - function polyEmit(poly, index, count, fromPoint,ops) { + function polyEmit(poly, index, count, fromPoint, ops) { let { cutFromLast, } = ops ?? { @@ -855,7 +864,6 @@ export function prepEach(widget, settings, print, firstPoint, update) { radFault = Math.abs(angle) > arcRes if (radFault) { // if so, remove first point - console.log("secondary radfault,",structuredClone(arcQ),{angle,arcRes,a,b}) camOut(arcQ.shift(), 1) } diff --git a/src/mesh/api.js b/src/mesh/api.js index 75bc7381..baf7fe78 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -1392,14 +1392,15 @@ const prefs = { scale_group_Z: true }, space: { + bounds: false, + center: false, + dark: false, + floor: false, + grid: true, + select: [], snap: 1, snapon: false, - center: false, - floor: false, - wire: false, - grid: true, - dark: false, - select: [] + wire: false }, sketch: { open_close: false,