From f9e8be8ed0545ef1ead2805ab04248ca1398f70b Mon Sep 17 00:00:00 2001 From: kovacsv Date: Fri, 17 Sep 2021 08:07:26 +0200 Subject: [PATCH] Make ctrl+zoom dependent of mouse movement diff, and clean-up code. --- source/viewer/navigation.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/source/viewer/navigation.js b/source/viewer/navigation.js index dc336cb..8c6e250 100644 --- a/source/viewer/navigation.js +++ b/source/viewer/navigation.js @@ -396,19 +396,14 @@ OV.Navigation = class let moveDiff = this.mouse.GetMoveDiff (); let mouseButton = this.mouse.GetButton (); - if (mouseButton === 1 && ev.ctrlKey) { - let params = ev || window.event; - if (params.movementX === 0) { - let delta = -params.movementY / 40; - let ratio = 0.02; - if (delta < 0) { - ratio = ratio * -1.0; - } - this.Zoom(ratio); + if (mouseButton === 1) { + if (ev.ctrlKey) { + let zoomRatio = 0.001; + this.Zoom (-moveDiff.y * zoomRatio); + } else { + let orbitRatio = 0.5; + this.Orbit (moveDiff.x * orbitRatio, moveDiff.y * orbitRatio); } - } else if (mouseButton === 1) { - let orbitRatio = 0.5; - this.Orbit (moveDiff.x * orbitRatio, moveDiff.y * orbitRatio); } else if (mouseButton === 2 || mouseButton === 3) { let eyeCenterDistance = OV.CoordDistance3D (this.camera.eye, this.camera.center); let panRatio = 0.001 * eyeCenterDistance;