add model cleaning
This commit is contained in:
parent
49f1729946
commit
4797a72810
4 changed files with 34 additions and 9 deletions
|
|
@ -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':
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
]),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue