From f00db734946e0346986a023bd3046b2eeb3ee75f Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 7 Nov 2020 20:31:18 -0500 Subject: [PATCH] fix layer height render bug --- src/kiri/render.js | 16 +++++++++------- src/mode/fdm/slice.js | 12 +++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/kiri/render.js b/src/kiri/render.js index 540c6891..a16f613a 100644 --- a/src/kiri/render.js +++ b/src/kiri/render.js @@ -132,6 +132,7 @@ addPaths(polys, options) { const opts = options || {}; + const height = opts.height || 1; const offset = opts.offset || 1; polys = flat(polys); if (!polys.length) { @@ -139,15 +140,16 @@ } const profiles = this.profiles; - if (!profiles[offset]) { + const prokey = `${offset}x${height}`; + if (!profiles[prokey]) { const profile = new THREE.Shape(); - profile.moveTo(-offset, -offset); - profile.lineTo(-offset, offset); - profile.lineTo( offset, offset); - profile.lineTo( offset, -offset); - profiles[offset] = profile; + profile.moveTo(-offset, -height); + profile.lineTo(-offset, height); + profile.lineTo( offset, height); + profile.lineTo( offset, -height); + profiles[prokey] = profile; } - const profile = profiles[offset].clone(); + const profile = profiles[prokey].clone(); polys.forEach(poly => { const contour = []; diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 4625081d..17360a4d 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -6,6 +6,7 @@ const KIRI = self.kiri, BASE = self.base, + DBUG = BASE.debug, POLY = BASE.polygons, UTIL = BASE.util, CONF = BASE.config, @@ -414,6 +415,7 @@ function doRender(slice) { const output = slice.output(); + const height = slice.height / 2; slice.tops.forEach(top => { if (isThin) { @@ -424,7 +426,7 @@ output .setLayer("shells", COLOR.shell) - .addPolys(top.shells, vopt({ offset })); + .addPolys(top.shells, vopt({ offset, height })); // if (isThin && debug) { // slice.output() @@ -436,11 +438,11 @@ if (top.fill_lines) output .setLayer("fill", COLOR.fill) - .addLines(top.fill_lines, vopt({ offset })); + .addLines(top.fill_lines, vopt({ offset, height })); if (top.fill_sparse) output .setLayer("infill", COLOR.infill) - .addPolys(top.fill_sparse, vopt({ offset, open: true, outline: true })) + .addPolys(top.fill_sparse, vopt({ offset, height, open: true, outline: true })) // emit solid areas // if (isThin && debug) { @@ -452,12 +454,12 @@ if (slice.supports) output .setLayer("support", COLOR.support) - .addPolys(slice.supports, vopt({ offset })); + .addPolys(slice.supports, vopt({ offset, height })); if (slice.supports) slice.supports.forEach(poly => { output .setLayer("support", COLOR.support) - .addLines(poly.fill, vopt({ offset })); + .addLines(poly.fill, vopt({ offset, height })); }) // if (isThin && debug) {