fix bugs with latent stock settings, first and print point for multi-widget slice in cam
This commit is contained in:
parent
64b8290abe
commit
5ba15bc4af
3 changed files with 43 additions and 38 deletions
|
|
@ -1089,32 +1089,35 @@ var gs_kiri_cam = exports;
|
||||||
* @param {Object} [firstPoint] starting point
|
* @param {Object} [firstPoint] starting point
|
||||||
*/
|
*/
|
||||||
function printSetup(print, update, index, firstPoint) {
|
function printSetup(print, update, index, firstPoint) {
|
||||||
|
let widgetIndex = index || 0,
|
||||||
|
widgetArray = print.widgets,
|
||||||
|
widgetCount = widgetArray.length,
|
||||||
|
widget = widgetArray[widgetIndex];
|
||||||
|
|
||||||
|
if (widgetIndex >= widgetCount || !widget) return;
|
||||||
|
|
||||||
let getTool = getToolById,
|
let getTool = getToolById,
|
||||||
settings = print.settings,
|
settings = print.settings,
|
||||||
device = settings.device,
|
device = settings.device,
|
||||||
process = settings.process,
|
process = settings.process,
|
||||||
stock = settings.stock,
|
stock = settings.stock,
|
||||||
outer = settings.bounds,
|
outer = settings.bounds,
|
||||||
widgetIndex = index || 0,
|
outerz = outer.max.z,
|
||||||
widgetArray = print.widgets,
|
slices = widget.slices,
|
||||||
widgetCount = widgetArray.length,
|
|
||||||
widget = widgetArray[widgetIndex],
|
|
||||||
alignTop = settings.controller.alignTop;
|
|
||||||
|
|
||||||
if (widgetIndex >= widgetCount || !widget) return;
|
|
||||||
let slices = widget.slices,
|
|
||||||
bounds = widget.getCamBounds(settings),
|
bounds = widget.getCamBounds(settings),
|
||||||
|
boundsz = bounds.max.z,
|
||||||
units = settings.controller.units === 'in' ? 25.4 : 1,
|
units = settings.controller.units === 'in' ? 25.4 : 1,
|
||||||
hasStock = process.camStockZ && process.camStockX && process.camStockY,
|
hasStock = process.camStockZ && process.camStockX && process.camStockY,
|
||||||
startCenter = process.outputOriginCenter,
|
startCenter = process.outputOriginCenter,
|
||||||
|
alignTop = settings.controller.alignTop,
|
||||||
zclear = (process.camZClearance || 1) * units,
|
zclear = (process.camZClearance || 1) * units,
|
||||||
zadd_outer = hasStock ? stock.z - outer.max.z : alignTop ? outer.max.z - outer.max.z : 0,
|
// zadd_outer = hasStock ? stock.z - outerz : alignTop ? outerz : 0,
|
||||||
zmax_outer = hasStock ? stock.z + zclear : outer.max.z + zclear,
|
zmax_outer = hasStock ? stock.z + zclear : outerz + zclear,
|
||||||
zadd = hasStock ? stock.z - bounds.max.z : alignTop ? outer.max.z - bounds.max.z : 0,
|
zadd = hasStock ? stock.z - boundsz : alignTop ? outerz - boundsz : 0,
|
||||||
zmax = hasStock ? stock.z + zclear : bounds.max.z + zclear,
|
zmax = outerz + zclear,//hasStock ? stock.z + zclear : boundsz + zclear,
|
||||||
originx = startCenter ? 0 : hasStock ? -stock.x / 2 : bounds.min.x,
|
originx = startCenter ? 0 : hasStock ? -stock.x / 2 : bounds.min.x,
|
||||||
originy = startCenter ? 0 : hasStock ? -stock.y / 2 : bounds.min.y,
|
originy = startCenter ? 0 : hasStock ? -stock.y / 2 : bounds.min.y,
|
||||||
origin = hasStock ? newPoint(originx, originy, stock.z) : newPoint(originx, originy, bounds.max.z + zclear),
|
origin = newPoint(originx, originy, zmax),
|
||||||
output = print.output,
|
output = print.output,
|
||||||
modes = CPRO,
|
modes = CPRO,
|
||||||
depthFirst = process.camDepthFirst,
|
depthFirst = process.camDepthFirst,
|
||||||
|
|
@ -1145,13 +1148,13 @@ var gs_kiri_cam = exports;
|
||||||
poly2polyDepthFirstEmit = print.poly2polyDepthFirstEmit;
|
poly2polyDepthFirstEmit = print.poly2polyDepthFirstEmit;
|
||||||
|
|
||||||
function newLayer() {
|
function newLayer() {
|
||||||
if (layerOut.length < 2) return;
|
if (layerOut.length < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
newOutput.push(layerOut);
|
newOutput.push(layerOut);
|
||||||
layerOut = [];
|
layerOut = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log({index, zadd, zmax, sz:stock.z, bz:bounds.max.z, oz:outer.max.z, at:alignTop});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Point} point
|
* @param {Point} point
|
||||||
* @param {number} emit (0=move, !0=filament emit/laser on/cut mode)
|
* @param {number} emit (0=move, !0=filament emit/laser on/cut mode)
|
||||||
|
|
@ -1253,6 +1256,7 @@ var gs_kiri_cam = exports;
|
||||||
point.x += widget.mesh.position.x;
|
point.x += widget.mesh.position.x;
|
||||||
point.y += widget.mesh.position.y;
|
point.y += widget.mesh.position.y;
|
||||||
point.z += zadd;
|
point.z += zadd;
|
||||||
|
|
||||||
if (nextIsMove) {
|
if (nextIsMove) {
|
||||||
cut = 0;
|
cut = 0;
|
||||||
nextIsMove = false;
|
nextIsMove = false;
|
||||||
|
|
@ -1292,7 +1296,7 @@ var gs_kiri_cam = exports;
|
||||||
point.x,
|
point.x,
|
||||||
point.y) + zadd,
|
point.y) + zadd,
|
||||||
point.z,
|
point.z,
|
||||||
lastPoint.z) : zmax + zadd,
|
lastPoint.z) : zmax,
|
||||||
mustGoUp = MAX(maxz - point.z, maxz - lastPoint.z) >= tolerance,
|
mustGoUp = MAX(maxz - point.z, maxz - lastPoint.z) >= tolerance,
|
||||||
clearz = maxz;
|
clearz = maxz;
|
||||||
// up if any point between higher than start/finish
|
// up if any point between higher than start/finish
|
||||||
|
|
@ -1321,7 +1325,7 @@ var gs_kiri_cam = exports;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// before first point, move cutting head to point above it
|
// before first point, move cutting head to point above it
|
||||||
layerPush(point.clone().setZ(zmax_outer + zadd_outer), 0, 0, tool.number);
|
layerPush(point.clone().setZ(zmax), 0, 0, tool.number);
|
||||||
}
|
}
|
||||||
// todo synthesize move speed from feed / plunge accordingly
|
// todo synthesize move speed from feed / plunge accordingly
|
||||||
layerPush(
|
layerPush(
|
||||||
|
|
@ -1334,6 +1338,9 @@ var gs_kiri_cam = exports;
|
||||||
layerOut.spindle = spindle;
|
layerOut.spindle = spindle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// coming from a previous widget, use previous last point
|
||||||
|
lastPoint = firstPoint;
|
||||||
|
|
||||||
// make top start offset configurable
|
// make top start offset configurable
|
||||||
printPoint = firstPoint || origin;
|
printPoint = firstPoint || origin;
|
||||||
|
|
||||||
|
|
@ -1568,10 +1575,8 @@ var gs_kiri_cam = exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
// last layer/move is to zmax
|
// last layer/move is to zmax
|
||||||
// printPoint = lastPoint.clone();
|
// injected into the last layer generated
|
||||||
// lastPoint = null;
|
addOutput(newOutput[newOutput.length-1], printPoint = lastPoint.clone().setZ(zmax_outer), 0, 0, tool);
|
||||||
camOut(printPoint.clone().setZ(bounds.max.z + zclear), false);
|
|
||||||
newOutput.push(layerOut);
|
|
||||||
|
|
||||||
// replace output single flattened layer with all points
|
// replace output single flattened layer with all points
|
||||||
print.output = newOutput;
|
print.output = newOutput;
|
||||||
|
|
|
||||||
|
|
@ -369,23 +369,23 @@ let gs_kiri_print = exports;
|
||||||
print[spd] = arr;
|
print[spd] = arr;
|
||||||
arr.push(last);
|
arr.push(last);
|
||||||
arr.push(point);
|
arr.push(point);
|
||||||
if (debug && showMoves) {
|
|
||||||
let rs = BASE.newSlope(
|
|
||||||
{x: point.x, y: point.y},
|
|
||||||
{x: last.x, y: last.y}
|
|
||||||
);
|
|
||||||
let ao1 = BASE.newSlopeFromAngle(rs.angle + 25);
|
|
||||||
let ao2 = BASE.newSlopeFromAngle(rs.angle - 25);
|
|
||||||
let sp = BASE.newPoint(point.x, point.y, point.z);
|
|
||||||
move.push(sp);
|
|
||||||
move.push(sp.projectOnSlope(ao1, 0.5));
|
|
||||||
move.push(sp);
|
|
||||||
move.push(sp.projectOnSlope(ao2, 0.5));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
move.push(last);
|
move.push(last);
|
||||||
move.push(point);
|
move.push(point);
|
||||||
}
|
}
|
||||||
|
if (debug && showMoves && last.z == point.z) {
|
||||||
|
let rs = BASE.newSlope(
|
||||||
|
{x: point.x, y: point.y},
|
||||||
|
{x: last.x, y: last.y}
|
||||||
|
);
|
||||||
|
let ao1 = BASE.newSlopeFromAngle(rs.angle + 25);
|
||||||
|
let ao2 = BASE.newSlopeFromAngle(rs.angle - 25);
|
||||||
|
let sp = BASE.newPoint(point.x, point.y, point.z);
|
||||||
|
move.push(sp);
|
||||||
|
move.push(sp.projectOnSlope(ao1, 0.5));
|
||||||
|
move.push(sp);
|
||||||
|
move.push(sp.projectOnSlope(ao2, 0.5));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (out.emit) DBUG.log("first point is emit");
|
if (out.emit) DBUG.log("first point is emit");
|
||||||
z = point.z;
|
z = point.z;
|
||||||
|
|
|
||||||
|
|
@ -922,7 +922,7 @@ self.kiri.license = exports.LICENSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
function platformUpdateTopZ() {
|
function platformUpdateTopZ() {
|
||||||
let camz = MODE === MODES.CAM && (settings.stock.z || settings.controller.alignTop);
|
let camz = (MODE === MODES.CAM) && (settings.stock.z || settings.controller.alignTop);
|
||||||
let ztop = camz ? camTopZ - settings.process.camZTopOffset : 0;
|
let ztop = camz ? camTopZ - settings.process.camZTopOffset : 0;
|
||||||
forAllWidgets(function(widget) {
|
forAllWidgets(function(widget) {
|
||||||
widget.setTopZ(ztop);
|
widget.setTopZ(ztop);
|
||||||
|
|
@ -949,7 +949,7 @@ self.kiri.license = exports.LICENSE;
|
||||||
forAllWidgets(function(widget) {
|
forAllWidgets(function(widget) {
|
||||||
let wp = widget.orient.pos;
|
let wp = widget.orient.pos;
|
||||||
let wb = widget.mesh.getBoundingBox().clone();
|
let wb = widget.mesh.getBoundingBox().clone();
|
||||||
wb.translate(widget.orient.pos);
|
// wb.translate(widget.orient.pos);
|
||||||
bounds.union(wb);
|
bounds.union(wb);
|
||||||
});
|
});
|
||||||
return settings.bounds = bounds;
|
return settings.bounds = bounds;
|
||||||
|
|
@ -1151,6 +1151,7 @@ self.kiri.license = exports.LICENSE;
|
||||||
let offset = UI.camStockOffset.checked;
|
let offset = UI.camStockOffset.checked;
|
||||||
let stockSet = sd.camStockX && sd.camStockY && sd.camStockZ;
|
let stockSet = sd.camStockX && sd.camStockY && sd.camStockZ;
|
||||||
let scale = unitScale();
|
let scale = unitScale();
|
||||||
|
settings.stock = { };
|
||||||
camTopZ = topZ;
|
camTopZ = topZ;
|
||||||
// create/inject cam stock if stock size other than default
|
// create/inject cam stock if stock size other than default
|
||||||
if (MODE === MODES.CAM && stockSet && WIDGETS.length) {
|
if (MODE === MODES.CAM && stockSet && WIDGETS.length) {
|
||||||
|
|
@ -1207,7 +1208,6 @@ self.kiri.license = exports.LICENSE;
|
||||||
camStock.material.visible = settings.mode === 'CAM';
|
camStock.material.visible = settings.mode === 'CAM';
|
||||||
camTopZ = csz;
|
camTopZ = csz;
|
||||||
} else if (camStock) {
|
} else if (camStock) {
|
||||||
settings.stock = { };
|
|
||||||
UI.stock.style.display = 'none';
|
UI.stock.style.display = 'none';
|
||||||
SPACE.platform.remove(camStock);
|
SPACE.platform.remove(camStock);
|
||||||
camStock = null;
|
camStock = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue