ArcballControls: Fix drifting when zooming with the mouse cursor #23838
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The intention of passing in
this._gizmos.position
tothis.scale
is to scale around the gizmo position. This means that inthis.scale
the_scalePointTemp
should be(0, 0, 0)
, and the camera position translation should result in(0, 0, 0)
as well. However, there are situations where this does not happen and that's when thethis._gizmos.position
gets updated. Because inthis.scale
this happens:This means that if
this._gizmos.position
andthis._gizmoMatrixState
are out-of-sync, a translation happens which propagates and causes the camera position to drift and at some point grow massively.By passing in the position coming from
this._gizmoMatrixState
this issue would be resolved.Note that in other calls to
this.scale
wherethis._gizmos.position
is passed we always callupdateTbState
, which syncs thethis._gizmos.position
andthis._gizmoMatrixState
(I tried to do that here as well, but it causes an issue with zooming, probably because it would also updatethis._zoomState
and the function doesn't expect that).