From 885bda5c6595b9c789c1d24e9d060bf239f5a84c Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 12 Jan 2022 00:28:33 -0500 Subject: [PATCH] add visibility toggle --- src/main/mesh.js | 2 ++ src/mesh/api.js | 7 +++++++ src/mesh/build.js | 6 +++++- src/mesh/object.js | 12 ++++++++++++ web/mesh/index.css | 8 ++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/mesh.js b/src/main/mesh.js index ac1a224b..a3e5cb36 100644 --- a/src/main/mesh.js +++ b/src/main/mesh.js @@ -172,6 +172,8 @@ function space_init(data) { return api.grid(); case 'KeyL': return api.log.toggle(); + case 'KeyS': + return selection.visible({toggle:true}); case 'KeyB': return selection.boundsBox({toggle:true}); case 'KeyH': diff --git a/src/mesh/api.js b/src/mesh/api.js index 0b9d28c9..20b92bbe 100644 --- a/src/mesh/api.js +++ b/src/mesh/api.js @@ -106,6 +106,13 @@ let selection = { } }, + visible() { + for (let m of selection.models()) { + m.visible(...arguments); + } + util.defer(selection.update); + }, + duplicate() { for (let m of selection.models()) { m.duplicate(); diff --git a/src/mesh/build.js b/src/mesh/build.js index 4b601572..8ffdff9a 100644 --- a/src/mesh/build.js +++ b/src/mesh/build.js @@ -225,6 +225,7 @@ function ui_build() { h.button({ _: 'bounds', onclick() { api.selection.boundsBox({toggle:true}) } }), h.button({ _: 'gridlines', onclick() { api.grid() } }), h.button({ _: 'wireframe', onclick() { api.wireframe() } }), + h.button({ _: 'visible', onclick() { api.selection.visible({ toggle: true }) } }), h.div({ class: "vsep" }), h.button({ _: 'duplicate', onclick: api.selection.duplicate }), h.button({ _: 'merge', onclick: api.selection.merge }), @@ -274,7 +275,10 @@ function ui_build() { h.div({ class: "models"}, // map models to buttons g.models.map(m => h.button({ _: m.file || m.id, - class: selHas(m) ? [ 'selected' ] : [], + class: [ + selHas(m) ? 'selected' : undefined, + m.visible() ? undefined : 'hidden' + ], onclick(e) { let sel = api.selection.list(); e.shiftKey || (sel.length === 1 && m === sel[0]) ? diff --git a/src/mesh/object.js b/src/mesh/object.js index d05c8e8a..42fe17fe 100644 --- a/src/mesh/object.js +++ b/src/mesh/object.js @@ -71,6 +71,18 @@ mesh.object = class MeshObject { return this; } + visible(opt) { + if (opt === undefined) { + return this.object.visible; + } + if (opt.toggle) { + this.visible(!this.visible()); + } else { + this.object.visible = opt; + } + return this; + } + floor(clazz) { if (!clazz || this instanceof clazz) { let b = this.bounds; diff --git a/web/mesh/index.css b/web/mesh/index.css index 841bc57a..ede583e0 100644 --- a/web/mesh/index.css +++ b/web/mesh/index.css @@ -369,6 +369,14 @@ button:hover { background-color: rgba(0,255,0,1) } +#grouplist .hidden { + background-color: rgba(0,0,255,0.2); +} + +#grouplist .hidden:hover { + background-color: rgba(0,0,255,0.1); +} + /** selection info bottom/right of workspace **/ #selectlist {