add model renaming
This commit is contained in:
parent
a81a1f0b60
commit
3df81d48c7
4 changed files with 33 additions and 1 deletions
|
|
@ -330,6 +330,31 @@ let tool = {
|
|||
}
|
||||
},
|
||||
|
||||
rename(models) {
|
||||
models = fallback(models, true);
|
||||
let model = models[0];
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
if (models.length > 1) {
|
||||
return api.log.emit('rename requires a single selection');
|
||||
}
|
||||
let onclick = onkeydown = (ev) => {
|
||||
if (ev.code && ev.code !== 'Enter') {
|
||||
return;
|
||||
}
|
||||
model.rename( $('tempedit').value.trim() );
|
||||
selection.update();
|
||||
api.modal.hide();
|
||||
};
|
||||
let { tempedit } = api.modal.show(`rename model`, h.div({ class: "rename"}, [
|
||||
h.input({ id: "tempedit", value: model.file, onkeydown }),
|
||||
h.button({ _: 'ok', onclick })
|
||||
]));
|
||||
tempedit.setSelectionRange(0,1000);
|
||||
tempedit.focus();
|
||||
},
|
||||
|
||||
analyze(models, opt = { compound: true }) {
|
||||
models = fallback(models);
|
||||
api.log.emit('analyzing mesh(es)...').pin();
|
||||
|
|
|
|||
|
|
@ -195,6 +195,12 @@ mesh.model = class MeshModel extends mesh.object {
|
|||
this.normals({refresh: true});
|
||||
}
|
||||
|
||||
rename(file) {
|
||||
this.file = file;
|
||||
// persist in db so it can be restored on page load
|
||||
mapp.db.space.put(this.id, { file, mesh: this.attributes.position.array });
|
||||
}
|
||||
|
||||
get group() {
|
||||
return this._group;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue