fix nested trace elements when clearing (poly area bug), fix shadowZ poly union, fix hidden cam animate
This commit is contained in:
parent
e967fd3b2f
commit
7d3b210ed9
8 changed files with 35 additions and 12 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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:'<i class="fas fa-fast-backward"></i>',title:"restart"}),
|
||||
anim.play = newButton(null,"anim.play",{icon:'<i class="fas fa-play"></i>',title:"play"}),
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue