diff --git a/package.json b/package.json index c04c2fdf..8b49090c 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "connect": "^3.7.0", "earcut": "^2.2.3", "express-useragent": "^1.0.13", - "@jscad/modeling": "^2.9.2", + "@jscad/modeling": "^2.9.5", "jszip": "^3.7.1", "moment": "^2.24.0", "pixi.js": "^4.8.9", diff --git a/src/add/array.js b/src/add/array.js index a2449742..8530bd99 100644 --- a/src/add/array.js +++ b/src/add/array.js @@ -35,6 +35,12 @@ AP.peek = function() { return this[this.length - 1]; }; +AP.drop = function(pre = 0, post = 0) { + while (pre-- > 0) this.shift(); + while (post-- > 0) this.pop(); + return this; +}; + /** * allow chaining of push() calls */ diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 11ba8b3c..f4286781 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -1597,18 +1597,17 @@ class Polygon { * @param {Polygon} poly clipping mask * @returns {?Polygon[]} */ - mask(poly, nullOnEquiv) { + mask(poly, nullOnEquiv, minarea) { let fillang = this.fillang && this.area() > poly.area() ? this.fillang : poly.fillang, clip = new clib.Clipper(), ctre = new clib.PolyTree(), sp1 = this.toClipper(), sp2 = poly.toClipper(); - clip.AddPaths(sp1, ptyp.ptSubject, true); clip.AddPaths(sp2, ptyp.ptClip, true); if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) { - poly = POLY.fromClipperTree(ctre, poly.getZ()); + poly = POLY.fromClipperTree(ctre, this.getZ(), undefined, undefined, minarea); poly.forEach(p => { p.fillang = fillang; }) @@ -1779,6 +1778,29 @@ class Polygon { return null; } + + annotate(obj = {}) { + Object.assign(this, obj); + return this; + } + + extrude(z = 1) { + let poly = this.clone().setClockwise(); + let faces = []; + let points = poly.points; + let length = points.length; + for (let i=0; i { +gapp.register("geo.polygons", [], (root, exports) => { const { base } = root; const { util, config, newPoint } = base; @@ -388,7 +388,7 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) { } } - let out = polys.slice(), i, j, union, uset = []; + let out = polys.slice(), i, j, union, uset = [], a, b; outer: for (i=0; i { const group = i % 5; diff --git a/src/kiri/api.js b/src/kiri/api.js index 90f60d13..fbb4881d 100644 --- a/src/kiri/api.js +++ b/src/kiri/api.js @@ -47,8 +47,9 @@ const devel = { xray: (layers, raw) => { let proc = api.conf.get().process; let size = proc.sliceHeight || proc.slaSlice || 1; + let base = (proc.firstSliceHeight || size); layers = Array.isArray(layers) ? layers : [ layers ]; - proc.xray = layers.map(l => raw ? l : l * size + size / 2); + proc.xray = layers.map(l => raw ? l : base + l * size - size / 2); api.function.slice(); } }; diff --git a/src/load/obj.js b/src/load/obj.js index 58138b6a..cc3cfd30 100644 --- a/src/load/obj.js +++ b/src/load/obj.js @@ -59,7 +59,6 @@ function parse(text) { break; } } - return objs; } diff --git a/src/main/mesh.js b/src/main/mesh.js index 30a0f375..67eee197 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -12,6 +12,7 @@ // dep: mesh.model // dep: mesh.build // dep: load.file +// use: geo.polygons gapp.main("main.mesh", [], (root) => { const { Quaternion, Mesh, MeshPhongMaterial, PlaneGeometry, DoubleSide, Vector3 } = THREE; diff --git a/web/mesh/index.css b/web/mesh/index.css index 875ef009..00c0cfab 100644 --- a/web/mesh/index.css +++ b/web/mesh/index.css @@ -432,6 +432,7 @@ button.selected:hover { #modes { position: absolute; + gap: 2px; top: 0; left: 50%; transform: translateX(-50%);