ctrl+click pans and rotates camera to selected face

This commit is contained in:
Stewart Allen 2022-01-21 02:35:58 -05:00
commit 1380d0e6ba
3 changed files with 20 additions and 6 deletions

View file

@ -399,8 +399,11 @@ function space_init(data) {
if (metaKey) {
// set focus on intersected face
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
api.focus({center: { x, y:-z, z:y }});
api.focus({center: { x, y:-z, z:y }, normal});
} else if (ctrlKey) {
// rotate selected face towawrd z "floor"
group.faceDown(int.face.normal);