@@ -621,7 +621,7 @@ class OrbitControls extends EventDispatcher {
621
621
622
622
}
623
623
624
- function updateMouseParameters ( event ) {
624
+ function updateZoomParameters ( x , y ) {
625
625
626
626
if ( ! scope . zoomToCursor ) {
627
627
@@ -632,13 +632,13 @@ class OrbitControls extends EventDispatcher {
632
632
performCursorZoom = true ;
633
633
634
634
const rect = scope . domElement . getBoundingClientRect ( ) ;
635
- const x = event . clientX - rect . left ;
636
- const y = event . clientY - rect . top ;
635
+ const dx = x - rect . left ;
636
+ const dy = y - rect . top ;
637
637
const w = rect . width ;
638
638
const h = rect . height ;
639
639
640
- mouse . x = ( x / w ) * 2 - 1 ;
641
- mouse . y = - ( y / h ) * 2 + 1 ;
640
+ mouse . x = ( dx / w ) * 2 - 1 ;
641
+ mouse . y = - ( dy / h ) * 2 + 1 ;
642
642
643
643
dollyDirection . set ( mouse . x , mouse . y , 1 ) . unproject ( scope . object ) . sub ( scope . object . position ) . normalize ( ) ;
644
644
@@ -662,7 +662,7 @@ class OrbitControls extends EventDispatcher {
662
662
663
663
function handleMouseDownDolly ( event ) {
664
664
665
- updateMouseParameters ( event ) ;
665
+ updateZoomParameters ( event . clientX , event . clientX ) ;
666
666
dollyStart . set ( event . clientX , event . clientY ) ;
667
667
668
668
}
@@ -729,7 +729,7 @@ class OrbitControls extends EventDispatcher {
729
729
730
730
function handleMouseWheel ( event ) {
731
731
732
- updateMouseParameters ( event ) ;
732
+ updateZoomParameters ( event . clientX , event . clientY ) ;
733
733
734
734
if ( event . deltaY < 0 ) {
735
735
@@ -957,6 +957,11 @@ class OrbitControls extends EventDispatcher {
957
957
958
958
dollyStart . copy ( dollyEnd ) ;
959
959
960
+ const centerX = ( event . pageX + position . x ) * 0.5 ;
961
+ const centerY = ( event . pageY + position . y ) * 0.5 ;
962
+
963
+ updateZoomParameters ( centerX , centerY ) ;
964
+
960
965
}
961
966
962
967
function handleTouchMoveDollyPan ( event ) {
0 commit comments