Skip to content

Commit 43f8b76

Browse files
mhallemrdoob
authored andcommitted
BUG: zoom with negative factor never gets damped (mrdoob#9863)
When using a mouse wheel to zoom in and out quickly, sometimes zoomCamera's factor can go negative. When that happens, _zoomStart.y never gets reset to 0, causing zooming to stop. The fix is to always update _zoomStart, but only update _eye when (factor != 1.0 && zoom > 0.0) .
1 parent 3653a82 commit 43f8b76

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/js/controls/TrackballControls.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,16 @@ THREE.TrackballControls = function ( object, domElement ) {
218218
if ( factor !== 1.0 && factor > 0.0 ) {
219219

220220
_eye.multiplyScalar( factor );
221+
222+
}
221223

222-
if ( _this.staticMoving ) {
223-
224-
_zoomStart.copy( _zoomEnd );
224+
if ( _this.staticMoving ) {
225225

226-
} else {
226+
_zoomStart.copy( _zoomEnd );
227227

228-
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
228+
} else {
229229

230-
}
230+
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
231231

232232
}
233233

0 commit comments

Comments
 (0)