Skip to content

Commit

Permalink
Update controls to allow zoom to cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Jan 11, 2025
1 parent 87679c7 commit 7187ed5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,14 @@ export default Kapsule({
controls.dampingFactor = 0.1;
controls.rotateSpeed = 0.3;
controls.zoomSpeed = 0.3;
controls.zoomToCursor = true;
controls.addEventListener('change', () => {
controls.target.setScalar(0); // Keep orbit target on center

// adjust controls speed based on altitude
const pov = this.pointOfView();
controls.rotateSpeed = pov.altitude * 0.3;
controls.zoomSpeed = Math.sqrt(pov.altitude) * 0.4;
controls.zoomSpeed = Math.sqrt(pov.altitude) * 0.5;

// Update three-globe pov when camera moves, for proper hiding of elements
state.globe.setPointOfView(state.renderObjs.camera());
Expand Down

0 comments on commit 7187ed5

Please sign in to comment.