fixes for indexing and tracking during slicing
This commit is contained in:
parent
7bb4b817fa
commit
77c8b0299c
6 changed files with 30 additions and 35 deletions
|
|
@ -385,7 +385,7 @@ kiri.load(() => {
|
|||
|
||||
stockSlices = [];
|
||||
const { x, y, z } = stock;
|
||||
const sliceCount = 10;
|
||||
const sliceCount = 20;
|
||||
const sliceWidth = stock.x / sliceCount;
|
||||
for (let i=0; i<sliceCount; i++) {
|
||||
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
||||
|
|
|
|||
|
|
@ -594,6 +594,7 @@ CAM.init = function(kiri, api) {
|
|||
widget.setAxisIndex(-index);
|
||||
}
|
||||
currentIndex = isIndexed ? index * (Math.PI / 180) : 0;
|
||||
updateStock();
|
||||
});
|
||||
|
||||
func.opGCode = (label, field = 'gcode') => {
|
||||
|
|
@ -1383,7 +1384,7 @@ CAM.init = function(kiri, api) {
|
|||
});
|
||||
|
||||
createPopOp('index', {
|
||||
degrees: 'camIndexAxis',
|
||||
degrees: 'camIndexAxis',
|
||||
absolute: 'camIndexAbs'
|
||||
}).inputs = {
|
||||
degrees: UC.newInput(LANG.ci_degr_s, {title:LANG.ci_degr_l, convert:UC.toFloat, bound:UC.bound(-360,360.0) }),
|
||||
|
|
@ -1496,14 +1497,16 @@ function createPopOp(type, map) {
|
|||
}
|
||||
if (op.note) {
|
||||
const { divid, noteid } = op.note;
|
||||
$(divid).onclick = () => {
|
||||
const div = $(divid);
|
||||
if (div) div.onclick = () => {
|
||||
let note = op.x = prompt('Edit Note for Operation', poppedRec.note || '');
|
||||
if (note !== undefined && note !== null) {
|
||||
$(noteid).innerText = poppedRec.note = note;
|
||||
API.conf.save();
|
||||
}
|
||||
};
|
||||
$(noteid).innerText = poppedRec.note || '';
|
||||
const note = $(noteid);
|
||||
if (note) note.innerText = poppedRec.note || '';
|
||||
}
|
||||
},
|
||||
group: [],
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class OpIndex extends CamOp {
|
|||
|
||||
slice() {
|
||||
let { op, state } = this;
|
||||
state.setAxisIndex(op.degrees);
|
||||
state.setAxisIndex(op.degrees, op.absolute);
|
||||
}
|
||||
|
||||
prepare(ops, progress) {
|
||||
|
|
@ -626,7 +626,7 @@ class OpOutline extends CamOp {
|
|||
|
||||
// project empty up and render
|
||||
for (let slice of slices) {
|
||||
if (false) slice.output()
|
||||
if (true) slice.output()
|
||||
.setLayer("slice", {line: 0xaaaa00}, false)
|
||||
.addPolys(slice.topPolys())
|
||||
slice.output()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
gapp.register("kiri-mode.cam.slice", [], (root, exports) => {
|
||||
|
||||
const { base, kiri } = root;
|
||||
const { driver, newSlice, trackWidget } = kiri;
|
||||
const { driver, newSlice, setSliceTracker } = kiri;
|
||||
const { polygons, newPoint, newPolygon } = base;
|
||||
const { CAM } = driver;
|
||||
const { OPS } = CAM;
|
||||
|
|
@ -44,13 +44,14 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
zTop = zMax + ztOff,
|
||||
minToolDiam = Infinity,
|
||||
maxToolDiam = -Infinity,
|
||||
thruHoles,
|
||||
dark = settings.controller.dark ? true : false,
|
||||
color = dark ? 0xbbbbbb : 0,
|
||||
tabs = widget.anno.tab,
|
||||
unsafe = proc.camExpertFast,
|
||||
units = settings.controller.units === 'in' ? 25.4 : 1,
|
||||
axisIndex = undefined;
|
||||
axisRotation,
|
||||
axisIndex,
|
||||
thruHoles;
|
||||
|
||||
if (tabs) {
|
||||
// make tab polygons
|
||||
|
|
@ -137,9 +138,10 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
return shadows[z] = POLY.setZ(shadow, z);
|
||||
}
|
||||
|
||||
function setAxisIndex(degrees) {
|
||||
axisIndex = degrees;
|
||||
// state.axisIndex = (Math.PI / 180) * axisIndex;
|
||||
function setAxisIndex(degrees = 0, absolute = true) {
|
||||
axisIndex = absolute ? degrees : axisIndex + degrees;
|
||||
axisRotation = (Math.PI / 180) * axisIndex;
|
||||
widget.setAxisIndex(-axisIndex);
|
||||
}
|
||||
|
||||
function addSlices(slices) {
|
||||
|
|
@ -211,8 +213,8 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
state.ops = opList;
|
||||
|
||||
// call slice() function on all ops in order
|
||||
trackWidget(widget);
|
||||
setAxisIndex(undefined);
|
||||
let tracker = setSliceTracker({ rotation: 0 });
|
||||
setAxisIndex();
|
||||
for (let op of opList) {
|
||||
let weight = op.weight();
|
||||
op.slice((progress, message) => {
|
||||
|
|
@ -230,10 +232,11 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
// console.log('reshadow', progress.round(3));
|
||||
});
|
||||
}
|
||||
tracker.rotation = axisRotation;
|
||||
camOps.push(op);
|
||||
opSum += weight;
|
||||
}
|
||||
trackWidget(undefined);
|
||||
setSliceTracker();
|
||||
|
||||
// reindex
|
||||
sliceAll.forEach((slice, index) => slice.index = index);
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ const { util } = base;
|
|||
const POLY = base.polygons;
|
||||
const NOKEY = key.NONE;
|
||||
|
||||
let tracked;
|
||||
let tracker;
|
||||
|
||||
function trackWidget(widget) {
|
||||
tracked = widget;
|
||||
function setSliceTracker(nv) {
|
||||
return tracker = nv;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,12 +45,8 @@ class Slice {
|
|||
output() {
|
||||
if (this.layers) return this.layers;
|
||||
let layers = this.layers = new kiri.Layers();
|
||||
if (tracked) {
|
||||
let { track } = tracked;
|
||||
let { indexed, indexRad } = track;
|
||||
if (indexed) {
|
||||
layers.setRotation(indexRad);
|
||||
}
|
||||
if (tracker) {
|
||||
layers.setRotation(-tracker.rotation || 0);
|
||||
}
|
||||
return layers;
|
||||
};
|
||||
|
|
@ -254,7 +250,7 @@ gapp.overlay(kiri, {
|
|||
Slice,
|
||||
newTop,
|
||||
newSlice,
|
||||
trackWidget
|
||||
setSliceTracker
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ class Widget {
|
|||
top = track.top,
|
||||
tz = tzoff !== top ? -tzoff : 0,
|
||||
{ x, y, z } = track.pos;
|
||||
console.trace('ump', {top, tz, tzoff});
|
||||
// console.trace('ump', {top, tz, tzoff});
|
||||
if (track.indexed) {
|
||||
let rad = track.indexRad;
|
||||
let ln = track.box.d / 2;
|
||||
|
|
@ -658,16 +658,9 @@ class Widget {
|
|||
// if indexed, return points rotated about X and then offset
|
||||
let track = this.track;
|
||||
if (translate && track.indexed) {
|
||||
// console.log(1, new THREE.Box3().setFromBufferAttribute(pos), track.box);
|
||||
let delta = track.delta;
|
||||
pos = pos.clone().applyMatrix4(
|
||||
new THREE.Matrix4().makeTranslation(0, 0, -track.box.d/2)
|
||||
).applyMatrix4(
|
||||
new THREE.Matrix4().makeRotationX(-track.indexRad)
|
||||
).applyMatrix4(
|
||||
new THREE.Matrix4().makeTranslation(0, 0, track.box.d/2)
|
||||
);
|
||||
// console.log(2, new THREE.Box3().setFromBufferAttribute(pos));
|
||||
pos = pos.clone()
|
||||
.applyMatrix4( new THREE.Matrix4().makeRotationX(-track.indexRad) );
|
||||
}
|
||||
pos = pos.array;
|
||||
if (geo.index && unroll !== false) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue