allow better scripting
This commit is contained in:
parent
9c58f05692
commit
ac7e37b225
4 changed files with 20 additions and 4 deletions
|
|
@ -80,6 +80,7 @@ const selection = {
|
||||||
selected = objects.map(o => o.models ? o.models : o).flat();
|
selected = objects.map(o => o.models ? o.models : o).flat();
|
||||||
tools = toolist || [];
|
tools = toolist || [];
|
||||||
meshUtil.defer(selection.update);
|
meshUtil.defer(selection.update);
|
||||||
|
return api.selection;
|
||||||
},
|
},
|
||||||
|
|
||||||
// @param group {MeshObject}
|
// @param group {MeshObject}
|
||||||
|
|
@ -1028,7 +1029,7 @@ const tool = {
|
||||||
return log('nothing to merge');
|
return log('nothing to merge');
|
||||||
}
|
}
|
||||||
log(`merging ${models.length} models`).pin();
|
log(`merging ${models.length} models`).pin();
|
||||||
worker.model_merge(models.map(m => {
|
return worker.model_merge(models.map(m => {
|
||||||
return { id: m.id, matrix: m.matrix }
|
return { id: m.id, matrix: m.matrix }
|
||||||
}))
|
}))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
@ -1039,6 +1040,7 @@ const tool = {
|
||||||
api.selection.visible(false);
|
api.selection.visible(false);
|
||||||
api.selection.set([group]);
|
api.selection.set([group]);
|
||||||
log('merge complete').unpin();
|
log('merge complete').unpin();
|
||||||
|
return group;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1118,7 +1120,7 @@ const tool = {
|
||||||
return log('nothing to subtract');
|
return log('nothing to subtract');
|
||||||
}
|
}
|
||||||
log(`subtract ${models.length} models`).pin();
|
log(`subtract ${models.length} models`).pin();
|
||||||
worker.model_subtract(models.map(m => {
|
return worker.model_subtract(models.map(m => {
|
||||||
return { id: m.id, tool: m.tool() }
|
return { id: m.id, tool: m.tool() }
|
||||||
}))
|
}))
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
@ -1128,6 +1130,7 @@ const tool = {
|
||||||
})]).promote();
|
})]).promote();
|
||||||
api.selection.delete();
|
api.selection.delete();
|
||||||
api.selection.set([group]);
|
api.selection.set([group]);
|
||||||
|
return group;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
log(`subtract error: ${error}`);
|
log(`subtract error: ${error}`);
|
||||||
|
|
@ -1150,7 +1153,7 @@ const tool = {
|
||||||
for (let m of models) {
|
for (let m of models) {
|
||||||
nm.push(m.duplicate({ select: dup_sel, shift: dup_shift }));
|
nm.push(m.duplicate({ select: dup_sel, shift: dup_shift }));
|
||||||
}
|
}
|
||||||
tool.regroup(nm);
|
return tool.regroup(nm);
|
||||||
},
|
},
|
||||||
|
|
||||||
mirror() {
|
mirror() {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,11 @@ class MeshGroup extends meshObject {
|
||||||
return box3;
|
return box3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rename(name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// @param model {MeshModel}
|
// @param model {MeshModel}
|
||||||
add(model) {
|
add(model) {
|
||||||
model.group = this;
|
model.group = this;
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,7 @@ class MeshModel extends meshObject {
|
||||||
rename(file) {
|
rename(file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.sync();
|
this.sync();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync to worker and indexeddb for page restoration or worker ops
|
// sync to worker and indexeddb for page restoration or worker ops
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@ export const script = {
|
||||||
},
|
},
|
||||||
execute() {
|
execute() {
|
||||||
let cmd = localStorage.script || `console.log('no script')`;
|
let cmd = localStorage.script || `console.log('no script')`;
|
||||||
if (cmd) eval(`{ \n ${cmd} \n }`);
|
if (cmd) {
|
||||||
|
cmd = [
|
||||||
|
'(async () => {',
|
||||||
|
cmd,
|
||||||
|
'})();'
|
||||||
|
].join('\n');
|
||||||
|
eval(`{ \n ${cmd} \n }`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue