complete body separation code

This commit is contained in:
Stewart Allen 2022-04-05 09:40:25 -07:00
commit 406cacc453
5 changed files with 72 additions and 9 deletions

View file

@ -76,16 +76,21 @@ function analyze(id, opt = {}) {
return tool;
}
function mapFaces(id, opt = {}) {
function isolateBodies(id) {
let tool = mapFaces(id);
log(`${id} | isolating bodies`);
return tool.isolateBodies();
}
function mapFaces(id) {
let rec = cache[id];
let { geo, tool } = rec;
if (!tool) {
tool = rec.tool = new mesh.tool();
}
const vertices = geo.attributes.position.array;
if (!tool.normals) {
log(`${id} | generating face map`);
tool.generateFaceMap(vertices);
tool.generateFaceMap(geo.attributes.position.array);
}
return tool;
}
@ -275,11 +280,16 @@ let model = {
},
mapFaces(data) {
let { id, opt } = data;
let tool = mapFaces(id, opt);
let { id } = data;
let tool = mapFaces(id);
return { mapped: true };
},
isolate(data) {
let { id } = data;
return isolateBodies(id);
},
// given model and point, locate matching vertices, lines, and faces
select(data) {
let { id, x, y, z, a, b, c, matrix, surface } = data;