diff --git a/js/geo-polygons.js b/js/geo-polygons.js index ec2c0c1e..41faac4b 100644 --- a/js/geo-polygons.js +++ b/js/geo-polygons.js @@ -422,7 +422,9 @@ var gs_base_polygons = exports; if (out) out.appendAll(polys); if (collector) collector(polys, count); - if ((count === 0 || count > 1) && polys.length > 0) expand(polys, distance2 || distance, z, out, count > 0 ? count-1 : 0, distance2, collector); + if ((count === 0 || count > 1) && polys.length > 0) { + expand(polys, distance2 || distance, z, out, count > 0 ? count-1 : 0, distance2, collector); + } return polys; } diff --git a/js/kiri-slice.js b/js/kiri-slice.js index bb15183c..e440f127 100644 --- a/js/kiri-slice.js +++ b/js/kiri-slice.js @@ -82,11 +82,11 @@ var gs_kiri_slice = exports; */ function Top(polygon) { this.poly = polygon; // outline poly - this.traces = null; // array of offset/inset trace polygons - this.inner = null; // array of inner fillable polygon areas (inside last trace) - this.outer = null; // array of outer trace polygons - this.fill_lines = null; // array of solid fill lines - this.fill_sparse = null; // array of sparse fill polygons + this.traces = null; // array of offset/inset trace polygons (ordered outer to inner) + this.inner = null; // array of inner fillable areas (inset from last trace) + this.outer = null; // array of outer trace polygons (TODO remove) + this.fill_lines = null; // solid fill lines (array of points) + this.fill_sparse = null; // sparse fill area open polygons (poly lines) this.solids = null; // solid fill regions in otherwise sparse fill (from solids.trimmed) } @@ -178,7 +178,7 @@ var gs_kiri_slice = exports; }; /** - * Appends all top polygons into a given array and returns it + * Returns all top polygons as an array * * @param {Polygon[]} out array to populate * @returns {Polygon[]} array of top polygons @@ -375,13 +375,17 @@ var gs_kiri_slice = exports; last = [top.poly].clone(true); top.traces = last; } else { - POLY.expand([top.poly], -offset1, top.poly.getZ(), top.traces, count, -offsetN, function(polys, count2) { - if (count === count2) top.outer = polys; + POLY.expand([top.poly], -offset1, top.poly.getZ(), top.traces, count, -offsetN, function(polys, countNow) { + // first offset is the outer poly group (max count #) + if (count === countNow) top.outer = polys; last = polys; + // mark each poly with depth (offset #) starting at 0 + polys.forEach(function(p) { p.depth = count - countNow }); }); } } + // generate fill offset poly set from last offset to top.inner if (fillOffset && last.length > 0) { last.forEach(function(inner) { POLY.trace2count(inner, top.inner, fillOffset, 1, 0); diff --git a/package.json b/package.json index 712574b6..8a7f654a 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,9 @@ "express-useragent": "^1.0.8", "leveldown": "^1.9.0", "levelup": "^1.3.9", - "moment": "^2.19.1", + "moment": "^2.19.3", "n3d-threejs": "^72.0.0", - "pixi.js": "^4.6.0", + "pixi.js": "^4.6.2", "request": "^2.83.0", "serve-static": "^1.13.1", "tween.js": "^0.14.0",