stub in cam pocket op with surface selection

This commit is contained in:
Stewart Allen 2022-04-04 21:37:15 -04:00
commit 50dfba4e84
9 changed files with 182 additions and 40 deletions

View file

@ -270,6 +270,31 @@ const util = exports({
}
return new VertexNormalsHelper(mesh);
},
facesToGroups(faces) {
let groups = [];
if (faces && faces.length) {
faces = faces.sort((a,b) => a - b).slice();
let first = faces.shift();
if (first > 0) {
groups.push({ start: 0, count: first, mat: 0 });
}
let range = { start: first, count: 1, mat: 1 };
groups.push(range);
for (let face of faces) {
if (face === range.start + range.count) {
range.count++;
} else {
groups.push(range = { start: range.start + range.count, count: face - range.start - range.count });
groups.push(range = { start: face, count: 1, mat: 1 });
}
}
groups.push({ start: range.start + range.count, count: Infinity });
} else {
groups.push({ start: 0, count: Infinity });
}
return groups;
}
});