clamp single trace to z top/bottom
This commit is contained in:
parent
f59a2ea021
commit
8bca0a949a
2 changed files with 16 additions and 2 deletions
|
|
@ -207,7 +207,7 @@ class OpArea extends CamOp {
|
||||||
} else
|
} else
|
||||||
if (mode === 'trace') {
|
if (mode === 'trace') {
|
||||||
let { tr_type } = op;
|
let { tr_type } = op;
|
||||||
let zs = down ? base_util.lerp(zTop, bounds.min.z, down) : [ bounds.min.z ];
|
let zs = down ? base_util.lerp(zTop, zBottom, down) : [ bounds.min.z ];
|
||||||
let zroc = 0;
|
let zroc = 0;
|
||||||
let zinc = 1 / zs.length;
|
let zinc = 1 / zs.length;
|
||||||
for (let z of zs) {
|
for (let z of zs) {
|
||||||
|
|
@ -217,7 +217,7 @@ class OpArea extends CamOp {
|
||||||
if (tr_type === 'none') {
|
if (tr_type === 'none') {
|
||||||
// todo: move this out of the zs loop and only setZ when needed
|
// todo: move this out of the zs loop and only setZ when needed
|
||||||
area = area.clone(true);
|
area = area.clone(true);
|
||||||
outs = [ zs.length > 1 ? area.setZ(z) : area ];
|
outs = [ zs.length > 1 ? area.setZ(z) : clampZ(area, zTop, zBottom) ];
|
||||||
} else {
|
} else {
|
||||||
// todo: move this out of the zs loop
|
// todo: move this out of the zs loop
|
||||||
POLY.offset([ area ], tr_type === 'inside' ? [ -toolDiam / 2 ] : [ toolDiam / 2 ], {
|
POLY.offset([ area ], tr_type === 'inside' ? [ -toolDiam / 2 ] : [ toolDiam / 2 ], {
|
||||||
|
|
@ -396,6 +396,19 @@ class OpArea extends CamOp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clampZ(poly, min, max) {
|
||||||
|
for (let p of poly.points) {
|
||||||
|
if (p.z < min) p.z = min;
|
||||||
|
else if (p.z > max) p.z = max;
|
||||||
|
}
|
||||||
|
if (poly.inner) {
|
||||||
|
for (let poly of poly.inner) {
|
||||||
|
clampZ(poly, min, max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return poly;
|
||||||
|
}
|
||||||
|
|
||||||
// box2: THREE.Box2
|
// box2: THREE.Box2
|
||||||
// angle: radians (direction of each scan ray)
|
// angle: radians (direction of each scan ray)
|
||||||
// step: spacing between parallel rays (world units)
|
// step: spacing between parallel rays (world units)
|
||||||
|
|
|
||||||
|
|
@ -454,6 +454,7 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
||||||
if (isMove && deltaXY <= shortCut && deltaZ <= 0 && !lasering) {
|
if (isMove && deltaXY <= shortCut && deltaZ <= 0 && !lasering) {
|
||||||
// but only if the z plunge is not too far
|
// but only if the z plunge is not too far
|
||||||
if (absDeltaZ < 0.01 || (tolerance > 0 && absDeltaZ <= tolerance)) {
|
if (absDeltaZ < 0.01 || (tolerance > 0 && absDeltaZ <= tolerance)) {
|
||||||
|
if (debug) console.log('shortcut', { deltaXY, deltaZ, shortCut });
|
||||||
emit = 1;
|
emit = 1;
|
||||||
} else
|
} else
|
||||||
// otherwise move over before descending
|
// otherwise move over before descending
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue