diff --git a/notes.md b/notes.md index 35f0f998..40c526fb 100644 --- a/notes.md +++ b/notes.md @@ -1,5 +1,9 @@ # Kiri:Moto todo +NEXT +- contour outside part boundaries +- fdm first level height render + ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix * `F` detect and report slow framerates diff --git a/package.json b/package.json index c4f13f6f..4f9a45b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grid-apps", - "version": "2.3.D5", + "version": "2.3.D6", "description": "grid.space 3d slice & modeling tools", "author": "Stewart Allen ", "license": "MIT", diff --git a/src/add/array.js b/src/add/array.js index 8a0202c7..4284973b 100644 --- a/src/add/array.js +++ b/src/add/array.js @@ -6,7 +6,7 @@ var AP = Array.prototype; /** ****************************************************************** - * array prototype helpers + * Array prototype helpers ******************************************************************* */ if (!AP.flat) { @@ -148,7 +148,7 @@ }; /** ****************************************************************** - * string prototype helpers + * String prototype helpers ******************************************************************* */ String.prototype.reverse = function() { @@ -167,4 +167,13 @@ return Math.max(min,Math.min(max,val)); }; + /** ****************************************************************** + * Number static helpers + ******************************************************************* */ + + Number.prototype.round = function(digits) { + const pow = Math.pow(10,digits || 3); + return Math.round(this.valueOf() * pow) / pow; + }; + })(); diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 35f0d322..810d412f 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -221,8 +221,62 @@ return ret; }; - PRO.miter = function() { + function slopeDiff(s1, s2) { + const n1 = s1.angle;//(s1.angle + 360) % 360; + const n2 = s2.angle;//(s2.angle + 360) % 360; + let diff = n2 - n1; + while (diff < -180) diff += 360; + while (diff > 180) diff -= 360; + return Math.abs(diff); + } + + PRO.miter = function(debug) { + if (this.length < 3) return this; + // todo - to eliminate path sharps in renders + const slo = [], pa = this.points, pln = pa.length, open = this.open; + let last; + for (let i=1; i 90; + redo |= ang[0] > 90; + } + if (redo) { + const newp = newPolygon(); + // newp.debug = this.debug = true; + newp.open = open; + for (let i=0; i 90) { + const s = slo[(i+pln) % pln]; + const pp = pa[(i+pln-1) % pln]; + const ps = slo[(i+pln-1) % pln]; + newp.push(p.follow(p.slopeTo(pp), 0.005)); + newp.push(p.follow(s, 0.005)); + } else { + p.parent = newp; + newp.push(p); + } + } + return newp; + } + return this; }; PRO.createConvexHull = function(points) { diff --git a/src/geo/slope.js b/src/geo/slope.js index 93f747d1..8f6ee07f 100644 --- a/src/geo/slope.js +++ b/src/geo/slope.js @@ -91,7 +91,7 @@ PRO.invert = function() { this.dx = -this.dx; this.dy = -this.dy; - this.angle = 360 - this.angle; + this.angle = 180 - this.angle; return this; }; diff --git a/src/kiri/render.js b/src/kiri/render.js index a33f0435..8ab4082e 100644 --- a/src/kiri/render.js +++ b/src/kiri/render.js @@ -3,7 +3,7 @@ "use strict"; (function() { - const KIRI = self.kiri, BASE = self.base, POLY = BASE.polygons; + const KIRI = self.kiri, BASE = self.base, POLY = BASE.polygons, newPolygon = BASE.newPolygon; class Render { constructor() { @@ -164,6 +164,14 @@ polys.forEach(poly => { const contour = []; + poly = poly.miter(); + // if (poly.debug) { + // const save = this.current; + // this.setLayer('debug.acute', 0xff0000).addPoly(poly, {thin:true}); + // this.setLayer('debug.start', 0x00ff00).addPoly(newPolygon().centerRectangle(poly.first(),1,1), {thin:true}); + // this.setLayer('debug.end', 0x0000ff).addPoly(newPolygon().centerRectangle(poly.last(),0.8,0.8), {thin:true}); + // this.current = save; + // } poly.points.forEach(p => { contour.push(new THREE.Vector2(p.x, p.y)); }); diff --git a/src/license.js b/src/license.js index f50162eb..395551a7 100644 --- a/src/license.js +++ b/src/license.js @@ -3,7 +3,7 @@ let terms = { COPYRIGHT: "Copyright (C) Stewart Allen - All Rights Reserved", LICENSE: "See the license.md file included with the source distribution", - VERSION: "2.3.D5" + VERSION: "2.3.D6" }; if (typeof(module) === 'object') { diff --git a/src/mode/fdm/prepare.js b/src/mode/fdm/prepare.js index e4693e45..a4068106 100644 --- a/src/mode/fdm/prepare.js +++ b/src/mode/fdm/prepare.js @@ -484,7 +484,7 @@ lastOut = out; }); if (lastOut.emit) { - pushPrint(lastOut.tool, current) + // pushPrint(lastOut.tool, current) } else { moves.push(current); }