Skip to content

Commit

Permalink
fixes to zoom logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Dec 30, 2023
1 parent 23914bc commit 4e9376a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions example/src/GlobeControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ export class GlobeControls {
raycaster.ray.origin.copy( camera.position );
raycaster.ray.direction.copy( zoomDirection );

console.log('UPDATING ZOOM POINT', performance.now(), new Error().stack)
const hit = raycaster.intersectObject( scene )[ 0 ] || null;
if ( hit ) {

Expand Down Expand Up @@ -671,7 +670,7 @@ export class GlobeControls {
let dist = 0;

// cast down from the camera to get the pivot to rotate around
const { up, camera, state } = this;
const { up, camera, state, zoomPoint, zoomDirection } = this;
camera.updateMatrixWorld();

const hit = this._getPointBelowCamera();
Expand All @@ -696,12 +695,12 @@ export class GlobeControls {

camera.updateMatrixWorld();

// TODO: removing this fixes the zoom point but the orientation can be put in a position that's
// potentially below the valid altitude. Why does rotating around the zoom point not work?
makeRotateAroundPoint( this.zoomPoint, _quaternion, _rotMatrix );
makeRotateAroundPoint( zoomPoint, _quaternion, _rotMatrix );
camera.matrixWorld.premultiply( _rotMatrix );
camera.matrixWorld.decompose( camera.position, camera.quaternion, _vec );

zoomDirection.subVectors( zoomPoint, camera.position ).normalize();

}

} else if ( state !== ROTATE ) {
Expand Down

0 comments on commit 4e9376a

Please sign in to comment.