-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reset focal offsets on input start and setLookAt #507
base: dev
Are you sure you want to change the base?
fix: reset focal offsets on input start and setLookAt #507
Conversation
Sorry for the delay... |
No worries. These are sweeping changes, and people can work around it if they really want to today. |
@@ -723,6 +723,8 @@ export class CameraControls extends EventDispatcher { | |||
if ( ! this._domElement ) return; | |||
if ( ! this._enabled || this.mouseButtons.wheel === ACTION.NONE ) return; | |||
|
|||
this._resetFocalOffsets(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving this line to the beginning of _zoomInternal()
and _dollyInternal()
with if ( this.dollyToCursor )
?
Then wheel zoom/dolly will reset focalOffsets.
eg
protected _dollyInternal = ( delta: number, x: number, y : number ): void => {
if ( this.dollyToCursor ) this._resetFocalOffsets();
@@ -843,6 +845,8 @@ export class CameraControls extends EventDispatcher { | |||
|
|||
if ( ! this._enabled ) return; | |||
|
|||
this._resetFocalOffsets(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think mouse drag movement does not affect focalOffset. so, can we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to call this whenever any input starts. Otherwise, we may interrupt transitions or animations. Is there a better place to put this?
// Applies and resets focal offsets to play nice with lookAt and zoom-to-cursor | ||
// https://github.com/yomotsu/camera-controls/issues/491 | ||
_resetFocalOffsets() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we check the focalOffset value first?
If the value is 0, 0, 0, let's just return and do nothing.
Co-authored-by: Akihiro Oyamada <[email protected]>
Thank you very much for fixing this issue. It indeed resolves #424, and I look forward to it being merged soon. |
Fixes #303
Fixes #316
Fixes #424
Fixes #491
Applies and zeroes focal offsets into the control's spherical coordinates so features like zoom-to-cursor (e.g.
setOrbitPoint
and then interacting with anOrthographicCamera
) andsetLookAt
work without interruption. I have not testedsetLookAt
as thoroughly, but expanded the fix to it after reading #303.