apply widget movement to arc points
This commit is contained in:
parent
f62a9970b2
commit
1ac1dd9228
1 changed files with 22 additions and 7 deletions
|
|
@ -317,6 +317,20 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a point by the widget's movement offset.
|
||||||
|
* @param {Point} p - point to move
|
||||||
|
* @return {Point} new point with offset applied
|
||||||
|
*/
|
||||||
|
function applyWidgetMovement(p){
|
||||||
|
return newPoint(
|
||||||
|
p.x + wmx,
|
||||||
|
p.y + wmy,
|
||||||
|
p.z + zadd
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emit a cut, arc, or move operation from the current location to a new location
|
* emit a cut, arc, or move operation from the current location to a new location
|
||||||
* @param {Point} point destination for move
|
* @param {Point} point destination for move
|
||||||
|
|
@ -338,10 +352,8 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
// console.log({radius})
|
// console.log({radius})
|
||||||
const isArc = emit == 2 || emit == 3;
|
const isArc = emit == 2 || emit == 3;
|
||||||
|
|
||||||
point = point.clone();
|
//apply widget movement pos
|
||||||
point.x += wmx;
|
point = applyWidgetMovement(point);
|
||||||
point.y += wmy;
|
|
||||||
point.z += zadd;
|
|
||||||
|
|
||||||
// console.log(point.z);
|
// console.log(point.z);
|
||||||
if (nextIsMove) {
|
if (nextIsMove) {
|
||||||
|
|
@ -848,13 +860,14 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
} else {
|
} else {
|
||||||
arcQ.center = [ tc ];
|
arcQ.center = [ tc ];
|
||||||
let angle = 2 * Math.asin(arcQ[1].dist/(2*tc.r));
|
let angle = 2 * Math.asin(arcQ[1].dist/(2*tc.r));
|
||||||
if (Math.abs(angle) > Math.PI * 2 / arcRes) { // enforce arcRes on initial angle
|
if (Math.abs(angle) > arcRes) { // enforce arcRes on initial angle
|
||||||
camOut(arcQ.shift(),1);
|
camOut(arcQ.shift(),1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// enough to consider an arc, emit and start new arc
|
// enough to consider an arc, emit and start new arc
|
||||||
let defer = arcQ.pop();
|
let defer = arcQ.pop();
|
||||||
|
console.log("draining",defer, structuredClone(arcQ),arcQ.length);
|
||||||
drainQ();
|
drainQ();
|
||||||
// re-add point that was off the last arc
|
// re-add point that was off the last arc
|
||||||
arcQ.push(defer);
|
arcQ.push(defer);
|
||||||
|
|
@ -915,13 +928,15 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
//if is a circle
|
//if is a circle
|
||||||
// generate circle
|
// generate circle
|
||||||
// console.log("circle",{from, to,center});
|
// console.log("circle",{from, to,center});
|
||||||
let arcPoints = arcToPath( from, from, arcPreviewRes,{ clockwise,center});
|
let arcPoints = arcToPath( from, from, arcPreviewRes,{ clockwise,center})
|
||||||
|
.map(applyWidgetMovement);
|
||||||
camOut(from,1);
|
camOut(from,1);
|
||||||
camOut(from,gc,{ center:center.sub(from), clockwise, arcPoints});
|
camOut(from,gc,{ center:center.sub(from), clockwise, arcPoints});
|
||||||
lastPoint = from.clone();
|
lastPoint = from.clone();
|
||||||
}else{
|
}else{
|
||||||
//if a non-circle arc
|
//if a non-circle arc
|
||||||
let arcPoints = arcToPath( from, to, arcPreviewRes,{ clockwise,center});
|
let arcPoints = arcToPath( from, to, arcPreviewRes,{ clockwise,center})
|
||||||
|
.map(applyWidgetMovement);
|
||||||
// console.log("arc")
|
// console.log("arc")
|
||||||
// first arc point
|
// first arc point
|
||||||
camOut(from,1);
|
camOut(from,1);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue