diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 877ce4ee..a46d0158 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -66,10 +66,10 @@ CAM.init = function(kiri, api) { return API.conf.get().process.camZBottom > 0; } - function setAnimationStyle() { + function setAnimationStyle(refresh) { const { camStockIndexed, camStockOn } = current.process; let newIndexed = camStockIndexed && camStockOn; - let changed = isIndexed !== newIndexed; + let changed = refresh || isIndexed !== newIndexed; isIndexed = newIndexed; if (!isIndexed || !isCamMode) { for (let widget of API.widgets.all()) { @@ -109,8 +109,10 @@ CAM.init = function(kiri, api) { } api.event.on("widget.add", widget => { - if (isCamMode) { - setAnimationStyle(); + if (isCamMode && !Array.isArray(widget)) { + setAnimationStyle(true); + widget.setIndexed(camStock && isIndexed ? camStock.scale.z : 0); + api.platform.update_top_z(); } }); diff --git a/src/kiri-mode/cam/slice.js b/src/kiri-mode/cam/slice.js index 9a4674fb..4d81779f 100644 --- a/src/kiri-mode/cam/slice.js +++ b/src/kiri-mode/cam/slice.js @@ -44,7 +44,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) { 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, + zBottom = isIndexed ? proc.camZBottom || 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, @@ -110,7 +110,8 @@ CAM.slice = function(settings, widget, onupdate, ondone) { let mark = Date.now(); let slicer = new kiri.cam_slicer(widget.getPoints(), { zlist: true, - zline: true + zline: true, + nobucket: isIndexed }); function updateToolDiams(toolDiam) {