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;
|
let model = int && int.object.model ? int.object.model : undefined;
|
||||||
if (model) {
|
if (model) {
|
||||||
let group = model.group;
|
let group = model.group;
|
||||||
|
let { ctrlKey, metaKey, shiftKey } = event;
|
||||||
// lay flat with meta or ctrl clicking a selected face
|
// lay flat with meta or ctrl clicking a selected face
|
||||||
if ((event.ctrlKey || event.metaKey)) {
|
if ((ctrlKey || metaKey)) {
|
||||||
let q = new THREE.Quaternion();
|
let q = new THREE.Quaternion();
|
||||||
// find intersecting point, look "up" on Z and rotate to face that
|
// find intersecting point, look "up" on Z and rotate to face that
|
||||||
q.setFromUnitVectors(int.face.normal, new THREE.Vector3(0,0,-1));
|
q.setFromUnitVectors(int.face.normal, new THREE.Vector3(0,0,-1));
|
||||||
group.qrotation(q);
|
group.qrotation(q);
|
||||||
group.floor();
|
group.floor();
|
||||||
} else {
|
} else {
|
||||||
selection.toggle(model.group);
|
selection.toggle(shiftKey ? model.group : model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -250,7 +251,7 @@ function space_init(data) {
|
||||||
});
|
});
|
||||||
|
|
||||||
space.mouse.onDrag((delta, offset, up = false) => {
|
space.mouse.onDrag((delta, offset, up = false) => {
|
||||||
if (delta) {
|
if (delta && delta.event.shiftKey) {
|
||||||
selection.move(delta.x, delta.y, 0);
|
selection.move(delta.x, delta.y, 0);
|
||||||
} else {
|
} else {
|
||||||
return api.objects().length > 0;
|
return api.objects().length > 0;
|
||||||
|
|
|
||||||
|
|
@ -62,21 +62,39 @@ let selection = {
|
||||||
|
|
||||||
// @param group {MeshObject}
|
// @param group {MeshObject}
|
||||||
add(object) {
|
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);
|
selected.addOnce(object);
|
||||||
selection.update();
|
selection.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle(object) {
|
|
||||||
selected.remove(object) || selected.addOnce(object);
|
|
||||||
selection.update();
|
|
||||||
},
|
|
||||||
|
|
||||||
// @param group {MeshObject}
|
// @param group {MeshObject}
|
||||||
remove(object) {
|
remove(object) {
|
||||||
selected.remove(object);
|
selected.remove(object);
|
||||||
selection.update();
|
selection.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// @param group {MeshObject}
|
||||||
|
toggle(object) {
|
||||||
|
if (selected.contains(object)) {
|
||||||
|
selection.remove(object);
|
||||||
|
} else {
|
||||||
|
selection.add(object);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
selected = [];
|
selected = [];
|
||||||
selection.update();
|
selection.update();
|
||||||
|
|
|
||||||
|
|
@ -875,7 +875,11 @@
|
||||||
let delta = mouseDragPoint.clone().sub(int[0].point);
|
let delta = mouseDragPoint.clone().sub(int[0].point);
|
||||||
let offset = mouseDragStart.clone().sub(int[0].point);
|
let offset = mouseDragStart.clone().sub(int[0].point);
|
||||||
mouseDragPoint = 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();
|
requestRefresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue