-
-
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
setOrbitPoint breaks setLookAt #303
Comments
Thanks for your detailed report, it's really helpful, and reproduced the problem. |
Seems, below is what camera-controls/src/CameraControls.ts Lines 1793 to 1794 in 6556f6e
but i think In fact the steps below work. (Can you try please just in case?)
The above should be work around so far, and I will add |
Here is what I tried but unfortunately, FocalOffset cannot be calculated during /**
* Make an orbit with given points.
* @param positionX
* @param positionY
* @param positionZ
* @param targetX
* @param targetY
* @param targetZ
* @param enableTransition
* @category Methods
*/
setLookAt(
positionX: number, positionY: number, positionZ: number,
targetX: number, targetY: number, targetZ: number,
enableTransition: boolean = false,
): Promise<void> {
this._camera.updateMatrix();
_xColumn.setFromMatrixColumn( this._camera.matrix, 0 );
_yColumn.setFromMatrixColumn( this._camera.matrix, 1 );
_zColumn.setFromMatrixColumn( this._camera.matrix, 2 );
_xColumn.multiplyScalar( this._focalOffset.x );
_yColumn.multiplyScalar( - this._focalOffset.y );
_zColumn.multiplyScalar( this._focalOffset.z );
const offset = _v3C.copy( _xColumn ).add( _yColumn ).add( _zColumn );
const target = _v3A.set( targetX, targetY, targetZ );
const position = _v3B.set( positionX, positionY, positionZ );
this._targetEnd.copy( target ).sub( offset );
// this._targetEnd.copy( target );
this._sphericalEnd.setFromVector3( position.sub( target ).applyQuaternion( this._yAxisUpSpace ) );
this.normalizeRotations();
this._needsUpdate = true;
if ( ! enableTransition ) {
this._target.copy( this._targetEnd );
this._spherical.copy( this._sphericalEnd );
}
const resolveImmediately = ! enableTransition ||
approxEquals( this._target.x, this._targetEnd.x, this.restThreshold ) &&
approxEquals( this._target.y, this._targetEnd.y, this.restThreshold ) &&
approxEquals( this._target.z, this._targetEnd.z, this.restThreshold ) &&
approxEquals( this._spherical.theta, this._sphericalEnd.theta, this.restThreshold ) &&
approxEquals( this._spherical.phi, this._sphericalEnd.phi, this.restThreshold ) &&
approxEquals( this._spherical.radius, this._sphericalEnd.radius, this.restThreshold );
return this._createOnRestPromise( resolveImmediately );
} Like, you need to run the bellow twice at least. 1.mp4Thus, the FocalOffset ( or the OrbitPoint) can't be reserved after |
I've been running into this issue as well, trying to keep the same orbit point while using setTarget to look at different objects, then re-setting the orbit point. Was wondering why the camera would slowly go crazy, but I watched the focalOffset thanks to this issue, and found it would slowly keep adjusting itself! |
Describe the bug
Setting setOrbitPoint seems to change the behavior of setLookAt. I would expect setLookAt to be idempotent, which is to say, when given identical parameters, it should move the camera to the same position and point it at the same target. Calling setOrbitPoint in between calls to setLookAt seems to break this assumption, as subsequent calls to setLookAt with the same parameters move the camera to a new position/target.
What is the best way to think about the relationship between setOrbitPoint and setLookAt? Should the code integrating camera-controls keep track of the last set orbit point, and use this when calculating the values to pass into setLookAt? E.g. use the last value passed to setOrbitPoint as an offset to setLookAt?
Thank you for your time and attention to this.
To Reproduce
Steps to reproduce the behavior:
cameraControls.setLookAt(3,5,2,3,0,-3)
cameraControls.setLookAt(3,5,2,3,0,-3)
again, and observe that the camera positions doesn't change.cameraControls.setOrbitPoint( 0, 0, 0 );
cameraControls.setLookAt(3,5,2,3,0,-3)
again, and observe that the camera positions now changes.Code
No response
Live example
No response
Expected behavior
Thank you for your time and attention to this.
Screenshots or Video
Device
Desktop
OS
Linux
Browser
Firefox
The text was updated successfully, but these errors were encountered: