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();
|
return selection.analyze();
|
||||||
case 'KeyR':
|
case 'KeyR':
|
||||||
return selection.repair();
|
return selection.repair();
|
||||||
|
case 'KeyN':
|
||||||
|
return selection.clean();
|
||||||
case 'KeyV':
|
case 'KeyV':
|
||||||
return selection.focus();
|
return selection.focus();
|
||||||
case 'KeyW':
|
case 'KeyW':
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,10 @@ let selection = {
|
||||||
tool.repair(selection.models());
|
tool.repair(selection.models());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clean() {
|
||||||
|
tool.clean(selection.models());
|
||||||
|
},
|
||||||
|
|
||||||
merge() {
|
merge() {
|
||||||
tool.merge(selection.models());
|
tool.merge(selection.models());
|
||||||
},
|
},
|
||||||
|
|
@ -318,11 +322,12 @@ let tool = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
repair(models) {
|
heal(models, opt = {}) {
|
||||||
api.log.emit('repairing mesh(es)...').pin();
|
|
||||||
let promises = [];
|
let promises = [];
|
||||||
for (let m of models) {
|
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) {
|
if (data) {
|
||||||
m.reload(
|
m.reload(
|
||||||
data.vertices,
|
data.vertices,
|
||||||
|
|
@ -333,8 +338,24 @@ let tool = {
|
||||||
});
|
});
|
||||||
promises.push(p);
|
promises.push(p);
|
||||||
}
|
}
|
||||||
Promise.all(promises).then(() => {
|
return new Promise((resolve, reject) => {
|
||||||
api.log.emit('repair complete').unpin();
|
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({ _: 'duplicate', onclick: api.selection.duplicate }),
|
||||||
h.button({ _: 'merge', onclick: api.selection.merge }),
|
h.button({ _: 'merge', onclick: api.selection.merge }),
|
||||||
h.div({ class: "vsep" }),
|
h.div({ class: "vsep" }),
|
||||||
h.button({ _: 'analyze', onclick: api.tool.analyze }),
|
h.button({ _: 'analyze', onclick: api.selection.analyze }),
|
||||||
h.button({ _: 'repair', onclick: api.tool.repair }),
|
h.button({ _: 'repair', onclick: api.selection.repair }),
|
||||||
|
h.button({ _: 'clean', onclick: api.selection.clean }),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,9 @@ let model = {
|
||||||
return { stats, mapped };
|
return { stats, mapped };
|
||||||
},
|
},
|
||||||
|
|
||||||
heal(id) {
|
heal(data) {
|
||||||
let tool = analyze(id, { merge: true });
|
let { id, opt } = data;
|
||||||
|
let tool = analyze(id, opt);
|
||||||
log(`${id} | unrolling...`);
|
log(`${id} | unrolling...`);
|
||||||
return {
|
return {
|
||||||
vertices: tool.unrolled().toFloat32(),
|
vertices: tool.unrolled().toFloat32(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue