diff --git a/src/main/mesh.js b/src/main/mesh.js index fbfac8e5..ac1a224b 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -162,6 +162,8 @@ function space_init(data) { return selection.analyze(); case 'KeyR': return selection.repair(); + case 'KeyN': + return selection.clean(); case 'KeyV': return selection.focus(); case 'KeyW': diff --git a/src/mesh/api.js b/src/mesh/api.js index 2870a954..0b9d28c9 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -120,6 +120,10 @@ let selection = { tool.repair(selection.models()); }, + clean() { + tool.clean(selection.models()); + }, + merge() { tool.merge(selection.models()); }, @@ -318,11 +322,12 @@ let tool = { }); }, - repair(models) { - api.log.emit('repairing mesh(es)...').pin(); + heal(models, opt = {}) { let promises = []; for (let m of models) { - let p = worker.model_heal(m.id).then(data => { + let p = worker.model_heal({ + id: m.id, opt + }).then(data => { if (data) { m.reload( data.vertices, @@ -333,8 +338,24 @@ let tool = { }); promises.push(p); } - Promise.all(promises).then(() => { - api.log.emit('repair complete').unpin(); + return new Promise((resolve, reject) => { + Promise.all(promises).then(() => { + resolve(); + }); + }); + }, + + repair(models) { + api.log.emit('repairing mesh(es)...').pin(); + tool.heal(models, { merge: true }).then(() => { + api.log.emit('repair commplete').pin(); + }); + }, + + clean(models) { + api.log.emit('cleaning mesh(es)...').pin(); + tool.heal(models, { merge: false }).then(() => { + api.log.emit('cleaning complete').pin(); }); } }; diff --git a/src/mesh/build.js b/src/mesh/build.js index f1149881..4b601572 100644 --- a/src/mesh/build.js +++ b/src/mesh/build.js @@ -229,8 +229,9 @@ function ui_build() { h.button({ _: 'duplicate', onclick: api.selection.duplicate }), h.button({ _: 'merge', onclick: api.selection.merge }), h.div({ class: "vsep" }), - h.button({ _: 'analyze', onclick: api.tool.analyze }), - h.button({ _: 'repair', onclick: api.tool.repair }), + h.button({ _: 'analyze', onclick: api.selection.analyze }), + h.button({ _: 'repair', onclick: api.selection.repair }), + h.button({ _: 'clean', onclick: api.selection.clean }), ]), ]); diff --git a/src/mesh/work.js b/src/mesh/work.js index bfa02c6d..34fa5ce3 100644 --- a/src/mesh/work.js +++ b/src/mesh/work.js @@ -88,8 +88,9 @@ let model = { return { stats, mapped }; }, - heal(id) { - let tool = analyze(id, { merge: true }); + heal(data) { + let { id, opt } = data; + let tool = analyze(id, opt); log(`${id} | unrolling...`); return { vertices: tool.unrolled().toFloat32(),