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) {
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 = [];

View file

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