fix layer height render bug

This commit is contained in:
Stewart Allen 2020-11-07 20:31:18 -05:00
commit f00db73494
2 changed files with 16 additions and 12 deletions

View file

@ -132,6 +132,7 @@
addPaths(polys, options) { addPaths(polys, options) {
const opts = options || {}; const opts = options || {};
const height = opts.height || 1;
const offset = opts.offset || 1; const offset = opts.offset || 1;
polys = flat(polys); polys = flat(polys);
if (!polys.length) { if (!polys.length) {
@ -139,15 +140,16 @@
} }
const profiles = this.profiles; const profiles = this.profiles;
if (!profiles[offset]) { const prokey = `${offset}x${height}`;
if (!profiles[prokey]) {
const profile = new THREE.Shape(); const profile = new THREE.Shape();
profile.moveTo(-offset, -offset); profile.moveTo(-offset, -height);
profile.lineTo(-offset, offset); profile.lineTo(-offset, height);
profile.lineTo( offset, offset); profile.lineTo( offset, height);
profile.lineTo( offset, -offset); profile.lineTo( offset, -height);
profiles[offset] = profile; profiles[prokey] = profile;
} }
const profile = profiles[offset].clone(); const profile = profiles[prokey].clone();
polys.forEach(poly => { polys.forEach(poly => {
const contour = []; const contour = [];

View file

@ -6,6 +6,7 @@
const KIRI = self.kiri, const KIRI = self.kiri,
BASE = self.base, BASE = self.base,
DBUG = BASE.debug,
POLY = BASE.polygons, POLY = BASE.polygons,
UTIL = BASE.util, UTIL = BASE.util,
CONF = BASE.config, CONF = BASE.config,
@ -414,6 +415,7 @@
function doRender(slice) { function doRender(slice) {
const output = slice.output(); const output = slice.output();
const height = slice.height / 2;
slice.tops.forEach(top => { slice.tops.forEach(top => {
if (isThin) { if (isThin) {
@ -424,7 +426,7 @@
output output
.setLayer("shells", COLOR.shell) .setLayer("shells", COLOR.shell)
.addPolys(top.shells, vopt({ offset })); .addPolys(top.shells, vopt({ offset, height }));
// if (isThin && debug) { // if (isThin && debug) {
// slice.output() // slice.output()
@ -436,11 +438,11 @@
if (top.fill_lines) output if (top.fill_lines) output
.setLayer("fill", COLOR.fill) .setLayer("fill", COLOR.fill)
.addLines(top.fill_lines, vopt({ offset })); .addLines(top.fill_lines, vopt({ offset, height }));
if (top.fill_sparse) output if (top.fill_sparse) output
.setLayer("infill", COLOR.infill) .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 // emit solid areas
// if (isThin && debug) { // if (isThin && debug) {
@ -452,12 +454,12 @@
if (slice.supports) output if (slice.supports) output
.setLayer("support", COLOR.support) .setLayer("support", COLOR.support)
.addPolys(slice.supports, vopt({ offset })); .addPolys(slice.supports, vopt({ offset, height }));
if (slice.supports) slice.supports.forEach(poly => { if (slice.supports) slice.supports.forEach(poly => {
output output
.setLayer("support", COLOR.support) .setLayer("support", COLOR.support)
.addLines(poly.fill, vopt({ offset })); .addLines(poly.fill, vopt({ offset, height }));
}) })
// if (isThin && debug) { // if (isThin && debug) {