add CAM Z bottom visualization, make it relative to stock instead of part

This commit is contained in:
Stewart Allen 2022-10-05 12:04:00 -04:00
commit b0c184ea85
4 changed files with 36 additions and 11 deletions

View file

@ -17,6 +17,7 @@ Full docs @ https://docs.grid.space/projects/kiri-moto
* add bridging option in CAM contouring
* add option to force z max routing in CAM
* add option to ignore z bottom in CAM contouring
* add CAM Z bottom visualization, make it relative to stock instead of part
* extend url loading of workspaces to all formats
* alert when healing is enabled and non-manifold geometries are detected
* fix thin output start and end point tracking which broke retraction

View file

@ -16,6 +16,7 @@ let isAnimate,
isCamMode,
isParsed,
camStock,
camZBottom,
current,
poppedRec,
hoveredOp,
@ -1314,10 +1315,10 @@ function updateStock(args, event) {
}
if (!isCamMode) {
if (camStock) {
SPACE.world.remove(camStock);
camStock = null;
}
SPACE.world.remove(camZBottom);
SPACE.world.remove(camStock);
camStock = null;
camZBottom = null;
return;
}
@ -1339,11 +1340,11 @@ function updateStock(args, event) {
UI.func.animate.classList.add('disabled');
// create/inject cam stock if stock size other than default
let csx = proc.camStockX;
let csy = proc.camStockY;
let csz = proc.camStockZ;
if (compute) {
UI.func.animate.classList.remove('disabled');
let csx = proc.camStockX;
let csy = proc.camStockY;
let csz = proc.camStockZ;
if (offset) {
let min = { x: Infinity, y: Infinity, z: 0 };
let max = { x: -Infinity, y: -Infinity, z: -Infinity };
@ -1402,6 +1403,28 @@ function updateStock(args, event) {
delta = 0;
}
SPACE.world.remove(camZBottom);
if (proc.camZBottom) {
let max = { x: csx, y: csy };
for (let w of widgets) {
max.x = Math.max(max.x, w.track.box.w);
max.y = Math.max(max.y, w.track.box.h);
}
let geo = new THREE.PlaneGeometry(max.x, max.y);
let mat = new THREE.MeshBasicMaterial({
color: 0x777777,
opacity: 0.55,
transparent: true,
side:THREE.DoubleSide
});
camZBottom = new THREE.Mesh(geo, mat);
camZBottom.renderOrder = 1;
camZBottom.position.z = proc.camZBottom;
SPACE.world.add(camZBottom);
} else {
camZBottom = undefined;
}
const {x, y, z} = stock;
if (x && y && z && !STACKS.getStack('bounds')) {
const render = new kiri.Layers().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa });

View file

@ -34,12 +34,13 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
camOps = widget.camops = [],
sliceAll = widget.slices = [],
bounds = widget.getBoundingBox(),
zBottom = proc.camZBottom,
wztop = widget.track.top,
ztOff = hasStock ? stock.z - wztop : 0,
zbOff = hasStock ? wztop - widget.track.box.d : 0,
zBottom = proc.camZBottom - zbOff,
zMin = Math.max(bounds.min.z, zBottom),
zMax = bounds.max.z,
zThru = zBottom === 0 ? (proc.camZThru || 0) : 0,
wztop = widget.track.top,
ztOff = hasStock ? stock.z - wztop : 0,
zTop = zMax + ztOff,
minToolDiam = Infinity,
maxToolDiam = -Infinity,

View file

@ -39,7 +39,7 @@ class Topo {
maxX = bounds.max.x,
minY = bounds.min.y,
maxY = bounds.max.y,
zBottom = contour.bottom ? proc.camZBottom : 0,
zBottom = contour.bottom ? state.zBottom : 0,
zMin = Math.max(bounds.min.z, zBottom) + 0.0001,
boundsX = maxX - minX,
boundsY = maxY - minY,