improve model/group selection with shiftKey. prevent drag/move unless shiftKey
This commit is contained in:
parent
fd645737e2
commit
356a2634e8
3 changed files with 32 additions and 9 deletions
|
|
@ -233,15 +233,16 @@ function space_init(data) {
|
|||
let model = int && int.object.model ? int.object.model : undefined;
|
||||
if (model) {
|
||||
let group = model.group;
|
||||
let { ctrlKey, metaKey, shiftKey } = event;
|
||||
// lay flat with meta or ctrl clicking a selected face
|
||||
if ((event.ctrlKey || event.metaKey)) {
|
||||
if ((ctrlKey || metaKey)) {
|
||||
let q = new THREE.Quaternion();
|
||||
// find intersecting point, look "up" on Z and rotate to face that
|
||||
q.setFromUnitVectors(int.face.normal, new THREE.Vector3(0,0,-1));
|
||||
group.qrotation(q);
|
||||
group.floor();
|
||||
} else {
|
||||
selection.toggle(model.group);
|
||||
selection.toggle(shiftKey ? model.group : model);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -250,7 +251,7 @@ function space_init(data) {
|
|||
});
|
||||
|
||||
space.mouse.onDrag((delta, offset, up = false) => {
|
||||
if (delta) {
|
||||
if (delta && delta.event.shiftKey) {
|
||||
selection.move(delta.x, delta.y, 0);
|
||||
} else {
|
||||
return api.objects().length > 0;
|
||||
|
|
|
|||
|
|
@ -62,21 +62,39 @@ let selection = {
|
|||
|
||||
// @param group {MeshObject}
|
||||
add(object) {
|
||||
// pendantic code necessary to minimize re-entrant api calls
|
||||
if (object.models) {
|
||||
// if group, remove discrete selected members
|
||||
for (let m of object.models) {
|
||||
if (selected.contains(m)) {
|
||||
selection.remove(m);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if model, remove selcted group
|
||||
if (selected.contains(object.group)) {
|
||||
selection.remove(object.group);
|
||||
}
|
||||
}
|
||||
selected.addOnce(object);
|
||||
selection.update();
|
||||
},
|
||||
|
||||
toggle(object) {
|
||||
selected.remove(object) || selected.addOnce(object);
|
||||
selection.update();
|
||||
},
|
||||
|
||||
// @param group {MeshObject}
|
||||
remove(object) {
|
||||
selected.remove(object);
|
||||
selection.update();
|
||||
},
|
||||
|
||||
// @param group {MeshObject}
|
||||
toggle(object) {
|
||||
if (selected.contains(object)) {
|
||||
selection.remove(object);
|
||||
} else {
|
||||
selection.add(object);
|
||||
}
|
||||
},
|
||||
|
||||
clear() {
|
||||
selected = [];
|
||||
selection.update();
|
||||
|
|
|
|||
|
|
@ -875,7 +875,11 @@
|
|||
let delta = mouseDragPoint.clone().sub(int[0].point);
|
||||
let offset = mouseDragStart.clone().sub(int[0].point);
|
||||
mouseDragPoint = int[0].point;
|
||||
mouseDrag({x: -delta.x, y: delta.z}, offset.multiplyVectors(offset, trackDelta));
|
||||
mouseDrag({
|
||||
x: -delta.x,
|
||||
y: delta.z,
|
||||
event
|
||||
}, offset.multiplyVectors(offset, trackDelta));
|
||||
requestRefresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue