Skip to content

Commit 687d272

Browse files
tormachjallwineyomotsu
authored andcommitted
fix: use camera's parent to transform target into world space (#624)
so focus doesn't change when parent changes
1 parent 68a0f9c commit 687d272

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/CameraControls.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,15 @@ export class CameraControls extends EventDispatcher {
28062806
// decompose spherical to the camera position
28072807
this._spherical.makeSafe();
28082808
this._camera.position.setFromSpherical( this._spherical ).applyQuaternion( this._yAxisUpSpaceInverse ).add( this._target );
2809-
this._camera.lookAt( this._target );
2809+
2810+
_v3A.copy( this._target );
2811+
if ( this._camera.parent ) {
2812+
2813+
this._camera.parent.localToWorld( _v3A );
2814+
2815+
}
2816+
2817+
this._camera.lookAt( _v3A );
28102818

28112819
// set offset after the orbit movement
28122820
const affectOffset =

0 commit comments

Comments
 (0)