diff --git a/src/kiri/slicer2.js b/src/kiri/slicer2.js index debd1568..0d094cfc 100644 --- a/src/kiri/slicer2.js +++ b/src/kiri/slicer2.js @@ -400,13 +400,21 @@ } if (opt.flats && opt.off) { + let add = []; + Object.keys(this.zFlat).forEach(z => { + z = parseFloat(z); + add.push(z + opt.off); + if (z > zmin) { + add.push(z - opt.off); + } + }); // add over and under all flats by 'off' - array.appendAll(Object.keys(this.zFlat).map(v => parseFloat(v))).sort((a,b) => { + array.appendAll(add).sort((a,b) => { return opt.down ? b-a : a-b; }); } - return array.map(v => parseFloat(v.toFixed(2))); + return array.map(v => Math.abs(parseFloat(v.toFixed(2)))); } } diff --git a/src/mode/cam/slice.js b/src/mode/cam/slice.js index 8eae3408..67af4914 100644 --- a/src/mode/cam/slice.js +++ b/src/mode/cam/slice.js @@ -175,7 +175,7 @@ let flats = []; let shadow = []; let slices = []; - let indices = slicer.interval(roughDown, { down: true, min: zBottom, fit: true }); + let indices = slicer.interval(roughDown, { down: true, min: zBottom, fit: true, boff: 0.01 }); if (proc.camRoughFlat) { let flats = Object.keys(slicer.zFlat) .map(v => parseFloat(v).round(4)) @@ -206,6 +206,7 @@ .filter(v => v > 0 && indices.indexOf(v) < 0); indices = indices.appendAll(flats).sort((a,b) => b-a); } + // console.log('indices', ...indices, {zBottom}); slicer.slice(indices, { each: (data, index, total) => { shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true); @@ -309,7 +310,7 @@ let shadow = []; let slices = []; - let indices = slicer.interval(outlineDown, { down: true, min: zBottom, fit: true }); + let indices = slicer.interval(outlineDown, { down: true, min: zBottom, fit: true, boff: 0.01 }); // add flats to shadow const flats = Object.keys(slicer.zFlat) .map(v => (parseFloat(v) - 0.01).round(5))