diff --git a/notes.md b/notes.md index 16d0d45b..8bc02b46 100644 --- a/notes.md +++ b/notes.md @@ -14,7 +14,6 @@ * `F` show slider range values in workspace units (on hover?) * `F` allow select of a range by typing in values in slices or workspace units * `F` add % field type with conversion (like units) -* `F` complete G2/G3 arc output / input (85% now) * `F` complete and expose grouping feature * `F` add svgnest-like arrange algorithm diff --git a/src/kiri/main.js b/src/kiri/main.js index f5fc830e..17d14547 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -1059,6 +1059,9 @@ console.log/** Copyright Stewart Allen -- All Rights Reserved */ widget.stack = STACKS.create(widget.id, widget.mesh), factor = (widget.getVertices().count / defvert); + // compensate for zcut (widget moved through floor) + widget.stack.obj.view.position.z = widget.track.zcut; + widget.slice(settings, function(sliced, error) { widget.rotinfo = null; let mark = Date.now(); diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index 378a3dc8..e147799e 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -53,10 +53,20 @@ */ function slice(points, bounds, options, ondone, onupdate) { let useFlats = options.flats, + zCut = options.zCut || 0, xray = options.xray, ox = 0, oy = 0; + if (zCut) { + for (let p of points) { + if (!p._z) { + p._z = p.z; + p.z -= zCut; + } + } + } + let zMin = options.zmin || options.firstHeight || Math.floor(bounds.min.z), zMax = options.zmax || Math.ceil(bounds.max.z), zInc = options.height, diff --git a/src/kiri/widget.js b/src/kiri/widget.js index bcfb7f03..b11967cd 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -438,7 +438,6 @@ console.log/** Copyright Stewart Allen -- All Rights Reserved */ /** * moves top of widget to given Z - * used in CAM mode * * @param {number} z position */ @@ -453,7 +452,7 @@ console.log/** Copyright Stewart Allen -- All Rights Reserved */ this.track.top = z; } else { pos.z = 0; - mesh.position.z = 0; + mesh.position.z = -this.track.zcut || 0; this.track.top = mbz; } let ntz = { @@ -462,7 +461,12 @@ console.log/** Copyright Stewart Allen -- All Rights Reserved */ }; this.modified |= (ltz.pz !== ntz.pz || ltz.mpz !== ntz.mpz); this.last_top_z = ntz; - } + }; + + PRO.cutZ = function(dist) { + this.track.zcut = dist; + this.setTopZ(); + }; PRO.move = function(x, y, z, abs) { this.group.forEach(w => { @@ -472,11 +476,12 @@ console.log/** Copyright Stewart Allen -- All Rights Reserved */ PRO._move = function(x, y, z, abs) { let mesh = this.mesh, - pos = this.track.pos; - // do not allow moves in pure slice view + pos = this.track.pos, + zcut = this.track.zcut || 0; + // do not allow moves in pure slice view if (!mesh.material.visible) return; if (abs) { - mesh.position.set(x,y,z); + mesh.position.set(x, y, z - zcut); pos.x = (x || 0); pos.y = (y || 0); pos.z = (z || 0); diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 8a8f09a9..a7a33904 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -178,6 +178,7 @@ SLICER.sliceWidget(widget, { mode: 'FDM', + zCut: widget.track.zcut || 0, height: sliceHeight, minHeight: sliceMinHeight, firstHeight: sliceHeightBase,