fixes #230 shared tool numbers cause animation errors
This commit is contained in:
parent
c025d69a0a
commit
fec2fcc18d
5 changed files with 19 additions and 31 deletions
|
|
@ -8,6 +8,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
|
||||||
* more graceful handling of security contexts blocking SharedArrayBuffer
|
* more graceful handling of security contexts blocking SharedArrayBuffer
|
||||||
* FDM refactor the 'detect' support feature for auto-placing manual supports
|
* FDM refactor the 'detect' support feature for auto-placing manual supports
|
||||||
* FDM fix supports in belt mode
|
* FDM fix supports in belt mode
|
||||||
|
* CAM fix issue #230 shared tool numbers cause animation errors
|
||||||
* CAM fix surface / trace selection copy on hover/pop/new op
|
* CAM fix surface / trace selection copy on hover/pop/new op
|
||||||
* CAM decrease cutting speed when entire tool is engaged in roughing
|
* CAM decrease cutting speed when entire tool is engaged in roughing
|
||||||
* CAM add dogbones support to traces ops
|
* CAM add dogbones support to traces ops
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,9 @@ kiri.load(() => {
|
||||||
}
|
}
|
||||||
pathIndex++;
|
pathIndex++;
|
||||||
|
|
||||||
if (next.tool >= 0 && (!tool || tool.getNumber() !== next.tool)) {
|
const firstTool = !tool && next.tool;
|
||||||
|
const toolChange = !firstTool && (tool.getID() !== next.tool.getID());
|
||||||
|
if (firstTool || toolChange) {
|
||||||
// on real tool change, go to safe Z first
|
// on real tool change, go to safe Z first
|
||||||
if (tool && last.point) {
|
if (tool && last.point) {
|
||||||
let pos = last.point = {
|
let pos = last.point = {
|
||||||
|
|
@ -533,11 +535,11 @@ kiri.load(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTool(toolnum, send) {
|
function updateTool(toolobj, send) {
|
||||||
if (tool) {
|
if (tool) {
|
||||||
send.data({ mesh_del: toolID });
|
send.data({ mesh_del: toolID });
|
||||||
}
|
}
|
||||||
tool = new CAM.Tool({ tools }, undefined, toolnum);
|
tool = new CAM.Tool({ tools }, toolobj.getID());
|
||||||
tool.generateProfile(rez);
|
tool.generateProfile(rez);
|
||||||
const flen = tool.fluteLength() || 15;
|
const flen = tool.fluteLength() || 15;
|
||||||
const slen = tool.shaftLength() || 15;
|
const slen = tool.shaftLength() || 15;
|
||||||
|
|
|
||||||
|
|
@ -151,20 +151,6 @@ CAM.export = function(print, online) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolByNumber(number) {
|
|
||||||
for (let i=0; i<tools.length; i++) {
|
|
||||||
if (tools[i].number === number) return tools[i];
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function toolNameByNumber(number) {
|
|
||||||
for (let i=0; i<tools.length; i++) {
|
|
||||||
if (tools[i].number === number) return tools[i].name;
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveTo(out, opt = {}) {
|
function moveTo(out, opt = {}) {
|
||||||
let laser = out.type === 'laser';
|
let laser = out.type === 'laser';
|
||||||
let newpos = out.point;
|
let newpos = out.point;
|
||||||
|
|
@ -188,8 +174,8 @@ CAM.export = function(print, online) {
|
||||||
let changeTool = out.tool != pos.t;
|
let changeTool = out.tool != pos.t;
|
||||||
if (changeTool) {
|
if (changeTool) {
|
||||||
pos.t = out.tool;
|
pos.t = out.tool;
|
||||||
consts.tool = pos.t;
|
consts.tool = pos.t.getNumber();
|
||||||
consts.tool_name = toolNameByNumber(out.tool);
|
consts.tool_name = pos.t.getName();
|
||||||
if (!laserOp && (spro.camToolInit || toolChanges > 0)) {
|
if (!laserOp && (spro.camToolInit || toolChanges > 0)) {
|
||||||
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
filterEmit(cmdToolChange, { ...consts, spindle: newSpindle } );
|
||||||
}
|
}
|
||||||
|
|
@ -395,7 +381,7 @@ CAM.export = function(print, online) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (out.tool && out.tool !== ctool) {
|
if (out.tool && out.tool !== ctool) {
|
||||||
ctool = toolByNumber(out.tool);
|
ctool = out.tool;
|
||||||
toolz[out.tool] = ctool;
|
toolz[out.tool] = ctool;
|
||||||
}
|
}
|
||||||
point = out.point;
|
point = out.point;
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,6 @@ class OpOutline extends CamOp {
|
||||||
if (op.top) {
|
if (op.top) {
|
||||||
let first = slices[0];
|
let first = slices[0];
|
||||||
let zlist = slices.map(s => s.z);
|
let zlist = slices.map(s => s.z);
|
||||||
console.log({zlist});
|
|
||||||
for (let z of indices.filter(v => v >= zMax).reverse()) {
|
for (let z of indices.filter(v => v >= zMax).reverse()) {
|
||||||
if (zlist.contains(z)) {
|
if (zlist.contains(z)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
time,
|
time,
|
||||||
tool.getNumber()
|
tool
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -319,7 +319,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
if (!lastPoint) {
|
if (!lastPoint) {
|
||||||
let above = point.clone().setZ(stockz + zclear);
|
let above = point.clone().setZ(stockz + zclear);
|
||||||
// let above = point.clone().setZ(zmax + zadd + ztOff);
|
// let above = point.clone().setZ(zmax + zadd + ztOff);
|
||||||
lastPoint = layerPush(above, 0, 0, tool.getNumber());
|
lastPoint = layerPush(above, 0, 0, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
// measure deltas to last point in XY and Z
|
// measure deltas to last point in XY and Z
|
||||||
|
|
@ -344,15 +344,15 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
isMove = false;
|
isMove = false;
|
||||||
} else if (deltaZ <= -tolerance) {
|
} else if (deltaZ <= -tolerance) {
|
||||||
// move over before descending
|
// move over before descending
|
||||||
layerPush(point.clone().setZ(lastPoint.z), 0, 0, tool.getNumber());
|
layerPush(point.clone().setZ(lastPoint.z), 0, 0, tool);
|
||||||
// new pos for plunge calc
|
// new pos for plunge calc
|
||||||
deltaXY = 0;
|
deltaXY = 0;
|
||||||
}
|
}
|
||||||
} else if (isMove && isLathe) {
|
} else if (isMove && isLathe) {
|
||||||
if (point.z > lastPoint.z) {
|
if (point.z > lastPoint.z) {
|
||||||
layerPush(lastPoint.clone().setZ(point.z), 0, 0, tool.getNumber());
|
layerPush(lastPoint.clone().setZ(point.z), 0, 0, tool);
|
||||||
} else if (point.z < lastPoint.z) {
|
} else if (point.z < lastPoint.z) {
|
||||||
layerPush(point.clone().setZ(lastPoint.z), 0, 0, tool.getNumber());
|
layerPush(point.clone().setZ(lastPoint.z), 0, 0, tool);
|
||||||
}
|
}
|
||||||
} else if (isMove) {
|
} else if (isMove) {
|
||||||
// for longer moves, check the terrain to see if we need to go up and over
|
// for longer moves, check the terrain to see if we need to go up and over
|
||||||
|
|
@ -384,9 +384,9 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
if (mustGoUp || zIsBelow) {
|
if (mustGoUp || zIsBelow) {
|
||||||
const zClearance = clearz + (isIndexed ? 0 : ztOff);
|
const zClearance = clearz + (isIndexed ? 0 : ztOff);
|
||||||
if (zIsBelow) {
|
if (zIsBelow) {
|
||||||
layerPush(lastPoint.clone().setZ(zClearance), 0, 0, tool.getNumber());
|
layerPush(lastPoint.clone().setZ(zClearance), 0, 0, tool);
|
||||||
}
|
}
|
||||||
layerPush(point.clone().setZ(zClearance), 0, 0, tool.getNumber());
|
layerPush(point.clone().setZ(zClearance), 0, 0, tool);
|
||||||
// new pos for plunge calc
|
// new pos for plunge calc
|
||||||
deltaXY = 0;
|
deltaXY = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -413,7 +413,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
point,
|
point,
|
||||||
cut ? 1 : 0,
|
cut ? 1 : 0,
|
||||||
rate,
|
rate,
|
||||||
tool.getNumber()
|
tool
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,7 +476,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
update((opSum + (progress * weight)) / opTot, message || op.type(), message);
|
||||||
});
|
});
|
||||||
opSum += weight;
|
opSum += weight;
|
||||||
if (tool) {
|
if (tool && lastPoint) {
|
||||||
newLayer();
|
newLayer();
|
||||||
camOut(printPoint = lastPoint.clone().setZ(zmax + zadd));
|
camOut(printPoint = lastPoint.clone().setZ(zmax + zadd));
|
||||||
newLayer();
|
newLayer();
|
||||||
|
|
@ -593,7 +593,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
if (lastPoint && newOutput.length) {
|
if (lastPoint && newOutput.length) {
|
||||||
let lastLayer = newOutput.filter(layer => Array.isArray(layer)).peek();
|
let lastLayer = newOutput.filter(layer => Array.isArray(layer)).peek();
|
||||||
if (Array.isArray(lastLayer)) {
|
if (Array.isArray(lastLayer)) {
|
||||||
print.addOutput(lastLayer, printPoint = lastPoint.clone().setZ(zmax_outer), 0, 0, tool.getNumber());
|
print.addOutput(lastLayer, printPoint = lastPoint.clone().setZ(zmax_outer), 0, 0, tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue