trim support to part shadow in non-belt modes. fix part support offset

This commit is contained in:
Stewart Allen 2021-01-27 23:47:06 -05:00
commit cbf5d492b8
2 changed files with 23 additions and 6 deletions

View file

@ -860,12 +860,14 @@
} }
function loadDeviceImage(dev, url) { function loadDeviceImage(dev, url) {
new THREE.TextureLoader().load(url || dev.imageURL, texture => { let turl = url || dev.imageURL;
if (!turl) return;
new THREE.TextureLoader().load(turl, texture => {
loadDeviceTexture(dev, texture); loadDeviceTexture(dev, texture);
}, inc => { }, inc => {
console.log({load_inc: inc}); console.log({load_inc: inc});
}, error => { }, error => {
console.log({load_error: error}); console.log({load_error: error, turl});
clearDeviceTexture(); clearDeviceTexture();
}); });
} }

View file

@ -193,6 +193,7 @@
// clip tops to other widgets in group // clip tops to other widgets in group
tops = slice.topPolys(); tops = slice.topPolys();
for (let peer of widget.group) { for (let peer of widget.group) {
// skip self
if (peer === widget) { if (peer === widget) {
continue; continue;
} }
@ -202,13 +203,27 @@
} }
// offset pslice tops by spro.sliceSupportOffset // offset pslice tops by spro.sliceSupportOffset
if (!pslice.synth_off) { if (!pslice.synth_off) {
pslice.synth_off = POLY.offset(pslice.topPolys(), nozzleSize/2 + spro.sliceSupportOffset); pslice.synth_off = POLY.offset(pslice.topPolys(), spro.sliceSupportOffset);
} }
let ptops = pslice.synth_off; let ptops = pslice.synth_off;
let ntops = []; let ntops = [];
POLY.subtract(tops, ptops, ntops, null, slice.z, 0); POLY.subtract(tops, ptops, ntops, null, slice.z, 0);
tops = ntops; tops = ntops;
} }
// trim to group's shadow if not in belt mode
if (!isBelt) {
let group = widget.group[0];
if (!group.shadow) {
let gs = [];
for (let w of group) {
if (w.shadow) {
gs = POLY.union([w.shadow,...gs],null,0.1);
}
}
group.shadow = gs;
}
tops = POLY.setZ(POLY.trimTo(tops, group.shadow), slice.z);
}
} }
slice.tops = []; slice.tops = [];
for (let t of tops) { for (let t of tops) {
@ -249,6 +264,7 @@
if (spro.sliceSupportExtra) { if (spro.sliceSupportExtra) {
shadow = POLY.offset(shadow, spro.sliceSupportExtra); shadow = POLY.offset(shadow, spro.sliceSupportExtra);
} }
widget.shadow = shadow;
// slices[0].output() // slices[0].output()
// .setLayer('shadow', { line: 0xff0000, check: 0xff0000 }) // .setLayer('shadow', { line: 0xff0000, check: 0xff0000 })
// .addPolys(shadow); // .addPolys(shadow);
@ -917,8 +933,7 @@
* calculate external overhangs requiring support * calculate external overhangs requiring support
*/ */
function doSupport(slice, proc, shadow) { function doSupport(slice, proc, shadow) {
let minOffset = proc.sliceSupportOffset, let maxBridge = proc.sliceSupportSpan || 5,
maxBridge = proc.sliceSupportSpan || 5,
minArea = proc.supportMinArea, minArea = proc.supportMinArea,
pillarSize = proc.sliceSupportSize, pillarSize = proc.sliceSupportSize,
offset = proc.sliceSupportOffset, offset = proc.sliceSupportOffset,
@ -948,7 +963,7 @@
let supported = point.isInPolygonOnly(down_tops); let supported = point.isInPolygonOnly(down_tops);
if (!supported) down_traces.forEach(function(trace) { if (!supported) down_traces.forEach(function(trace) {
trace.forEachSegment(function(p1, p2) { trace.forEachSegment(function(p1, p2) {
if (point.distToLine(p1, p2) <= minOffset) { if (point.distToLine(p1, p2) <= offset) {
return supported = true; return supported = true;
} }
}); });