diff --git a/src/main/mesh.js b/src/main/mesh.js index 892ae9ec..ca7caa2c 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -284,6 +284,8 @@ function space_init(data) { case 'KeyM': if (shiftKey) return api.tool.merge(); return api.tool.mirror(); + case 'KeyU': + return shiftKey && api.tool.union(); case 'KeyA': return shiftKey ? api.tool.analyze() : undefined; case 'KeyR': diff --git a/src/mesh/api.js b/src/mesh/api.js index 4c453e45..7db3ca19 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -312,6 +312,22 @@ let tool = { }); }, + union(models) { + models = fallback(models); + api.log.emit(`union ${models.length} model(s)`).pin(); + worker.model_union(models.map(m => { + return { id: m.id, matrix: m.matrix } + })) + .then(data => { + let group = api.group.new([new mesh.model({ + file: `unioned`, + mesh: data + })]).promote(); + api.selection.set([group]); + api.log.emit('union complete').unpin(); + }); + }, + duplicate() { for (let m of selection.models()) { m.duplicate(); diff --git a/src/mesh/build.js b/src/mesh/build.js index bc5dae63..f7a8ca82 100644 --- a/src/mesh/build.js +++ b/src/mesh/build.js @@ -281,8 +281,8 @@ function ui_build() { h.button({ _: 'visible', onclick() { selection.visible({ toggle: true }) } }), h.button({ _: 'bounds', onclick() { selection.boundsBox({ toggle: true }) } }), h.button({ _: 'gridlines', onclick() { api.grid() } }), - h.button({ _: 'wireframe', onclick() { api.wireframe() } }), h.button({ _: 'normals', onclick() { api.normals() } }), + h.button({ _: 'wireframe', onclick() { api.wireframe() } }), ]), h.div([ h.div({ _: "edit", class: "head" }), @@ -291,8 +291,8 @@ function ui_build() { h.button({ _: 'regroup', onclick: tool.regroup }), h.button({ _: 'merge', onclick: tool.merge }), h.button({ _: 'mirror', onclick: tool.mirror }), + h.button({ _: 'union', onclick: tool.union }), h.button({ _: 'split', onclick: call.edit_split }), - h.button({ _: 'invert', onclick: tool.invert }), ]), h.div([ h.div({ _: "fix", class: "head" }), @@ -300,6 +300,7 @@ function ui_build() { h.button({ _: 'automatic', onclick: tool.repair }), h.button({ _: 'analyze', onclick: tool.analyze }), // h.button({ _: 'rebuild', onclick: tool.rebuild }), + h.button({ _: 'invert', onclick: tool.invert }), h.button({ _: 'clean', onclick: tool.clean }), ]), ]);