allow meta + click to focus camera for better navigation

This commit is contained in:
Stewart Allen 2022-01-03 00:43:35 -05:00
commit 466c389b89
2 changed files with 8 additions and 4 deletions

View file

@ -236,8 +236,12 @@ function space_init(data) {
if (model) {
let group = model.group;
let { ctrlKey, metaKey, shiftKey } = event;
// lay flat with meta or ctrl clicking a selected face
if ((ctrlKey || metaKey)) {
if (metaKey) {
// set focus on intersected face
let { x, y, z } = int.point;
api.focus({center: { x, y:-z, z:y }});
} else if (ctrlKey) {
// lay flat when ctrl clicking a selected face
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));

View file

@ -225,9 +225,9 @@ let api = mesh.api = {
}
},
// @param object {THREE.Object3D | THREE.Object3D[]}
// @param object {THREE.Object3D | THREE.Object3D[] | Point}
focus(object) {
let { center } = util.bounds(object);
let { center } = object.center ? object : util.bounds(object);
// when no valid objects supplied, set origin
if (isNaN(center.x * center.y * center.z)) {
center = { x: 0, y: 0, z: 0 };