correct slice offsets when indexed
This commit is contained in:
parent
77c8b0299c
commit
430f85120a
6 changed files with 39 additions and 23 deletions
|
|
@ -104,8 +104,8 @@ kiri.load(() => {
|
|||
geo.setIndex(new THREE.BufferAttribute(ia, 1));
|
||||
const mat = new THREE.MeshMatcapMaterial({
|
||||
flatShading: true,
|
||||
transparent: false,
|
||||
opacity: 1,
|
||||
transparent: true,
|
||||
opacity: 0.1,
|
||||
color: 0x888888,
|
||||
side: THREE.DoubleSide
|
||||
});
|
||||
|
|
@ -385,7 +385,7 @@ kiri.load(() => {
|
|||
|
||||
stockSlices = [];
|
||||
const { x, y, z } = stock;
|
||||
const sliceCount = 20;
|
||||
const sliceCount = 1;
|
||||
const sliceWidth = stock.x / sliceCount;
|
||||
for (let i=0; i<sliceCount; i++) {
|
||||
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
||||
|
|
|
|||
|
|
@ -65,27 +65,32 @@ CAM.init = function(kiri, api) {
|
|||
return API.conf.get().process.camZBottom > 0;
|
||||
}
|
||||
|
||||
function setAnimationStyle(settings) {
|
||||
let changed = isIndexed !== settings.process.camStockIndexed;
|
||||
isIndexed = settings.process.camStockIndexed;
|
||||
function setAnimationStyle() {
|
||||
const { camStockIndexed, camStockOn } = current.process;
|
||||
let newIndexed = camStockIndexed && camStockOn;
|
||||
let changed = isIndexed !== newIndexed;
|
||||
isIndexed = newIndexed;
|
||||
if (!isIndexed || !isCamMode) {
|
||||
for (let widget of API.widgets.all()) {
|
||||
widget.setAxisIndex(0);
|
||||
}
|
||||
}
|
||||
if (!(isCamMode && changed)) {
|
||||
if (!isCamMode) {
|
||||
return;
|
||||
}
|
||||
if (isIndexed) {
|
||||
settings.process.camZAnchor = "middle";
|
||||
current.process.camZAnchor = "middle";
|
||||
}
|
||||
animVer = isIndexed ? 1 : 0;
|
||||
SPACE.platform.setVisible(!isIndexed);
|
||||
$('cam-index').style.display = isIndexed ? '' : 'none';
|
||||
if (!changed) {
|
||||
return;
|
||||
}
|
||||
for (let widget of api.widgets.all()) {
|
||||
widget.setIndexed(camStock && isIndexed ? camStock.scale.z : 0);
|
||||
}
|
||||
api.platform.update_top_z();
|
||||
$('cam-index').style.display = isIndexed ? '' : 'none';
|
||||
// add or remove clock op depending on indexing
|
||||
const cp = current.process;
|
||||
if (!cp.ops) {
|
||||
|
|
@ -104,7 +109,7 @@ CAM.init = function(kiri, api) {
|
|||
|
||||
api.event.on("widget.add", widget => {
|
||||
if (isCamMode) {
|
||||
setAnimationStyle(api.conf.get());
|
||||
setAnimationStyle();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -173,7 +178,7 @@ CAM.init = function(kiri, api) {
|
|||
api.ui.camTabs.marker.style.display = hasTabs ? 'flex' : 'none';
|
||||
api.ui.camStock.marker.style.display = proc.camStockOn ? 'flex' : 'none';
|
||||
updateStock(settings, 'settings.saved.internal');
|
||||
setAnimationStyle(settings);
|
||||
setAnimationStyle();
|
||||
func.opRender();
|
||||
});
|
||||
|
||||
|
|
@ -182,9 +187,11 @@ CAM.init = function(kiri, api) {
|
|||
if (!isCamMode) return;
|
||||
validateTools(settings.tools);
|
||||
restoreTabs(api.widgets.all());
|
||||
setAnimationStyle(settings);
|
||||
setAnimationStyle();
|
||||
});
|
||||
|
||||
api.event.on("boolean.click", api.platform.update_top_z);
|
||||
|
||||
api.event.on([
|
||||
"init-done",
|
||||
"view.set",
|
||||
|
|
|
|||
|
|
@ -481,6 +481,7 @@ class OpOutline extends CamOp {
|
|||
max: op.top ? zMax + ztOff : undefined
|
||||
};
|
||||
let indices = slicer.interval(op.down, intopt);
|
||||
console.log({slicer, indices, zBottom});
|
||||
let trueShadow = process.camTrueShadow === true;
|
||||
// shift out first (top-most) slice
|
||||
indices.shift();
|
||||
|
|
|
|||
|
|
@ -31,14 +31,22 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
proc = settings.process,
|
||||
stock = settings.stock || {},
|
||||
hasStock = stock.x && stock.y && stock.z && proc.camStockOn,
|
||||
isIndexed = hasStock && proc.camStockIndexed,
|
||||
camOps = widget.camops = [],
|
||||
sliceAll = widget.slices = [],
|
||||
bounds = widget.getBoundingBox(),
|
||||
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),
|
||||
track = widget.track,
|
||||
// widget top z as defined by setTopz()
|
||||
wztop = track.top,
|
||||
// distance between top of part and top of stock
|
||||
ztOff = isIndexed ? 0 : (hasStock ? stock.z - wztop : 0),
|
||||
// distance between bottom of part and bottom of stock
|
||||
zbOff = isIndexed ? 0 : (hasStock ? wztop - track.box.d : 0),
|
||||
// defined z bottom offset by distance to stock bottom
|
||||
// keeps the z bottom relative to the part when z align changes
|
||||
zBottom = isIndexed ? bounds.min.z : proc.camZBottom - zbOff,
|
||||
// greater of widget bottom and z bottom
|
||||
zMin = isIndexed ? bounds.min.z : Math.max(bounds.min.z, zBottom),
|
||||
zMax = bounds.max.z,
|
||||
zThru = proc.camZBottom ? 0 : (proc.camZThru || 0),
|
||||
zTop = zMax + ztOff,
|
||||
|
|
@ -141,7 +149,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
function setAxisIndex(degrees = 0, absolute = true) {
|
||||
axisIndex = absolute ? degrees : axisIndex + degrees;
|
||||
axisRotation = (Math.PI / 180) * axisIndex;
|
||||
widget.setAxisIndex(-axisIndex);
|
||||
widget.setAxisIndex(isIndexed ? -axisIndex : 0);
|
||||
}
|
||||
|
||||
function addSlices(slices) {
|
||||
|
|
@ -232,7 +240,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
|||
// console.log('reshadow', progress.round(3));
|
||||
});
|
||||
}
|
||||
tracker.rotation = axisRotation;
|
||||
tracker.rotation = isIndexed ? axisRotation : 0;
|
||||
camOps.push(op);
|
||||
opSum += weight;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1918,12 +1918,12 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
camStockOffset: uc.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}),
|
||||
camStockClipTo: uc.newBoolean(LANG.cs_clip_s, onBooleanClick, {title:LANG.cs_clip_l, modes:CAM}),
|
||||
camSep: uc.newBlank({class:"pop-sep"}),
|
||||
camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM, show: () => ui.camStockOn.checked}),
|
||||
camStockIndexed: uc.newBoolean(LANG.cs_indx_s, onBooleanClick, {title:LANG.cs_indx_l, modes:CAM, show:() => ui.camStockOn.checked}),
|
||||
camStockOn: uc.newBoolean(LANG.cs_offe_s, onBooleanClick, {title:LANG.cs_offe_l, modes:CAM}),
|
||||
|
||||
camCommon: uc.newGroup(LANG.cc_menu, null, {modes:CAM}),
|
||||
camZAnchor: uc.newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, modes:CAM, trace:true}, "zanchor"),
|
||||
camSep: uc.newBlank({class:"pop-sep"}),
|
||||
camZAnchor: uc.newSelect(LANG.ou_zanc_s, {title: LANG.ou_zanc_l, action:zAnchorSave, modes:CAM, trace:true, show:() => ui.camStockOn.checked && !ui.camStockIndexed.checked}, "zanchor"),
|
||||
camSep: uc.newBlank({class:"pop-sep", show:() => ui.camStockOn.checked && !ui.camStockIndexed.checked}),
|
||||
camZOffset: uc.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:uc.toFloat, modes:CAM, units:true}),
|
||||
camZBottom: uc.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:uc.toFloat, modes:CAM, units:true, trigger: true}),
|
||||
camZThru: uc.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:uc.toFloat, bound:uc.bound(0.0,100), modes:CAM, units:true, show:() => { return ui.camZBottom.value == 0 }}),
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ function platformUpdateOrigin() {
|
|||
space.platform.setRulers(ruler, ruler, 1 / api.view.unit_scale(), 'X', isBelt ? 'Z' : 'Y');
|
||||
|
||||
let { x, y, z } = origin;
|
||||
let oz = process.camStockIndexed ? z / 2 : z;
|
||||
let oz = process.camStockIndexed && process.camStockOn ? z / 2 : z;
|
||||
if (controller.showOrigin && MODE !== MODES.SLA) {
|
||||
space.platform.setOrigin(x, y, oz, true);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue