fix ctrl click to select planar matching lines
This commit is contained in:
parent
220dc7c439
commit
05a9bca485
2 changed files with 15 additions and 1 deletions
|
|
@ -1006,6 +1006,19 @@ class Polygon {
|
|||
return Math.min(...this.points.map(p => p.z));
|
||||
}
|
||||
|
||||
avgZ() {
|
||||
return [...this.points.map(p => p.z)].reduce((a,v) => a+v) / this.points.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} z value target
|
||||
* @param {*} epsilon allowed Z variance
|
||||
* @returns {boolean} true if all points Z within epsilon of value
|
||||
*/
|
||||
onZ(z, epsilon = 10e-4) {
|
||||
return Math.max(...this.points.map(p => Math.abs(z - p.z))) < epsilon;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
render(layer, color, recursive, open) {
|
||||
|
|
|
|||
|
|
@ -1128,8 +1128,9 @@ CAM.init = function(kiri, api) {
|
|||
if (ev.metaKey || ev.ctrlKey) {
|
||||
let { selected } = object;
|
||||
let { widget, poly } = object.trace;
|
||||
let avgZ = poly.avgZ();
|
||||
for (let add of widget.adds) {
|
||||
if (add.trace && add.selected !== selected && add.trace.poly.getZ() === poly.getZ()) {
|
||||
if (add.trace && add.selected !== selected && add.trace.poly.onZ(avgZ)) {
|
||||
func.traceToggle(add);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue