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 = [];
|
stockSlices = [];
|
||||||
const { x, y, z } = stock;
|
const { x, y, z } = stock;
|
||||||
const sliceCount = 10;
|
const sliceCount = 20;
|
||||||
const sliceWidth = stock.x / sliceCount;
|
const sliceWidth = stock.x / sliceCount;
|
||||||
for (let i=0; i<sliceCount; i++) {
|
for (let i=0; i<sliceCount; i++) {
|
||||||
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
||||||
|
|
|
||||||
|
|
@ -594,6 +594,7 @@ CAM.init = function(kiri, api) {
|
||||||
widget.setAxisIndex(-index);
|
widget.setAxisIndex(-index);
|
||||||
}
|
}
|
||||||
currentIndex = isIndexed ? index * (Math.PI / 180) : 0;
|
currentIndex = isIndexed ? index * (Math.PI / 180) : 0;
|
||||||
|
updateStock();
|
||||||
});
|
});
|
||||||
|
|
||||||
func.opGCode = (label, field = 'gcode') => {
|
func.opGCode = (label, field = 'gcode') => {
|
||||||
|
|
@ -1496,14 +1497,16 @@ function createPopOp(type, map) {
|
||||||
}
|
}
|
||||||
if (op.note) {
|
if (op.note) {
|
||||||
const { divid, noteid } = 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 || '');
|
let note = op.x = prompt('Edit Note for Operation', poppedRec.note || '');
|
||||||
if (note !== undefined && note !== null) {
|
if (note !== undefined && note !== null) {
|
||||||
$(noteid).innerText = poppedRec.note = note;
|
$(noteid).innerText = poppedRec.note = note;
|
||||||
API.conf.save();
|
API.conf.save();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$(noteid).innerText = poppedRec.note || '';
|
const note = $(noteid);
|
||||||
|
if (note) note.innerText = poppedRec.note || '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
group: [],
|
group: [],
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class OpIndex extends CamOp {
|
||||||
|
|
||||||
slice() {
|
slice() {
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
state.setAxisIndex(op.degrees);
|
state.setAxisIndex(op.degrees, op.absolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
|
|
@ -626,7 +626,7 @@ class OpOutline extends CamOp {
|
||||||
|
|
||||||
// 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 (true) slice.output()
|
||||||
.setLayer("slice", {line: 0xaaaa00}, false)
|
.setLayer("slice", {line: 0xaaaa00}, false)
|
||||||
.addPolys(slice.topPolys())
|
.addPolys(slice.topPolys())
|
||||||
slice.output()
|
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, trackWidget } = kiri;
|
const { driver, newSlice, setSliceTracker } = kiri;
|
||||||
const { polygons, newPoint, newPolygon } = base;
|
const { polygons, newPoint, newPolygon } = base;
|
||||||
const { CAM } = driver;
|
const { CAM } = driver;
|
||||||
const { OPS } = CAM;
|
const { OPS } = CAM;
|
||||||
|
|
@ -44,13 +44,14 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
zTop = zMax + ztOff,
|
zTop = zMax + ztOff,
|
||||||
minToolDiam = Infinity,
|
minToolDiam = Infinity,
|
||||||
maxToolDiam = -Infinity,
|
maxToolDiam = -Infinity,
|
||||||
thruHoles,
|
|
||||||
dark = settings.controller.dark ? true : false,
|
dark = settings.controller.dark ? true : false,
|
||||||
color = dark ? 0xbbbbbb : 0,
|
color = dark ? 0xbbbbbb : 0,
|
||||||
tabs = widget.anno.tab,
|
tabs = widget.anno.tab,
|
||||||
unsafe = proc.camExpertFast,
|
unsafe = proc.camExpertFast,
|
||||||
units = settings.controller.units === 'in' ? 25.4 : 1,
|
units = settings.controller.units === 'in' ? 25.4 : 1,
|
||||||
axisIndex = undefined;
|
axisRotation,
|
||||||
|
axisIndex,
|
||||||
|
thruHoles;
|
||||||
|
|
||||||
if (tabs) {
|
if (tabs) {
|
||||||
// make tab polygons
|
// make tab polygons
|
||||||
|
|
@ -137,9 +138,10 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
return shadows[z] = POLY.setZ(shadow, z);
|
return shadows[z] = POLY.setZ(shadow, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAxisIndex(degrees) {
|
function setAxisIndex(degrees = 0, absolute = true) {
|
||||||
axisIndex = degrees;
|
axisIndex = absolute ? degrees : axisIndex + degrees;
|
||||||
// state.axisIndex = (Math.PI / 180) * axisIndex;
|
axisRotation = (Math.PI / 180) * axisIndex;
|
||||||
|
widget.setAxisIndex(-axisIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSlices(slices) {
|
function addSlices(slices) {
|
||||||
|
|
@ -211,8 +213,8 @@ 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);
|
let tracker = setSliceTracker({ rotation: 0 });
|
||||||
setAxisIndex(undefined);
|
setAxisIndex();
|
||||||
for (let op of opList) {
|
for (let op of opList) {
|
||||||
let weight = op.weight();
|
let weight = op.weight();
|
||||||
op.slice((progress, message) => {
|
op.slice((progress, message) => {
|
||||||
|
|
@ -230,10 +232,11 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
// console.log('reshadow', progress.round(3));
|
// console.log('reshadow', progress.round(3));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
tracker.rotation = axisRotation;
|
||||||
camOps.push(op);
|
camOps.push(op);
|
||||||
opSum += weight;
|
opSum += weight;
|
||||||
}
|
}
|
||||||
trackWidget(undefined);
|
setSliceTracker();
|
||||||
|
|
||||||
// reindex
|
// reindex
|
||||||
sliceAll.forEach((slice, index) => slice.index = index);
|
sliceAll.forEach((slice, index) => slice.index = index);
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ const { util } = base;
|
||||||
const POLY = base.polygons;
|
const POLY = base.polygons;
|
||||||
const NOKEY = key.NONE;
|
const NOKEY = key.NONE;
|
||||||
|
|
||||||
let tracked;
|
let tracker;
|
||||||
|
|
||||||
function trackWidget(widget) {
|
function setSliceTracker(nv) {
|
||||||
tracked = widget;
|
return tracker = nv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,12 +45,8 @@ class Slice {
|
||||||
output() {
|
output() {
|
||||||
if (this.layers) return this.layers;
|
if (this.layers) return this.layers;
|
||||||
let layers = this.layers = new kiri.Layers();
|
let layers = this.layers = new kiri.Layers();
|
||||||
if (tracked) {
|
if (tracker) {
|
||||||
let { track } = tracked;
|
layers.setRotation(-tracker.rotation || 0);
|
||||||
let { indexed, indexRad } = track;
|
|
||||||
if (indexed) {
|
|
||||||
layers.setRotation(indexRad);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return layers;
|
return layers;
|
||||||
};
|
};
|
||||||
|
|
@ -254,7 +250,7 @@ gapp.overlay(kiri, {
|
||||||
Slice,
|
Slice,
|
||||||
newTop,
|
newTop,
|
||||||
newSlice,
|
newSlice,
|
||||||
trackWidget
|
setSliceTracker
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,7 @@ class Widget {
|
||||||
top = track.top,
|
top = track.top,
|
||||||
tz = tzoff !== top ? -tzoff : 0,
|
tz = tzoff !== top ? -tzoff : 0,
|
||||||
{ x, y, z } = track.pos;
|
{ x, y, z } = track.pos;
|
||||||
console.trace('ump', {top, tz, tzoff});
|
// console.trace('ump', {top, tz, tzoff});
|
||||||
if (track.indexed) {
|
if (track.indexed) {
|
||||||
let rad = track.indexRad;
|
let rad = track.indexRad;
|
||||||
let ln = track.box.d / 2;
|
let ln = track.box.d / 2;
|
||||||
|
|
@ -658,16 +658,9 @@ class Widget {
|
||||||
// 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 (translate && track.indexed) {
|
if (translate && track.indexed) {
|
||||||
// console.log(1, new THREE.Box3().setFromBufferAttribute(pos), track.box);
|
|
||||||
let delta = track.delta;
|
let delta = track.delta;
|
||||||
pos = pos.clone().applyMatrix4(
|
pos = pos.clone()
|
||||||
new THREE.Matrix4().makeTranslation(0, 0, -track.box.d/2)
|
.applyMatrix4( new THREE.Matrix4().makeRotationX(-track.indexRad) );
|
||||||
).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.array;
|
pos = pos.array;
|
||||||
if (geo.index && unroll !== false) {
|
if (geo.index && unroll !== false) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue