add grid lines toggling

This commit is contained in:
Stewart Allen 2022-01-07 21:32:53 -05:00
commit 798bf1750d
4 changed files with 18 additions and 3 deletions

View file

@ -267,6 +267,14 @@ let api = mesh.api = {
)); ));
}, },
grid(state = {toggle:true}) {
if (state.toggle) {
space.platform.showGrid(!space.platform.isGridVisible());
} else {
space.platform.showGrid(state);
}
},
wireframe(state = {toggle:true}, opt = {opacity:0.15}) { wireframe(state = {toggle:true}, opt = {opacity:0.15}) {
for (let m of api.model.list()) { for (let m of api.model.list()) {
m.wireframe(state, opt); m.wireframe(state, opt);

View file

@ -179,6 +179,7 @@ function ui_build() {
h.button({ _: 'analyze', disabled: true }), h.button({ _: 'analyze', disabled: true }),
h.button({ _: 'repair', onclick: api.tool.repair }), h.button({ _: 'repair', onclick: api.tool.repair }),
h.div({ class: "vsep" }), h.div({ class: "vsep" }),
h.button({ _: 'gridlines', onclick() { api.grid() } }),
h.button({ _: 'wireframe', onclick() { api.wireframe() } }), h.button({ _: 'wireframe', onclick() { api.wireframe() } }),
]), ]),
]); ]);

View file

@ -923,7 +923,8 @@
function setPlatform(opt = {}) { function setPlatform(opt = {}) {
let platform = Space.platform; let platform = Space.platform;
let { color, round, size, grid, opacity, volume, zOffset, origin } = opt; let { color, round, size, grid, opacity } = opt;
let { visible, volume, zOffset, origin } = opt;
if (color) { if (color) {
platform.setColor(color); platform.setColor(color);
} }
@ -953,6 +954,9 @@
if (zOffset !== undefined) { if (zOffset !== undefined) {
platform.setZOff(zOffset); platform.setZOff(zOffset);
} }
if (visible !== undefined) {
platform.setVisible(visible);
}
} }
let Space = MOTO.Space = { let Space = MOTO.Space = {
@ -1017,11 +1021,13 @@
setMaxZ: (z) => { panY = z / 2 }, setMaxZ: (z) => { panY = z / 2 },
setCenter: (x,y,z) => { panX = x; panY = z, panZ = y }, setCenter: (x,y,z) => { panX = x; panY = z, panZ = y },
setHidden: (b) => { showPlatform = !b; platform.visible = !b }, setHidden: (b) => { showPlatform = !b; platform.visible = !b },
setVisible: (b) => { showPlatform = b; platform.visible = b },
setHiding: (b) => { hidePlatformBelow = b }, setHiding: (b) => { hidePlatformBelow = b },
setZOff: (z) => { platformZOff = z; updatePlatformPosition() }, setZOff: (z) => { platformZOff = z; updatePlatformPosition() },
setGridZOff:(z) => { gridZOff = z; updatePlatformPosition() }, setGridZOff:(z) => { gridZOff = z; updatePlatformPosition() },
isHidden: () => { return !showPlatform }, isHidden: () => { return !showPlatform },
isVisible: () => { return platform.visible }, isVisible: () => { return platform.visible },
isGridVisible() { return grid.view.visible },
opacity: (o) => { platform.material.opacity = o }, opacity: (o) => { platform.material.opacity = o },
onMove: (f,t) => { platformOnMove = f, platformOnMoveTime = t || platformOnMoveTime }, onMove: (f,t) => { platformOnMove = f, platformOnMoveTime = t || platformOnMoveTime },
onHover: (f) => { platformHover = f }, onHover: (f) => { platformHover = f },

View file

@ -144,7 +144,7 @@ body, div {
button { button {
padding: 2px 3px 2px 3px; padding: 2px 3px 2px 3px;
border: 1px solid rgba(150,150,150,0.5); border: 1px solid rgba(150,150,150,0.5);
background-color: rgba(220,220,220,0.5); background-color: rgba(220,220,220,0.75);
} }
button:hover { button:hover {
@ -236,6 +236,7 @@ button:hover {
border-radius: 3px; border-radius: 3px;
margin: 0 0 2px 0; margin: 0 0 2px 0;
padding: 3px; padding: 3px;
background-color: rgba(255,255,255,0.5);
} }
#actions .vsep, #grouplist .vsep { #actions .vsep, #grouplist .vsep {
@ -306,7 +307,6 @@ button:hover {
#grouplist, #grouplist div { #grouplist, #grouplist div {
flex-direction: column; flex-direction: column;
background-color: transparent;
gap: 2px; gap: 2px;
} }