add z cut option for widgets

This commit is contained in:
Stewart Allen 2021-08-30 13:50:24 -04:00
commit 69f246efb9
5 changed files with 25 additions and 7 deletions

View file

@ -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

View file

@ -1059,6 +1059,9 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- 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();

View file

@ -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,

View file

@ -438,7 +438,6 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- 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 <sa@grid.space> -- 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 <sa@grid.space> -- 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 <sa@grid.space> -- 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);

View file

@ -178,6 +178,7 @@
SLICER.sliceWidget(widget, {
mode: 'FDM',
zCut: widget.track.zcut || 0,
height: sliceHeight,
minHeight: sliceMinHeight,
firstHeight: sliceHeightBase,