Skip to content

Commit

Permalink
fix: position in fromJSON does not work correctly (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
yomotsu authored Mar 16, 2023
1 parent cd3f452 commit 4fb31a0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/CameraControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,6 @@ export class CameraControls extends EventDispatcher {
fromJSON( json: string, enableTransition: boolean = false ): void {

const obj = JSON.parse( json );
const position = _v3A.fromArray( obj.position );

this.enabled = obj.enabled;

Expand All @@ -2625,7 +2624,7 @@ export class CameraControls extends EventDispatcher {
this._focalOffset0.fromArray( obj.focalOffset0 );

this.moveTo( obj.target[ 0 ], obj.target[ 1 ], obj.target[ 2 ], enableTransition );
_sphericalA.setFromVector3( position.sub( this._targetEnd ).applyQuaternion( this._yAxisUpSpace ) );
_sphericalA.setFromVector3( _v3A.fromArray( obj.position ).sub( this._targetEnd ).applyQuaternion( this._yAxisUpSpace ) );
this.rotateTo( _sphericalA.theta, _sphericalA.phi, enableTransition );
this.zoomTo( obj.zoom, enableTransition );
this.setFocalOffset( obj.focalOffset[ 0 ], obj.focalOffset[ 1 ], obj.focalOffset[ 2 ], enableTransition );
Expand Down

0 comments on commit 4fb31a0

Please sign in to comment.