checkpoint trace work
This commit is contained in:
parent
0ff23ef8cd
commit
44c1c850e9
11 changed files with 82 additions and 24 deletions
|
|
@ -2187,7 +2187,7 @@
|
|||
UI.back.style.display = '';
|
||||
UI.render.style.display = '';
|
||||
UI.render.classList.add('lt-enabled');
|
||||
KIRI.work.clear();
|
||||
// KIRI.work.clear();
|
||||
STACKS.clear();
|
||||
hideSlider();
|
||||
updateSpeeds();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
}
|
||||
|
||||
const { polys, lines, faces, cface, paths, cpath, color, off } = layer;
|
||||
const meshes = this.meshes;
|
||||
const meshes = [];
|
||||
const defstate = !off;
|
||||
const mats = [];
|
||||
mats.state = defstate;
|
||||
|
|
@ -185,6 +185,8 @@
|
|||
mats.appendAll(mat);
|
||||
}
|
||||
|
||||
this.new_meshes = meshes;
|
||||
this.meshes.appendAll(meshes);
|
||||
mats.forEach(mat => mat.visible = defstate);
|
||||
return mats;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,7 +390,8 @@
|
|||
*/
|
||||
PRO.setTopZ = function(z) {
|
||||
let mesh = this.mesh,
|
||||
pos = this.track.pos;
|
||||
pos = this.track.pos,
|
||||
ltz = this.last_top_z || {};
|
||||
if (z) {
|
||||
pos.z = mesh.getBoundingBox().max.z - z;
|
||||
mesh.position.z = -pos.z - 0.01;
|
||||
|
|
@ -398,7 +399,12 @@
|
|||
pos.z = 0;
|
||||
mesh.position.z = 0;
|
||||
}
|
||||
this.modified = true;
|
||||
let ntz = {
|
||||
pz: pos.z,
|
||||
mpz: mesh.position.z
|
||||
};
|
||||
this.modified |= (ltz.pz !== ntz.pz || ltz.mpz !== ntz.mpz);
|
||||
this.last_top_z = ntz;
|
||||
}
|
||||
|
||||
PRO.move = function(x, y, z, abs) {
|
||||
|
|
@ -448,6 +454,7 @@
|
|||
scale.x *= (x || 1.0);
|
||||
scale.y *= (y || 1.0);
|
||||
scale.z *= (z || 1.0);
|
||||
this.modified = true;
|
||||
};
|
||||
|
||||
PRO.rotate = function(x, y, z) {
|
||||
|
|
@ -478,6 +485,7 @@
|
|||
rot.y += (y || 0);
|
||||
rot.z += (z || 0);
|
||||
}
|
||||
this.modified = true;
|
||||
};
|
||||
|
||||
PRO.unrotate = function() {
|
||||
|
|
@ -486,6 +494,7 @@
|
|||
});
|
||||
this.roto = [];
|
||||
this.center();
|
||||
this.modified = true;
|
||||
};
|
||||
|
||||
PRO.mirror = function() {
|
||||
|
|
@ -511,6 +520,7 @@
|
|||
geo.computeFaceNormals();
|
||||
geo.computeVertexNormals();
|
||||
o.mirror = !o.mirror;
|
||||
this.modified = true;
|
||||
};
|
||||
|
||||
PRO.getGeoVertices = function() {
|
||||
|
|
@ -593,7 +603,6 @@
|
|||
ondone(false, reply.error);
|
||||
}
|
||||
if (reply.done) {
|
||||
widget.modified = false;
|
||||
ondone(true);
|
||||
}
|
||||
});
|
||||
|
|
@ -609,7 +618,6 @@
|
|||
onupdate(1.0, "transfer");
|
||||
|
||||
widget.stats.slice_time = UTIL.time() - startTime;
|
||||
widget.modified = false;
|
||||
|
||||
ondone();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -305,6 +305,15 @@ self.kiri.loader.push(function() {
|
|||
animating = true;
|
||||
stepsRemain--;
|
||||
if (next.tool >= 0 && (!tool || tool.getNumber() !== next.tool)) {
|
||||
// on real tool change, go to safe Z first
|
||||
if (tool) {
|
||||
let pos = last.point = {
|
||||
x: last.point.x,
|
||||
y: last.point.y,
|
||||
z: stock.z
|
||||
};
|
||||
send.data({ mesh_move: { toolID, pos }});
|
||||
}
|
||||
updateTool(next.tool, send);
|
||||
}
|
||||
const id = toolID;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
PRO = CAM.process,
|
||||
newPolygon = BASE.newPolygon,
|
||||
newPoint = BASE.newPoint,
|
||||
toolInfo,
|
||||
isAnimate,
|
||||
isArrange,
|
||||
isCamMode,
|
||||
|
|
@ -33,6 +34,8 @@
|
|||
UC = api.uc;
|
||||
API = api;
|
||||
|
||||
toolInfo = $('tool-info');
|
||||
|
||||
api.event.on("mode.set", (mode) => {
|
||||
isCamMode = mode === 'CAM';
|
||||
$('set-tools').style.display = isCamMode ? '' : 'none';
|
||||
|
|
@ -239,18 +242,21 @@
|
|||
alert = api.show.alert("[esc] key cancels trace editing");
|
||||
KIRI.api.widgets.opacity(0.5);
|
||||
KIRI.api.widgets.for(widget => {
|
||||
if (widget.trace_stack) {
|
||||
widget.adds.appendAll(widget.trace_stack.meshes);
|
||||
widget.trace_stack.show();
|
||||
return;
|
||||
}
|
||||
let stack = new KIRI.Stack(widget.mesh);
|
||||
widget.trace_stack = stack;
|
||||
widget.traces.forEach(poly => {
|
||||
let layers = new KIRI.Layers();
|
||||
layers.setLayer("trace", {line: 0x88aa55}, false).addPoly(poly);
|
||||
stack.addLayers(layers);
|
||||
stack.meshes.forEach(mesh => {
|
||||
stack.new_meshes.forEach(mesh => {
|
||||
mesh.trace = {widget, poly};
|
||||
});
|
||||
// reset so each mesh array is new for the layer
|
||||
widget.adds.appendAll(stack.meshes);
|
||||
stack.meshes = [];
|
||||
widget.adds.appendAll(stack.new_meshes);
|
||||
});
|
||||
// for (let [key, val] of Object.entries(widget.sindex)) {
|
||||
// console.log('sindex', {key, val});
|
||||
|
|
@ -276,8 +282,8 @@
|
|||
api.feature.hoverAdds = false;
|
||||
KIRI.api.widgets.for(widget => {
|
||||
if (widget.trace_stack) {
|
||||
widget.trace_stack.hide();
|
||||
widget.adds.removeAll(widget.trace_stack.meshes);
|
||||
widget.trace_stack.destroy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -300,6 +306,18 @@
|
|||
return;
|
||||
}
|
||||
lastTrace = data.int.object;
|
||||
if (lastTrace.selected) {
|
||||
let traceInfo = lastTrace.trace.poly.traceInfo;
|
||||
let tool = new CAM.Tool(current, traceInfo.tool);
|
||||
toolInfo.innerText = [
|
||||
` tool: ${tool.getName()}`,
|
||||
` feed: ${traceInfo.speed}`,
|
||||
`plunge: ${traceInfo.plunge}`
|
||||
].join('\n');
|
||||
toolInfo.style.display = 'flex';
|
||||
} else {
|
||||
toolInfo.style.display = '';
|
||||
}
|
||||
let material = lastTrace.material[0];
|
||||
let color = material.color;
|
||||
let {r, g, b} = color;
|
||||
|
|
@ -310,7 +328,6 @@
|
|||
};
|
||||
func.traceHoverUp = function(int) {
|
||||
if (!int) return;
|
||||
console.log({traceHoverUp: int});
|
||||
func.traceToggle(int.object);
|
||||
};
|
||||
func.traceToggle = function(obj) {
|
||||
|
|
@ -461,13 +478,15 @@
|
|||
}
|
||||
|
||||
function clearTraces(widget) {
|
||||
Object.values(widget.traces || {}).forEach(rec => {
|
||||
console.log('clear',rec);
|
||||
// widget.adds.remove(rec.box);
|
||||
// widget.mesh.remove(rec.box);
|
||||
});
|
||||
widget.traces = {};
|
||||
widget.trace_stack = null;
|
||||
let stack = widget.trace_stack;
|
||||
if (stack) {
|
||||
stack.meshes.forEach(mesh => {
|
||||
if (mesh.selected) {
|
||||
func.traceToggle(mesh);
|
||||
}
|
||||
});
|
||||
}
|
||||
widget.trace = null;
|
||||
delete API.widgets.annotate(widget.id).trace;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@
|
|||
KIRI.worker.traces = function(data, send) {
|
||||
const { settings } = data;
|
||||
const widgets = Object.values(cache);
|
||||
widgets.forEach(widget => CAM.traces(settings, widget));
|
||||
send.done(KIRI.codec.encode(widgets.map(widget => {return {
|
||||
const fresh = widgets.filter(widget => CAM.traces(settings, widget));
|
||||
send.done(KIRI.codec.encode(fresh.map(widget => {return {
|
||||
id: widget.id,
|
||||
traces: widget.traces,
|
||||
// sindex: widget.sindex
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@
|
|||
easeDown = process.camEaseDown,
|
||||
depthFirst = process.camDepthFirst,
|
||||
tolerance = process.camTolerance,
|
||||
contour = process.camContourXOn || process.camContourYOn,
|
||||
contourCurves = process.camContourCurves,
|
||||
drillDown = process.camDrillDown,
|
||||
drillLift = process.camDrillLift,
|
||||
drillDwell = process.camDrillDwell,
|
||||
|
|
@ -550,7 +552,7 @@
|
|||
printPoint = depthOutlinePath(printPoint, 0, flatLevels, toolDiam, polyEmit, true);
|
||||
}
|
||||
// two modes for deferred outlining: x then y or combined
|
||||
if (process.camContourCurves) {
|
||||
if (contour && contourCurves) {
|
||||
lastMode = PRO.CONTOUR_X;
|
||||
setTool(process.camContourTool, process.camContourSpeed, process.camContourPlunge);
|
||||
spindle = Math.min(spindleMax, process.camContourSpindle);
|
||||
|
|
@ -567,7 +569,7 @@
|
|||
newLayer();
|
||||
return lastPoint;
|
||||
});
|
||||
} else {
|
||||
} else if (contour) {
|
||||
setTool(process.camContourTool, process.camContourSpeed, process.camContourPlunge);
|
||||
spindle = Math.min(spindleMax, process.camContourSpindle);
|
||||
// deferred contour x outlining
|
||||
|
|
|
|||
|
|
@ -503,7 +503,6 @@
|
|||
.addPolys(slice.topPolys())
|
||||
sliceAll.push(slice);
|
||||
maxToolDiam = Math.max(maxToolDiam, traceToolDiam);
|
||||
console.log({slice});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -537,6 +536,10 @@ console.log({slice});
|
|||
};
|
||||
|
||||
CAM.traces = function computeTraces(settings, widget) {
|
||||
if (widget.traces) {
|
||||
// do no work if cached
|
||||
return false;
|
||||
}
|
||||
let slicer = new KIRI.slicer2(widget.getPoints(), {
|
||||
zlist: true,
|
||||
zline: true
|
||||
|
|
@ -615,6 +618,7 @@ console.log({slice});
|
|||
slicer.slice(indices, opts);
|
||||
widget.traces = traces;
|
||||
// widget.sindex = sindex;
|
||||
return true;
|
||||
};
|
||||
|
||||
// drilling op
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@
|
|||
return this.tool.id;
|
||||
}
|
||||
|
||||
getName() {
|
||||
return this.tool.name;
|
||||
}
|
||||
|
||||
getType() {
|
||||
return this.tool.type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1196,6 +1196,15 @@ th, tr, td, label {
|
|||
right: 5px;
|
||||
color: #000;
|
||||
}
|
||||
#tool-info {
|
||||
position: fixed;
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
bottom: 5px;
|
||||
left: 5px;
|
||||
color: #000;
|
||||
}
|
||||
#winfo {
|
||||
position: fixed;
|
||||
font-size: 10px;
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@
|
|||
<p>this site uses cookies to preserve application preferences</p>
|
||||
<button id="gotit" class="f-col j-center">got it</button>
|
||||
</div>
|
||||
<div id="tool-info" class="noshow"></div>
|
||||
<div id="fps" class="noshow"></div>
|
||||
<div id="layer-animate" class="f-col a-center"></div>
|
||||
<div id="layer-toolpos" class="f-row a-center"></div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue