add selection merge
This commit is contained in:
parent
4e7e29c14d
commit
25e2d60ea0
4 changed files with 26 additions and 0 deletions
|
|
@ -2751,6 +2751,7 @@ gapp.register("kiri.init", [], (root, exports) => {
|
|||
// $('mesh-rename').onclick = () => { api.widgets.rename() };
|
||||
$('mesh-export-stl').onclick = () => { objectsExport('stl') };
|
||||
$('mesh-export-obj').onclick = () => { objectsExport('obj') };
|
||||
$('mesh-merge').onclick = api.selection.merge;
|
||||
$('context-duplicate').onclick = duplicateSelection;
|
||||
$('context-mirror').onclick = mirrorSelection;
|
||||
$('context-layflat').onclick = () => { api.event.emit("tool.mesh.lay-flat") };
|
||||
|
|
|
|||
|
|
@ -743,6 +743,7 @@ function platformLayout() {
|
|||
|
||||
function platformLoadWidget(group, vertices, filename) {
|
||||
const widget = newWidget(undefined, group).loadVertices(vertices.toFloat32(), true);
|
||||
widget.meta.file = filename;
|
||||
if (filename) widget.saveToCatalog(filename);
|
||||
platformAdd(widget);
|
||||
return widget;
|
||||
|
|
@ -904,6 +905,7 @@ const platform = api.platform = {
|
|||
load_stl: platformLoadSTL,
|
||||
load_url: platformLoadURL,
|
||||
load_files: platformLoadFiles,
|
||||
load_verts: platformLoadWidget,
|
||||
deselect: platformDeselect,
|
||||
select: platformSelect,
|
||||
select_all: platformSelectAll,
|
||||
|
|
|
|||
|
|
@ -192,6 +192,27 @@ function rotate(x, y, z) {
|
|||
space.update();
|
||||
}
|
||||
|
||||
function merge() {
|
||||
let sel = widgets();
|
||||
if (sel.length === 0) {
|
||||
sel = api.widgets.all();
|
||||
}
|
||||
let obj = [];
|
||||
sel.forEach(widget => {
|
||||
let {x, y, z} = widget.track.pos || { x:0, y:0, z:0 };
|
||||
let pos = widget.mesh.geometry.attributes.position;
|
||||
let pvals = pos.array;
|
||||
for (let i=0, il=pos.count; i<il; i += 3) {
|
||||
let pi = i * pos.itemSize;
|
||||
obj.push(pvals[pi++] + x, pvals[pi++] + y, pvals[pi++] + z);
|
||||
obj.push(pvals[pi++] + x, pvals[pi++] + y, pvals[pi++] + z);
|
||||
obj.push(pvals[pi++] + x, pvals[pi++] + y, pvals[pi++] + z);
|
||||
}
|
||||
});
|
||||
let w = api.platform.load_verts([], obj, "merged");
|
||||
api.platform.select(w);
|
||||
}
|
||||
|
||||
function exportWidgets(format = "stl") {
|
||||
let sel = widgets();
|
||||
if (sel.length === 0) {
|
||||
|
|
@ -276,6 +297,7 @@ function setDisabled(bool) {
|
|||
// extend API (api.selection)
|
||||
const selection = api.selection = {
|
||||
move,
|
||||
merge,
|
||||
scale,
|
||||
rotate,
|
||||
mirror,
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@
|
|||
<span id="tool-mesh"><i class="fas fa-dice-d20"></i>
|
||||
<div id="ft-mesh" class="grow f-col pop">
|
||||
<div id="ft-mesh-btn">
|
||||
<div><button id="mesh-merge" lk="rc_merge">Merge</button></div>
|
||||
<div><button id="mesh-export-obj" lk="rc_xobj">export OBJ</button></div>
|
||||
<div><button id="mesh-export-stl" lk="rc_xstl">export STL</button></div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue