Animate selection focusing

This commit is contained in:
JannisX11 2021-04-10 13:16:05 +02:00
parent cc1b5d5567
commit f61fdc471f

View File

@ -2264,14 +2264,25 @@ BARS.defineActions(function() {
condition: () => !Modes.display, condition: () => !Modes.display,
click: function () { click: function () {
let preview = quad_previews.current; let preview = quad_previews.current;
let center = getSelectionCenter(); let center = new THREE.Vector3().fromArray(getSelectionCenter());
if (!Format.centered_grid) center.V3_subtract(8, 8, 8); center.add(scene.position);
let difference = new THREE.Vector3().copy(preview.controls.target);
preview.controls.target.fromArray(center); let difference = new THREE.Vector3().copy(preview.controls.target).sub(center);
difference.divideScalar(6)
let i = 0;
let interval = setInterval(() => {
preview.controls.target.sub(difference);
if (preview.angle != null) { if (preview.angle != null) {
difference.sub(preview.controls.target);
preview.camera.position.sub(difference); preview.camera.position.sub(difference);
} }
i++;
if (i == 6) clearInterval(interval);
}, 16.66)
} }
}) })