allow newSlice to track a specified widget to aid 4th axis visuals
This commit is contained in:
parent
5a726c49c8
commit
f588e2e5cf
5 changed files with 33 additions and 14 deletions
|
|
@ -471,7 +471,6 @@ class OpOutline extends CamOp {
|
||||||
if (op.down <= 0) {
|
if (op.down <= 0) {
|
||||||
throw `invalid step down "${op.down}"`;
|
throw `invalid step down "${op.down}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let toolDiam = this.toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
|
let toolDiam = this.toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
|
||||||
updateToolDiams(toolDiam);
|
updateToolDiams(toolDiam);
|
||||||
|
|
||||||
|
|
@ -622,6 +621,9 @@ class OpOutline extends CamOp {
|
||||||
slice.camLines = offset;
|
slice.camLines = offset;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// when top expand fails above, it creates an empty slice
|
||||||
|
slices = slices.filter(s => s.camLines);
|
||||||
|
|
||||||
// project empty up and render
|
// project empty up and render
|
||||||
for (let slice of slices) {
|
for (let slice of slices) {
|
||||||
if (false) slice.output()
|
if (false) slice.output()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
gapp.register("kiri-mode.cam.slice", [], (root, exports) => {
|
gapp.register("kiri-mode.cam.slice", [], (root, exports) => {
|
||||||
|
|
||||||
const { base, kiri } = root;
|
const { base, kiri } = root;
|
||||||
const { driver, newSlice } = kiri;
|
const { driver, newSlice, trackWidget } = kiri;
|
||||||
const { polygons, newPoint, newPolygon } = base;
|
const { polygons, newPoint, newPolygon } = base;
|
||||||
const { CAM } = driver;
|
const { CAM } = driver;
|
||||||
const { OPS } = CAM;
|
const { OPS } = CAM;
|
||||||
|
|
@ -149,7 +149,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
sliceAll.appendAll(slices);
|
sliceAll.appendAll(slices);
|
||||||
if (axisIndex !== undefined) {
|
if (axisIndex !== undefined) {
|
||||||
// update slice cam lines to add axis indexing
|
// update slice cam lines to add axis indexing
|
||||||
for (let slice of slices) {
|
for (let slice of slices.filter(s => s.camLines)) {
|
||||||
for (let poly of slice.camLines) {
|
for (let poly of slice.camLines) {
|
||||||
for (let point of poly.points) {
|
for (let point of poly.points) {
|
||||||
point.a = -axisIndex;
|
point.a = -axisIndex;
|
||||||
|
|
@ -208,6 +208,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
state.ops = opList;
|
state.ops = opList;
|
||||||
|
|
||||||
// call slice() function on all ops in order
|
// call slice() function on all ops in order
|
||||||
|
trackWidget(widget);
|
||||||
setAxisIndex(undefined);
|
setAxisIndex(undefined);
|
||||||
for (let op of opList) {
|
for (let op of opList) {
|
||||||
let weight = op.weight();
|
let weight = op.weight();
|
||||||
|
|
@ -215,7 +216,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
onupdate((opSum + (progress * weight)) / opTot, message || op.type());
|
onupdate((opSum + (progress * weight)) / opTot, message || op.type());
|
||||||
});
|
});
|
||||||
// setup new state when indexing the workspace
|
// setup new state when indexing the workspace
|
||||||
if (false && op.op.type === "index") {
|
if (true && op.op.type === "index") {
|
||||||
let points = base.verticesToPoints(widget.getGeoVertices(true, true));
|
let points = base.verticesToPoints(widget.getGeoVertices(true, true));
|
||||||
state.slicer = new kiri.cam_slicer(points, {
|
state.slicer = new kiri.cam_slicer(points, {
|
||||||
zlist: true,
|
zlist: true,
|
||||||
|
|
@ -223,12 +224,13 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
nobucket: true // b/c negative Z when rotated
|
nobucket: true // b/c negative Z when rotated
|
||||||
});
|
});
|
||||||
new CAM.OPS.shadow(state, { type: "shadow", silent: true }).slice(progress => {
|
new CAM.OPS.shadow(state, { type: "shadow", silent: true }).slice(progress => {
|
||||||
console.log('reshadow', progress.round(3));
|
// console.log('reshadow', progress.round(3));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
camOps.push(op);
|
camOps.push(op);
|
||||||
opSum += weight;
|
opSum += weight;
|
||||||
}
|
}
|
||||||
|
trackWidget(undefined);
|
||||||
|
|
||||||
// reindex
|
// reindex
|
||||||
sliceAll.forEach((slice, index) => slice.index = index);
|
sliceAll.forEach((slice, index) => slice.index = index);
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ kiri.Layers.prototype.encode = function(state) {
|
||||||
} : undefined,
|
} : undefined,
|
||||||
cpath: layer.cpath || codec.undef,
|
cpath: layer.cpath || codec.undef,
|
||||||
rotation: layer.rotation,
|
rotation: layer.rotation,
|
||||||
posiiton: layer.position
|
position: layer.position
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@ const { util } = base;
|
||||||
const POLY = base.polygons;
|
const POLY = base.polygons;
|
||||||
const NOKEY = key.NONE;
|
const NOKEY = key.NONE;
|
||||||
|
|
||||||
|
let tracked;
|
||||||
|
|
||||||
|
function trackWidget(widget) {
|
||||||
|
tracked = widget;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object encapsulates a z-slice from an object. This code is shared by the
|
* Object encapsulates a z-slice from an object. This code is shared by the
|
||||||
* client and the worker thread. As such, the view layers are ignored in the
|
* client and the worker thread. As such, the view layers are ignored in the
|
||||||
|
|
@ -38,7 +44,15 @@ class Slice {
|
||||||
*/
|
*/
|
||||||
output() {
|
output() {
|
||||||
if (this.layers) return this.layers;
|
if (this.layers) return this.layers;
|
||||||
return this.layers = new kiri.Layers();
|
let layers = this.layers = new kiri.Layers();
|
||||||
|
if (tracked) {
|
||||||
|
let { track } = tracked;
|
||||||
|
let { indexed, indexRad, delta } = track;
|
||||||
|
if (indexed) {
|
||||||
|
layers.setRotation(indexRad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return layers;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -239,7 +253,8 @@ gapp.overlay(kiri, {
|
||||||
Top,
|
Top,
|
||||||
Slice,
|
Slice,
|
||||||
newTop,
|
newTop,
|
||||||
newSlice
|
newSlice,
|
||||||
|
trackWidget
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -645,17 +645,17 @@ class Widget {
|
||||||
this.points = null;
|
this.points = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getGeoVertices(unroll, index) {
|
getGeoVertices(unroll, translate) {
|
||||||
let geo = this.mesh.geometry;
|
let geo = this.mesh.geometry;
|
||||||
let pos = geo.getAttribute('position');
|
let pos = geo.getAttribute('position');
|
||||||
// if indexed, return points rotated about X and then offset
|
// if indexed, return points rotated about X and then offset
|
||||||
let track = this.track;
|
let track = this.track;
|
||||||
if (index && track.indexed) {
|
if (translate && track.indexed) {
|
||||||
let delta = track.delta;
|
let delta = track.delta;
|
||||||
pos = pos.clone().applyMatrix4(
|
pos = pos.clone().applyMatrix4(
|
||||||
new THREE.Matrix4().makeRotationX(track.indexRad)
|
new THREE.Matrix4().makeRotationX(-track.indexRad)
|
||||||
).applyMatrix4(
|
// ).applyMatrix4(
|
||||||
new THREE.Matrix4().makeTranslation(0, -delta.y, -delta.z + track.tzoff)
|
// new THREE.Matrix4().makeTranslation(0, -delta.y, -delta.z + track.tzoff)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pos = pos.array;
|
pos = pos.array;
|
||||||
|
|
@ -672,7 +672,7 @@ class Widget {
|
||||||
pp2[inc++] = pos[ip];
|
pp2[inc++] = pos[ip];
|
||||||
}
|
}
|
||||||
pos = pp2;
|
pos = pp2;
|
||||||
} else if (index) {
|
} else if (translate) {
|
||||||
pos = pos.slice();
|
pos = pos.slice();
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue