add preferences for auto-center and auto-floor
This commit is contained in:
parent
2696406601
commit
c04dac8ba9
4 changed files with 37 additions and 7 deletions
|
|
@ -490,6 +490,8 @@ let prefs = {
|
||||||
scale_group_Z: true
|
scale_group_Z: true
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
|
center: true,
|
||||||
|
floor: true,
|
||||||
wire: false,
|
wire: false,
|
||||||
grid: true,
|
grid: true,
|
||||||
dark: false,
|
dark: false,
|
||||||
|
|
|
||||||
|
|
@ -182,13 +182,24 @@ gapp.broker.subscribe("mesh.log", log.emit);
|
||||||
|
|
||||||
// bind settings endpoint to api
|
// bind settings endpoint to api
|
||||||
api.settings = function() {
|
api.settings = function() {
|
||||||
modal.show('settings', h.div([
|
let { prefs } = api;
|
||||||
|
let { space } = prefs.map;
|
||||||
|
modal.show('settings', h.div({ class: "settings" }, [
|
||||||
h.label('dark mode'),
|
h.label('dark mode'),
|
||||||
h.input({
|
h.input({ type: "checkbox",
|
||||||
type: "checkbox",
|
|
||||||
onchange: ev => call.set_darkmode(ev.target.checked),
|
onchange: ev => call.set_darkmode(ev.target.checked),
|
||||||
[ api.prefs.map.space.dark ? 'checked' : 'unchecked' ] : 1
|
[ space.dark ? 'checked' : 'unchecked' ] : 1
|
||||||
})
|
}),
|
||||||
|
h.label('auto floor'),
|
||||||
|
h.input({ type: "checkbox",
|
||||||
|
onchange: ev => prefs.save( space.floor = !space.floor ),
|
||||||
|
[ space.floor !== false ? 'checked' : 'unchecked' ] : 1
|
||||||
|
}),
|
||||||
|
h.label('auto center'),
|
||||||
|
h.input({ type: "checkbox",
|
||||||
|
onchange: ev => prefs.save( space.center = !space.center ),
|
||||||
|
[ space.center !== false ? 'checked' : 'unchecked' ] : 1
|
||||||
|
}),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,14 +99,17 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
|
|
||||||
promote() {
|
promote() {
|
||||||
this.centerModels();
|
this.centerModels();
|
||||||
let { dim } = this.bounds;
|
let { dim, mid } = this.bounds;
|
||||||
let { x, y, z } = dim;
|
let { x, y, z } = dim;
|
||||||
let max = Math.max(x, y, z);
|
let max = Math.max(x, y, z);
|
||||||
if (max < 2) {
|
if (max < 2) {
|
||||||
mesh.api.log.emit(`auto-scaling import from ${max.round(5)}`);
|
mesh.api.log.emit(`auto-scaling import from ${max.round(5)}`);
|
||||||
this.scale(1000, 1000, 1000);
|
this.scale(1000, 1000, 1000);
|
||||||
}
|
}
|
||||||
return this.centerXY().floor();
|
let { center, floor } = mesh.api.prefs.map.space;
|
||||||
|
if (center !== false) this.centerXY();
|
||||||
|
if (floor !== false) this.floor();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
scale(x = 1, y = 1, z = 1) {
|
scale(x = 1, y = 1, z = 1) {
|
||||||
|
|
@ -123,6 +126,11 @@ mesh.group = class MeshGroup extends mesh.object {
|
||||||
for (let model of this.models) {
|
for (let model of this.models) {
|
||||||
model.center(bounds);
|
model.center(bounds);
|
||||||
}
|
}
|
||||||
|
let { center } = mesh.api.prefs.map.space;
|
||||||
|
if (center === false) {
|
||||||
|
let { mid } = bounds;
|
||||||
|
this.move(mid.x, mid.y, mid.z);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,15 @@ button:hover {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** settings dialog **/
|
||||||
|
|
||||||
|
.settings {
|
||||||
|
display: grid;
|
||||||
|
grid: min-content 1fr / min-content 1fr;
|
||||||
|
white-space: nowrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
/** spinner animation **/
|
/** spinner animation **/
|
||||||
|
|
||||||
@keyframes spinner {
|
@keyframes spinner {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue