diff --git a/src/kiri/widget.js b/src/kiri/widget.js index db2b9cdd..b1edc150 100644 --- a/src/kiri/widget.js +++ b/src/kiri/widget.js @@ -505,6 +505,12 @@ this.center(false); }; + PRO.rotateRaw = function(x, y, z, temp) { + this.group.forEach(w => { + w._rotate(x, y, z, temp); + }); + }; + PRO._rotate = function(x, y, z, temp) { if (!temp) { this.bounds = null; diff --git a/src/kiri/worker.js b/src/kiri/worker.js index d74a5854..9e150342 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -98,10 +98,10 @@ KIRI.worker = { let x = vert[i++]; let y = vert[i++]; let z = vert[i++]; - if (z < 0.01) { + // if (z < 0.01) { miny = Math.min(miny, y); maxy = Math.max(maxy, y); - } + // } } return { miny, maxy }; } @@ -116,19 +116,19 @@ KIRI.worker = { for (let group of Object.values(wgroup)) { let { miny, maxy } = gmin(group); - let widget = group[0]; let track = widget.track; let xpos = track.pos.x; let ypos = settings.device.bedDepth / 2 + track.pos.y + miny; let rotation = (Math.PI / 180) * 45; - // move to accomodate anchor ypos += (settings.process.firstLayerBeltLead || 0); - - widget.rotate(rotation,0,0,true); + for (let w of group) { + w.moveMesh(0, miny, 0); + } + widget.rotateRaw(rotation,0,0,true); let minr = gmin(group); - widget.belt = { xpos, ypos, yadd: minr.maxy - minr.miny }; + widget.belt = { xpos, ypos, yadd: minr.maxy - minr.miny, dy: -miny, dz: 0 }; for (let others of group.slice(1)) { others.belt = widget.belt; } @@ -146,11 +146,8 @@ KIRI.worker = { let rotation = (Math.PI / 180) * 45; for (let group of Object.values(wgroup)) { let widget = group[0]; - widget.groupBounds(); - widget.rotate(-rotation,0,0,true); - let { dy, dz } = widget.track.center; - widget.groupBounds(); let { xpos, ypos } = widget.belt; + let { dy, dz } = widget.belt; // move to accomodate anchor dy -= (settings.process.firstLayerBeltLead || 0) ; widget.rotinfo = { angle: 45, dy, dz, xpos, ypos }; diff --git a/src/mode/fdm/prepare.js b/src/mode/fdm/prepare.js index a7b0b552..30e76e9b 100644 --- a/src/mode/fdm/prepare.js +++ b/src/mode/fdm/prepare.js @@ -305,8 +305,8 @@ let o = rotinfo.ypos * beltfact; offset = { x: rotinfo.xpos, - y: o - belt.midy - belt.yadd/2, - z: o, + y: o, + z: o }; // offset = { x:0, y:0, z:0 }; // locate the lowest point in slices and widget overall @@ -322,11 +322,6 @@ } } } - // todo remove b/c this is now calculated at slice time - // flag slices as being on or off the bed / belt - // for (let slice of widget.slices) { - // slice.onbelt = Math.abs(minby - slice.minby) < 0.01; - // } } else { // when rafts used this is non-zero offset.z = zoff; @@ -495,12 +490,6 @@ } } - // add lead in, when specified - // if (process.firstLayerBeltLead) { - // // add belt lead in - // console.log({process, output}); - // } - let thresh = firstLayerHeight * 0.25; let seqn = 0; // iterate over layers, find extrusion on belt and diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 4e73883f..5cca6a72 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -332,8 +332,9 @@ // also find max width of first 5 layers let start; let minx = Infinity, maxx = -Infinity; + let peek = 0; for (let slice of slices) { - if (slice.index < 5) { + if (slice.groups.length && peek++ < 5) { for (let poly of slice.topPolys()) { minx = Math.min(minx, poly.bounds.minx); maxx = Math.max(maxx, poly.bounds.maxx);