improve split healing

This commit is contained in:
Stewart Allen 2024-08-10 23:49:32 -04:00
commit 23d065aca8

View file

@ -254,7 +254,6 @@ let model = {
}
}
}
{
// find unshared edges on Z plane
let faces = o1.group(3);
for (let face of faces) {
@ -287,19 +286,19 @@ let model = {
p2: newPoint().move(e.p2),
}
});
// flatten output points to arrays
o1 = o1.map(e => [ ...e ]).flat();
o2 = o2.map(e => [ ...e ]).flat();
}
if (edges.length) {
// heal open spaces created by split
// heal unshared edges created along Z split
// normals (from point array) are reversed for the bottom split
let heal = sliceConnect(edges, z).map(poly => poly.earcut()).flat();
let o1p = heal.map(poly => poly.points.map(p => [ p.x, p.y, p.z ]));
let o2p = heal.map(poly => poly.points.reverse().map(p => [ p.x, p.y, p.z ]));
o1.appendAll(o1p.flat().flat());
o2.appendAll(o2p.flat().flat());
console.log({ edges, heal, o1, o2 });
// console.log({ edges, heal, o1, o2 });
}
// return null;
return { o1: o1.toFloat32(), o2: o2.toFloat32() };
},