Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Dec 30, 2023
1 parent 610f90b commit ab8a031
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions example/src/GlobeControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,8 @@ export class GlobeControls {

if ( ! this.zoomDirectionSet ) {

const { raycaster, scene } = this;
const { raycaster } = this;
raycaster.setFromCamera( _pointer, this.camera );

const hit = raycaster.intersectObject( scene )[ 0 ] || null;
if ( hit ) {

this.zoomPoint.copy( hit.point );
this.zoomPointSet = true;

}

this.zoomDirection.copy( this.raycaster.ray.direction ).normalize();
this.zoomDirectionSet = true;

Expand Down Expand Up @@ -546,7 +537,6 @@ export class GlobeControls {
_updateZoom( scale ) {

const {
zoomPointSet,
zoomPoint,
zoomDirection,
camera,
Expand All @@ -558,21 +548,14 @@ export class GlobeControls {

const fallback = scale < 0 ? - 1 : 1;
let dist = Infinity;
if ( zoomPointSet ) {

dist = zoomPoint.distanceTo( camera.position );

} else {

raycaster.ray.origin.copy( camera.position );
raycaster.ray.direction.copy( zoomDirection );
raycaster.ray.origin.copy( camera.position );
raycaster.ray.direction.copy( zoomDirection );

const hit = raycaster.intersectObject( scene )[ 0 ] || null;
if ( hit ) {

dist = hit.distance;
const hit = raycaster.intersectObject( scene )[ 0 ] || null;
if ( hit ) {

}
dist = hit.distance;
zoomPoint.copy( hit.point );

}

Expand Down Expand Up @@ -602,6 +585,7 @@ export class GlobeControls {
// so as the use drags it winds up in the same spot.
// Will this work? Or be good enough?
this.camera.position.add( delta );
this.camera.updateMatrixWorld();

}

Expand Down Expand Up @@ -655,6 +639,8 @@ export class GlobeControls {

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

raycaster.ray.direction.copy( up ).multiplyScalar( - 1 );
raycaster.ray.origin.copy( camera.position ).addScaledVector( raycaster.ray.direction, - 100 );

Expand Down Expand Up @@ -712,6 +698,8 @@ export class GlobeControls {

}

this.up.copy( newUp );

}

}
Expand Down

0 comments on commit ab8a031

Please sign in to comment.