-
-
Notifications
You must be signed in to change notification settings - Fork 260
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -723,6 +723,8 @@ export class CameraControls extends EventDispatcher { | |
if ( ! this._domElement ) return; | ||
if ( ! this._enabled || this.mouseButtons.wheel === ACTION.NONE ) return; | ||
|
||
this._resetFocalOffsets(); | ||
|
||
if ( | ||
this._interactiveArea.left !== 0 || | ||
this._interactiveArea.top !== 0 || | ||
|
@@ -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 commentThe 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 commentThe 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? |
||
|
||
extractClientCoordFromEvent( this._activePointers, _v2 ); | ||
|
||
this._getClientRect( this._elementRect ); | ||
|
@@ -2034,6 +2038,8 @@ export class CameraControls extends EventDispatcher { | |
enableTransition: boolean = false, | ||
): Promise<void> { | ||
|
||
this._resetFocalOffsets(); | ||
|
||
this._isUserControllingRotate = false; | ||
this._isUserControllingDolly = false; | ||
this._isUserControllingTruck = false; | ||
|
@@ -3214,6 +3220,19 @@ export class CameraControls extends EventDispatcher { | |
|
||
protected _removeAllEventListeners(): void {} | ||
|
||
// Applies and resets focal offsets to play nice with lookAt and zoom-to-cursor | ||
// https://github.com/yomotsu/camera-controls/issues/491 | ||
protected _resetFocalOffsets() { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we check the focalOffset value first? |
||
_v3A.set( 0, 0, -1 ).applyQuaternion( this._camera.quaternion ); | ||
_v3A.multiplyScalar( this._spherical.radius ); | ||
_v3A.add( this._camera.position ); | ||
|
||
this.setFocalOffset( 0, 0, 0, false ); | ||
this.moveTo( _v3A.x, _v3A.y, _v3A.z, false ); | ||
|
||
} | ||
|
||
/** | ||
* backward compatible | ||
* @deprecated use smoothTime (in seconds) instead | ||
|
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()
withif ( this.dollyToCursor )
?Then wheel zoom/dolly will reset focalOffsets.
eg