fix progressive shadows in rough/outline by using terrain top/bottom derived from new fit option
This commit is contained in:
parent
b19f985728
commit
41d95c5585
3 changed files with 29 additions and 15 deletions
|
|
@ -1313,7 +1313,6 @@
|
||||||
if (src[0].isEquivalent(dst[0]) && src[1].isEquivalent(dst[1])) {
|
if (src[0].isEquivalent(dst[0]) && src[1].isEquivalent(dst[1])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return union;
|
|
||||||
}
|
}
|
||||||
return union;
|
return union;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,25 +253,35 @@
|
||||||
interval(step, options) {
|
interval(step, options) {
|
||||||
let opt = options || {},
|
let opt = options || {},
|
||||||
bounds = this.bounds,
|
bounds = this.bounds,
|
||||||
boff = opt.boff || 0, // bottom offset
|
boff = opt.boff || opt.off || 0, // bottom offset
|
||||||
toff = opt.toff || 0, // top offset
|
toff = opt.toff || opt.off || 0, // top offset
|
||||||
zmin = (opt.min || this.bounds.min.z) + boff,
|
zmin = (opt.min || this.bounds.min.z) + boff,
|
||||||
zmax = (opt.max || this.bounds.max.z) - toff,
|
zmax = (opt.max || this.bounds.max.z) - toff,
|
||||||
count = Math.floor((zmax - zmin) / step),
|
steps = (zmax - zmin) / step,
|
||||||
array = new Array(count);
|
count = Math.floor(steps),
|
||||||
|
array = [];
|
||||||
|
|
||||||
|
if (opt.fit) {
|
||||||
|
count++;
|
||||||
|
step = (zmax - zmin) / count;
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.down) {
|
if (opt.down) {
|
||||||
for (let i=0, il=array.length; i<il; i++) {
|
for (let i=0; i<count; i++) {
|
||||||
array[i] = zmax;
|
array.push(zmax);
|
||||||
zmax -= step;
|
zmax -= step;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i=0, il=array.length; i<il; i++) {
|
for (let i=0; i<count; i++) {
|
||||||
array[i] = zmin;
|
array.push(zmin);
|
||||||
zmin += step;
|
zmin += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt.fit) {
|
||||||
|
array.push(opt.down ? zmax : zmin);
|
||||||
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -538,8 +538,8 @@
|
||||||
* @param {number} overlap on each pass
|
* @param {number} overlap on each pass
|
||||||
*/
|
*/
|
||||||
function createRoughPaths(slice, shell, diameter, stock, overlap) {
|
function createRoughPaths(slice, shell, diameter, stock, overlap) {
|
||||||
let tops = slice.shadow;
|
let shadow = slice.shadow;
|
||||||
let offset = [shell.clone(true),tops.clone(true)].flat();
|
let offset = [shell.clone(true),shadow.clone(true)].flat();
|
||||||
let flat = POLY.flatten(offset, [], true);
|
let flat = POLY.flatten(offset, [], true);
|
||||||
|
|
||||||
offset = POLY.setZ(POLY.nest(flat), slice.z);
|
offset = POLY.setZ(POLY.nest(flat), slice.z);
|
||||||
|
|
@ -830,13 +830,15 @@
|
||||||
});
|
});
|
||||||
let tslices = [];
|
let tslices = [];
|
||||||
let tshadow = [];
|
let tshadow = [];
|
||||||
let tzindex = slicer.interval(1); // bottom up 1mm steps
|
let tzindex = slicer.interval(1, { fit: true, off: 0.01 }); // bottom up 1mm steps
|
||||||
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
|
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
|
||||||
console.log('terrain', index, total, data);
|
console.log('terrain', index, total, data);
|
||||||
tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true);
|
tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true);
|
||||||
tslices.push(data.slice);
|
tslices.push(data.slice);
|
||||||
onupdate(0.0 + (index/total) * 0.1, "mapping");
|
onupdate(0.0 + (index/total) * 0.1, "mapping");
|
||||||
}, genso: true });
|
}, genso: true });
|
||||||
|
let shadowTop = terrain[terrain.length - 1];
|
||||||
|
let shadowBase = terrain[0];
|
||||||
console.log({slicer, tzindex, tshadow, terrain});
|
console.log({slicer, tzindex, tshadow, terrain});
|
||||||
|
|
||||||
if (procDrillReg) {
|
if (procDrillReg) {
|
||||||
|
|
@ -849,20 +851,22 @@
|
||||||
|
|
||||||
// identify through holes
|
// identify through holes
|
||||||
thruHoles = tshadow.map(p => p.inner || []).flat();
|
thruHoles = tshadow.map(p => p.inner || []).flat();
|
||||||
|
console.log({thruHoles})
|
||||||
|
|
||||||
// create roughing slices
|
// create roughing slices
|
||||||
if (procRough) {
|
if (procRough) {
|
||||||
|
let shadow = shadowTop.tops;
|
||||||
let shadow = [];
|
|
||||||
let slices = [];
|
let slices = [];
|
||||||
slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
||||||
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
|
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
|
||||||
data.shadow = shadow.clone(true);
|
data.shadow = shadow.clone(true);
|
||||||
data.slice.camMode = CPRO.ROUGH;
|
data.slice.camMode = CPRO.ROUGH;
|
||||||
data.slice.shadow = data.shadow;
|
data.slice.shadow = data.shadow;
|
||||||
|
// data.slice.tops[0].inner = shadow.clone(true);
|
||||||
slices.push(data.slice);
|
slices.push(data.slice);
|
||||||
onupdate(0.1 + (index/total) * 0.1, "roughing");
|
onupdate(0.1 + (index/total) * 0.1, "roughing");
|
||||||
}, genso: true });
|
}, genso: true });
|
||||||
|
shadow = POLY.union(shadow.appendAll(shadowBase.tops), 0.01, true);
|
||||||
|
|
||||||
// inset or eliminate thru holes from shadow
|
// inset or eliminate thru holes from shadow
|
||||||
shadow = POLY.flatten(shadow.clone(true), [], true);
|
shadow = POLY.flatten(shadow.clone(true), [], true);
|
||||||
|
|
@ -890,7 +894,7 @@
|
||||||
|
|
||||||
// create outline slices
|
// create outline slices
|
||||||
if (procOutline) {
|
if (procOutline) {
|
||||||
let shadow = [];
|
let shadow = shadowTop.tops;
|
||||||
let slices = [];
|
let slices = [];
|
||||||
slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
||||||
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
|
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
|
||||||
|
|
@ -901,6 +905,7 @@
|
||||||
slices.push(data.slice);
|
slices.push(data.slice);
|
||||||
onupdate(0.2 + (index/total) * 0.1, "outlines");
|
onupdate(0.2 + (index/total) * 0.1, "outlines");
|
||||||
}, genso: true });
|
}, genso: true });
|
||||||
|
shadow = POLY.union(shadow.appendAll(shadowBase.tops), 0.01, true);
|
||||||
|
|
||||||
shellOutline = tshadow;
|
shellOutline = tshadow;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue