ctrl+click pans and rotates camera to selected face
This commit is contained in:
parent
8805f3db61
commit
1380d0e6ba
3 changed files with 20 additions and 6 deletions
|
|
@ -399,8 +399,11 @@ function space_init(data) {
|
||||||
if (metaKey) {
|
if (metaKey) {
|
||||||
// set focus on intersected face
|
// set focus on intersected face
|
||||||
let { x, y, z } = int.point;
|
let { x, y, z } = int.point;
|
||||||
|
let q = new THREE.Quaternion().setFromRotationMatrix(group.object.matrix);
|
||||||
|
// rotate normal using group's matrix
|
||||||
|
let normal = int.face.normal.applyQuaternion(q);
|
||||||
// y,z swap due to world rotation for orbit controls
|
// y,z swap due to world rotation for orbit controls
|
||||||
api.focus({center: { x, y:-z, z:y }});
|
api.focus({center: { x, y:-z, z:y }, normal});
|
||||||
} else if (ctrlKey) {
|
} else if (ctrlKey) {
|
||||||
// rotate selected face towawrd z "floor"
|
// rotate selected face towawrd z "floor"
|
||||||
group.faceDown(int.face.normal);
|
group.faceDown(int.face.normal);
|
||||||
|
|
|
||||||
|
|
@ -541,12 +541,21 @@ let api = mesh.api = {
|
||||||
if (isNaN(center.x * center.y * center.z)) {
|
if (isNaN(center.x * center.y * center.z)) {
|
||||||
center = { x: 0, y: 0, z: 0 };
|
center = { x: 0, y: 0, z: 0 };
|
||||||
}
|
}
|
||||||
|
let { normal } = object;
|
||||||
|
let left, up;
|
||||||
|
if (normal) {
|
||||||
|
let { x, y, z } = normal;
|
||||||
|
left = new Vector3(x,y,0).angleTo(new Vector3(0,-1,0));
|
||||||
|
up = new Vector3(0,y,z).angleTo(new Vector3(0,0,1));
|
||||||
|
if (x < 0) left = -left;
|
||||||
|
}
|
||||||
// sets "home" views (front, back, home, reset)
|
// sets "home" views (front, back, home, reset)
|
||||||
space.platform.setCenter(center.x, -center.y, center.z);
|
space.platform.setCenter(center.x, -center.y, center.z);
|
||||||
// sets camera focus
|
// sets camera focus
|
||||||
space.view.setFocus(new Vector3(
|
space.view.panTo(center.x, center.z, -center.y, left, up);
|
||||||
center.x, center.z, -center.y
|
// space.view.setFocus(new Vector3(
|
||||||
));
|
// center.x, center.z, -center.y
|
||||||
|
// ));
|
||||||
},
|
},
|
||||||
|
|
||||||
grid(state = {toggle:true}) {
|
grid(state = {toggle:true}) {
|
||||||
|
|
|
||||||
|
|
@ -164,12 +164,14 @@
|
||||||
|
|
||||||
tweenit();
|
tweenit();
|
||||||
|
|
||||||
function tweenCamPan(x,y,z) {
|
function tweenCamPan(x,y,z,left,up) {
|
||||||
updateLastAction();
|
updateLastAction();
|
||||||
let pos = viewControl.getPosition();
|
let pos = viewControl.getPosition();
|
||||||
pos.panX = x;
|
pos.panX = x;
|
||||||
pos.panY = y;
|
pos.panY = y;
|
||||||
pos.panZ = z;
|
pos.panZ = z;
|
||||||
|
if (left !== undefined) pos.left = left;
|
||||||
|
if (up !== undefined) pos.up = up;
|
||||||
tweenCam(pos);
|
tweenCam(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,7 +1102,7 @@
|
||||||
reset: () => { viewControl.reset(); requestRefresh() },
|
reset: () => { viewControl.reset(); requestRefresh() },
|
||||||
load: (cam) => { viewControl.setPosition(cam); requestRefresh() },
|
load: (cam) => { viewControl.setPosition(cam); requestRefresh() },
|
||||||
save: () => { return viewControl.getPosition(true) },
|
save: () => { return viewControl.getPosition(true) },
|
||||||
panTo: (x,y,z) => { tweenCamPan(x,y,z) },
|
panTo: (x,y,z,l,u) => { tweenCamPan(x,y,z,l,u) },
|
||||||
setZoom: (r,v) => { viewControl.setZoom(r,v) },
|
setZoom: (r,v) => { viewControl.setZoom(r,v) },
|
||||||
setCtrl: (name) => {
|
setCtrl: (name) => {
|
||||||
if (name === 'onshape') {
|
if (name === 'onshape') {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue