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 polygon around origin
|
||||||
*/
|
*/
|
||||||
scale(scale, round) {
|
scale(scale, round) {
|
||||||
|
this.area2 = undefined;
|
||||||
let x, y, z;
|
let x, y, z;
|
||||||
if (typeof(scale) === 'number') {
|
if (typeof(scale) === 'number') {
|
||||||
x = y = z = scale;
|
x = y = z = scale;
|
||||||
|
|
@ -1073,6 +1074,7 @@ export class Polygon {
|
||||||
* append point to polygon and return point
|
* append point to polygon and return point
|
||||||
*/
|
*/
|
||||||
push(p) {
|
push(p) {
|
||||||
|
this.area2 = undefined;
|
||||||
// clone any point belonging to another polygon
|
// clone any point belonging to another polygon
|
||||||
if (p.poly) p = p.clone();
|
if (p.poly) p = p.clone();
|
||||||
p.poly = this;
|
p.poly = this;
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ export function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
||||||
|
|
||||||
function filter(from, to = []) {
|
function filter(from, to = []) {
|
||||||
from.forEach(function(poly) {
|
from.forEach(function(poly) {
|
||||||
if (poly.area() >= min) {
|
if (poly.area() >= min && poly.length > 2) {
|
||||||
to.push(poly);
|
to.push(poly);
|
||||||
out.push(poly);
|
out.push(poly);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -421,8 +421,13 @@ function newDiv(opt = {}) {
|
||||||
(opt.addto || addTo).appendChild(div);
|
(opt.addto || addTo).appendChild(div);
|
||||||
if (opt.addto) lastDiv = addTo = div;
|
if (opt.addto) lastDiv = addTo = div;
|
||||||
if (opt.class) div.setAttribute('class', opt.class);
|
if (opt.class) div.setAttribute('class', opt.class);
|
||||||
|
if (opt.group !== false) {
|
||||||
lastGroup?.push(div);
|
lastGroup?.push(div);
|
||||||
div._group = groupName;
|
div._group = groupName;
|
||||||
|
} else {
|
||||||
|
lastGroup = undefined;
|
||||||
|
groupName = undefined;
|
||||||
|
}
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ export function createPopOp(type, map) {
|
||||||
return op.rec === rec;
|
return op.rec === rec;
|
||||||
},
|
},
|
||||||
bind: (ev) => {
|
bind: (ev) => {
|
||||||
console.log({ bind: type, map, op });
|
|
||||||
api.util.ui2rec(op.rec, op.inputs);
|
api.util.ui2rec(op.rec, op.inputs);
|
||||||
|
|
||||||
const settings = conf.get();
|
const settings = conf.get();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export function menu() {
|
||||||
/** Animation Bar */
|
/** Animation Bar */
|
||||||
|
|
||||||
_____: {
|
_____: {
|
||||||
_____: newDiv({ addto: $('layer-animate'), set:true }),
|
_____: newDiv({ addto: $('layer-animate'), set:true, group:false }),
|
||||||
row: newRow([
|
row: newRow([
|
||||||
anim.replay = newButton(null,"anim.replay",{icon:'<i class="fas fa-fast-backward"></i>',title:"restart"}),
|
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"}),
|
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) {
|
for (let z of zs) {
|
||||||
let clip = [], shadow;
|
let clip = [], shadow;
|
||||||
shadow = shadowAt(z);
|
shadow = shadowAt(z);
|
||||||
|
// 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);
|
POLY.subtract([ poly ], shadow, clip, undefined, undefined, 0);
|
||||||
|
}
|
||||||
if (op.outline) {
|
if (op.outline) {
|
||||||
POLY.clearInner(clip);
|
POLY.clearInner(clip);
|
||||||
}
|
}
|
||||||
if (clip.length === 0) {
|
if (clip.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let slice = newSliceOut(z);
|
|
||||||
let count = 999;
|
let count = 999;
|
||||||
|
let slice = newSliceOut(z);
|
||||||
slice.camTrace = { tool, rate, plunge };
|
slice.camTrace = { tool, rate, plunge };
|
||||||
if (toolDiam) {
|
if (toolDiam) {
|
||||||
const offs = [ -toolDiam / 2, -toolOver ];
|
const offs = [ -toolDiam / 2, -toolOver ];
|
||||||
|
|
@ -132,12 +145,15 @@ class OpTrace extends CamOp {
|
||||||
slice.camLines = POLY.flatten(slice.camLines, null, true);
|
slice.camLines = POLY.flatten(slice.camLines, null, true);
|
||||||
}
|
}
|
||||||
POLY.setWinding(slice.camLines, cutdir, false);
|
POLY.setWinding(slice.camLines, cutdir, false);
|
||||||
slice.output()
|
|
||||||
.setLayer("trace", {line: color}, false)
|
|
||||||
.addPolys(slice.camLines)
|
|
||||||
if (debug && shadow) slice.output()
|
if (debug && shadow) slice.output()
|
||||||
.setLayer("trace shadow", {line: 0xff8811}, false)
|
.setLayer("trace shadow", {line: 0xff8811}, false)
|
||||||
.addPolys(shadow)
|
.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");
|
progress(zpro, "trace");
|
||||||
zpro += zinc;
|
zpro += zinc;
|
||||||
addSlices(slice);
|
addSlices(slice);
|
||||||
|
|
@ -254,6 +270,7 @@ class OpTrace extends CamOp {
|
||||||
case "clear":
|
case "clear":
|
||||||
const zbo = widget.track.top - widget.track.box.d;
|
const zbo = widget.track.top - widget.track.box.d;
|
||||||
let zmap = {};
|
let zmap = {};
|
||||||
|
polys = POLY.nest(polys);
|
||||||
for (let poly of polys) {
|
for (let poly of polys) {
|
||||||
let z = minZ(poly.minZ());
|
let z = minZ(poly.minZ());
|
||||||
if (offover) {
|
if (offover) {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
}
|
}
|
||||||
feedRate = feed || feedRate || plunge;
|
feedRate = feed || feedRate || plunge;
|
||||||
plungeRate = Math.min(feedRate || plunge, plunge || plungeRate || feedRate);
|
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) {
|
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);
|
.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;
|
return polys;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue