diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 4aece2c3..8cc0f14d 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -843,6 +843,7 @@ export class Polygon { * scale polygon around origin */ scale(scale, round) { + this.area2 = undefined; let x, y, z; if (typeof(scale) === 'number') { x = y = z = scale; @@ -1073,6 +1074,7 @@ export class Polygon { * append point to polygon and return point */ push(p) { + this.area2 = undefined; // clone any point belonging to another polygon if (p.poly) p = p.clone(); p.poly = this; diff --git a/src/geo/polygons.js b/src/geo/polygons.js index 07cea123..6d4d8128 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -359,7 +359,7 @@ export function subtract(setA, setB, outA, outB, z, minArea, opt = {}) { function filter(from, to = []) { from.forEach(function(poly) { - if (poly.area() >= min) { + if (poly.area() >= min && poly.length > 2) { to.push(poly); out.push(poly); } diff --git a/src/kiri/core/ui.js b/src/kiri/core/ui.js index bb665d31..a31e41ec 100644 --- a/src/kiri/core/ui.js +++ b/src/kiri/core/ui.js @@ -421,8 +421,13 @@ function newDiv(opt = {}) { (opt.addto || addTo).appendChild(div); if (opt.addto) lastDiv = addTo = div; if (opt.class) div.setAttribute('class', opt.class); - lastGroup?.push(div); - div._group = groupName; + if (opt.group !== false) { + lastGroup?.push(div); + div._group = groupName; + } else { + lastGroup = undefined; + groupName = undefined; + } return div; } diff --git a/src/kiri/mode/cam/cl-ops.js b/src/kiri/mode/cam/cl-ops.js index d3559a2d..d4c63b6d 100644 --- a/src/kiri/mode/cam/cl-ops.js +++ b/src/kiri/mode/cam/cl-ops.js @@ -95,7 +95,6 @@ export function createPopOp(type, map) { return op.rec === rec; }, bind: (ev) => { - console.log({ bind: type, map, op }); api.util.ui2rec(op.rec, op.inputs); const settings = conf.get(); diff --git a/src/kiri/mode/cam/init-menu.js b/src/kiri/mode/cam/init-menu.js index 0b62759b..40faf9f7 100644 --- a/src/kiri/mode/cam/init-menu.js +++ b/src/kiri/mode/cam/init-menu.js @@ -37,7 +37,7 @@ export function menu() { /** Animation Bar */ _____: { - _____: newDiv({ addto: $('layer-animate'), set:true }), + _____: newDiv({ addto: $('layer-animate'), set:true, group:false }), row: newRow([ anim.replay = newButton(null,"anim.replay",{icon:'',title:"restart"}), anim.play = newButton(null,"anim.play",{icon:'',title:"play"}), diff --git a/src/kiri/mode/cam/op-trace.js b/src/kiri/mode/cam/op-trace.js index ab83409e..6ec46dba 100644 --- a/src/kiri/mode/cam/op-trace.js +++ b/src/kiri/mode/cam/op-trace.js @@ -107,15 +107,28 @@ class OpTrace extends CamOp { for (let z of zs) { let clip = [], shadow; shadow = shadowAt(z); - POLY.subtract([ poly ], shadow, clip, undefined, undefined, 0); + // for cases where the shadow IS the poly like + // with lettering without a bounding frame, clip + // will fail and we need to restore the matching poly + let subshadow = true; + for (let spo of shadow) { + if (poly.isInside(spo, 0.01)) { + subshadow = false; + clip = [ poly ]; + break; + } + } + if (subshadow) { + POLY.subtract([ poly ], shadow, clip, undefined, undefined, 0); + } if (op.outline) { POLY.clearInner(clip); } if (clip.length === 0) { continue; } - let slice = newSliceOut(z); let count = 999; + let slice = newSliceOut(z); slice.camTrace = { tool, rate, plunge }; if (toolDiam) { const offs = [ -toolDiam / 2, -toolOver ]; @@ -132,12 +145,15 @@ class OpTrace extends CamOp { slice.camLines = POLY.flatten(slice.camLines, null, true); } POLY.setWinding(slice.camLines, cutdir, false); - slice.output() - .setLayer("trace", {line: color}, false) - .addPolys(slice.camLines) if (debug && shadow) slice.output() .setLayer("trace shadow", {line: 0xff8811}, false) .addPolys(shadow) + if (debug) slice.output() + .setLayer("trace poly", {line: 0x1188ff}, false) + .addPolys([ poly ]) + slice.output() + .setLayer("trace", {line: color}, false) + .addPolys(slice.camLines) progress(zpro, "trace"); zpro += zinc; addSlices(slice); @@ -254,6 +270,7 @@ class OpTrace extends CamOp { case "clear": const zbo = widget.track.top - widget.track.box.d; let zmap = {}; + polys = POLY.nest(polys); for (let poly of polys) { let z = minZ(poly.minZ()); if (offover) { diff --git a/src/kiri/mode/cam/prepare.js b/src/kiri/mode/cam/prepare.js index cf7b5ea4..b54b9feb 100644 --- a/src/kiri/mode/cam/prepare.js +++ b/src/kiri/mode/cam/prepare.js @@ -177,7 +177,7 @@ export function prepEach(widget, settings, print, firstPoint, update) { } feedRate = feed || feedRate || plunge; plungeRate = Math.min(feedRate || plunge, plunge || plungeRate || feedRate); - console.log({ setTool: toolID, feed, plunge, plungeRate }); + // console.log({ setTool: toolID, feed, plunge, plungeRate }); } function setLasering(bool, power = 0) { diff --git a/src/kiri/mode/cam/slice.js b/src/kiri/mode/cam/slice.js index 174bdf23..c23b1786 100644 --- a/src/kiri/mode/cam/slice.js +++ b/src/kiri/mode/cam/slice.js @@ -801,7 +801,7 @@ export function computeShadowAt(widget, z, ztop) { .add(a[2].x, a[2].y, a[2].z); }); - polys = POLY.union(polys, 0.001, true); + polys = POLY.union(polys, 0, true); return polys; }