work on getting index translated widget geometry

This commit is contained in:
Stewart Allen 2022-11-01 19:55:30 -04:00
commit 2af361fc5a
8 changed files with 57 additions and 37 deletions

View file

@ -1761,7 +1761,9 @@ function updateStock(args, event) {
const {x, y, z} = stock;
if (x && y && z && !STACKS.getStack('bounds')) {
const render = new kiri.Layers().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa, index: currentIndex });
const render = new kiri.Layers()
.setRotation(currentIndex)
.setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa });
const stack = STACKS.setFreeMem(false).create('bounds', SPACE.world);
const hx = x/2, hy = y/2;
const sz = stock.z || 0;

View file

@ -1036,7 +1036,6 @@ class OpPocket extends CamOp {
}
function newSliceOut(z) {
let slice = newSlice(z);
addSlices(slice);
sliceOut.push(slice);
return slice;
}
@ -1109,10 +1108,12 @@ class OpPocket extends CamOp {
progress(zpro, "pocket");
}
zpro += zinc;
addSlices(slice);
}
}
}
let surfaces = op.surfaces[widget.id] || [];
// let vert = widget.getGeoVertices(true,true).map(v => v.round(4));
let vert = widget.getVertices().array.map(v => v.round(4));
let outline = [];
let faces = CAM.surface_find(widget, surfaces);

View file

@ -139,6 +139,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
function setAxisIndex(degrees) {
axisIndex = degrees;
// state.axisIndex = (Math.PI / 180) * axisIndex;
}
function addSlices(slices) {
@ -213,6 +214,18 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
op.slice((progress, message) => {
onupdate((opSum + (progress * weight)) / opTot, message || op.type());
});
// setup new state when indexing the workspace
if (false && op.op.type === "index") {
let points = base.verticesToPoints(widget.getGeoVertices(true, true));
state.slicer = new kiri.cam_slicer(points, {
zlist: true,
zline: true,
nobucket: true // b/c negative Z when rotated
});
new CAM.OPS.shadow(state, { type: "shadow", silent: true }).slice(progress => {
console.log('reshadow', progress.round(3));
});
}
camOps.push(op);
opSum += weight;
}

View file

@ -131,8 +131,7 @@ class Slicer {
let bucketCount = Math.max(1, Math.ceil(zMax / (zSum / points.length)) - 1);
let zScale = this.zScale = 1 / (zMax / bucketCount);
let buckets = this.buckets = [];
if (bucketCount > 1) {
if (bucketCount > 1 && !this.options.nobucket) {
// create empty buckets
for (let i = 0; i <= bucketCount + 1; i++) {
buckets.push([]);