add direct position control

This commit is contained in:
Stewart Allen 2022-01-20 18:40:02 -05:00
commit fb41d6be3e
2 changed files with 26 additions and 6 deletions

View file

@ -276,8 +276,8 @@ function space_init(data) {
case 'KeyF':
return selection.floor().focus();
case 'KeyM':
if (shiftKey) return api.tool.mirror();
return api.tool.merge();
if (shiftKey) return api.tool.merge();
return api.tool.mirror();
case 'KeyA':
return api.tool.analyze();
case 'KeyR':
@ -296,8 +296,8 @@ function space_init(data) {
case 'KeyL':
return api.log.toggle();
case 'KeyS':
if (shiftKey) return call.edit_split();
return selection.visible({toggle:true});
if (shiftKey) return selection.visible({toggle:true});
return call.edit_split();
case 'KeyB':
return selection.boundsBox({toggle:true});
case 'KeyH':

View file

@ -351,7 +351,7 @@ function ui_build() {
// return function bound to field editing clicks
// builds a modal dialog that updates the object and field
function field_edit(title, set) {
function field_edit(title, set, opt = {}) {
return function(ev) {
let value = ev.target.innerText;
let onclick = (ev) => {
@ -362,7 +362,9 @@ function ui_build() {
}
for (let g of api.selection.groups()) {
set(g, tempval, value);
g.floor(mesh.group);
if (opt.floor !== false) {
g.floor(mesh.group);
}
defer_selection(); // update ui
}
};
@ -475,6 +477,24 @@ function ui_build() {
group.rotation(r.x, r.y, val/rad);
});
// bind position editable fields
let { group_val_X_pos, group_val_Y_pos, group_val_Z_pos } = bound;
[ group_val_X_pos, group_val_Y_pos, group_val_Z_pos ].forEach(e => {
e.classList.add('editable');
});
group_val_X_pos.onclick = field_edit('x position', (group, val) => {
let r = group.position();
group.position(val, r.y, r.z);
}, { floor: false });
group_val_Y_pos.onclick = field_edit('y position', (group, val) => {
let r = group.position();
group.position(r.x, val, r.z);
}, { floor: false });
group_val_Z_pos.onclick = field_edit('z position', (group, val) => {
let r = group.position();
group.position(r.x, r.y, val);
}, { floor: false });
// bind scale editable fields
let pedit = prefs.map.edit;
let { span_val_X_size, span_val_Y_size, span_val_Z_size } = bound;