tweaks to xray, debug. add poly dep to mesh for topo mod
This commit is contained in:
parent
bc5e3eda24
commit
f233bc2768
9 changed files with 47 additions and 9 deletions
|
|
@ -29,7 +29,7 @@
|
||||||
"connect": "^3.7.0",
|
"connect": "^3.7.0",
|
||||||
"earcut": "^2.2.3",
|
"earcut": "^2.2.3",
|
||||||
"express-useragent": "^1.0.13",
|
"express-useragent": "^1.0.13",
|
||||||
"@jscad/modeling": "^2.9.2",
|
"@jscad/modeling": "^2.9.5",
|
||||||
"jszip": "^3.7.1",
|
"jszip": "^3.7.1",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"pixi.js": "^4.8.9",
|
"pixi.js": "^4.8.9",
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,12 @@ AP.peek = function() {
|
||||||
return this[this.length - 1];
|
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
|
* allow chaining of push() calls
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1597,18 +1597,17 @@ class Polygon {
|
||||||
* @param {Polygon} poly clipping mask
|
* @param {Polygon} poly clipping mask
|
||||||
* @returns {?Polygon[]}
|
* @returns {?Polygon[]}
|
||||||
*/
|
*/
|
||||||
mask(poly, nullOnEquiv) {
|
mask(poly, nullOnEquiv, minarea) {
|
||||||
let fillang = this.fillang && this.area() > poly.area() ? this.fillang : poly.fillang,
|
let fillang = this.fillang && this.area() > poly.area() ? this.fillang : poly.fillang,
|
||||||
clip = new clib.Clipper(),
|
clip = new clib.Clipper(),
|
||||||
ctre = new clib.PolyTree(),
|
ctre = new clib.PolyTree(),
|
||||||
sp1 = this.toClipper(),
|
sp1 = this.toClipper(),
|
||||||
sp2 = poly.toClipper();
|
sp2 = poly.toClipper();
|
||||||
|
|
||||||
clip.AddPaths(sp1, ptyp.ptSubject, true);
|
clip.AddPaths(sp1, ptyp.ptSubject, true);
|
||||||
clip.AddPaths(sp2, ptyp.ptClip, true);
|
clip.AddPaths(sp2, ptyp.ptClip, true);
|
||||||
|
|
||||||
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
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 => {
|
poly.forEach(p => {
|
||||||
p.fillang = fillang;
|
p.fillang = fillang;
|
||||||
})
|
})
|
||||||
|
|
@ -1779,6 +1778,29 @@ class Polygon {
|
||||||
|
|
||||||
return null;
|
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<length; i++) {
|
||||||
|
let p0 = points[i];
|
||||||
|
let p1 = points[(i + 1) % length];
|
||||||
|
faces.push(p0.x, p0.y, p0.z);
|
||||||
|
faces.push(p1.x, p1.y, p0.z);
|
||||||
|
faces.push(p1.x, p1.y, p1.z + z);
|
||||||
|
faces.push(p0.x, p0.y, p0.z);
|
||||||
|
faces.push(p1.x, p1.y, p1.z + z);
|
||||||
|
faces.push(p0.x, p0.y, p0.z + z);
|
||||||
|
}
|
||||||
|
return faces;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use Slope.angleDiff() then re-test path mitering / rendering
|
// use Slope.angleDiff() then re-test path mitering / rendering
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
// use: ext.clip2
|
// use: ext.clip2
|
||||||
// use: geo.slope
|
// use: geo.slope
|
||||||
// use: geo.polygon
|
// use: geo.polygon
|
||||||
gapp.register("base.polygons", [], (root, exports) => {
|
gapp.register("geo.polygons", [], (root, exports) => {
|
||||||
|
|
||||||
const { base } = root;
|
const { base } = root;
|
||||||
const { util, config, newPoint } = base;
|
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<out.length; i++) {
|
outer: for (i=0; i<out.length; i++) {
|
||||||
if (!out[i]) continue;
|
if (!out[i]) continue;
|
||||||
|
|
@ -396,6 +396,10 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
||||||
if (!out[j]) continue;
|
if (!out[j]) continue;
|
||||||
union = out[i].union(out[j], minarea, all);
|
union = out[i].union(out[j], minarea, all);
|
||||||
if (union && union.length) {
|
if (union && union.length) {
|
||||||
|
if (opt.onmerge) {
|
||||||
|
a = out[i];
|
||||||
|
b = out[j];
|
||||||
|
}
|
||||||
out[i] = null;
|
out[i] = null;
|
||||||
out[j] = null;
|
out[j] = null;
|
||||||
if (all) {
|
if (all) {
|
||||||
|
|
@ -403,6 +407,9 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
||||||
} else {
|
} else {
|
||||||
out.push(union);
|
out.push(union);
|
||||||
}
|
}
|
||||||
|
if (opt.onmerge) {
|
||||||
|
opt.onmerge(a, b, union);
|
||||||
|
}
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
for (let i=0; i<zi.length; i++) {
|
for (let i=0; i<zi.length; i++) {
|
||||||
zi[i] = (zi[i] - zh[i] / 2).round(3);
|
zi[i] = (zi[i] - zh[i] / 2).round(3);
|
||||||
}
|
}
|
||||||
|
console.log({zi});
|
||||||
return zi;
|
return zi;
|
||||||
},
|
},
|
||||||
// slicer function (worker local or minion distributed)
|
// slicer function (worker local or minion distributed)
|
||||||
|
|
@ -818,7 +819,7 @@ function doRender(slice, isSynth, params, devel) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (slice.xray) {
|
if (slice.xray) {
|
||||||
const color = [ 0xff0000, 0x00aa00, 0x0000ff, 0xaaaa00, 0xff00ff ];
|
const color = [ 0xff0000, 0x00aa00, 0x0000ff, 0xaaaa00, 0xff00ff, 0x0 ];
|
||||||
if (slice.lines) {
|
if (slice.lines) {
|
||||||
slice.lines.forEach((line, i) => {
|
slice.lines.forEach((line, i) => {
|
||||||
const group = i % 5;
|
const group = i % 5;
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,9 @@ const devel = {
|
||||||
xray: (layers, raw) => {
|
xray: (layers, raw) => {
|
||||||
let proc = api.conf.get().process;
|
let proc = api.conf.get().process;
|
||||||
let size = proc.sliceHeight || proc.slaSlice || 1;
|
let size = proc.sliceHeight || proc.slaSlice || 1;
|
||||||
|
let base = (proc.firstSliceHeight || size);
|
||||||
layers = Array.isArray(layers) ? layers : [ layers ];
|
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();
|
api.function.slice();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ function parse(text) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
// dep: mesh.model
|
// dep: mesh.model
|
||||||
// dep: mesh.build
|
// dep: mesh.build
|
||||||
// dep: load.file
|
// dep: load.file
|
||||||
|
// use: geo.polygons
|
||||||
gapp.main("main.mesh", [], (root) => {
|
gapp.main("main.mesh", [], (root) => {
|
||||||
|
|
||||||
const { Quaternion, Mesh, MeshPhongMaterial, PlaneGeometry, DoubleSide, Vector3 } = THREE;
|
const { Quaternion, Mesh, MeshPhongMaterial, PlaneGeometry, DoubleSide, Vector3 } = THREE;
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,7 @@ button.selected:hover {
|
||||||
|
|
||||||
#modes {
|
#modes {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
gap: 2px;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue