Skip to content

Commit

Permalink
Merge pull request #335 from Carifio24/pin-zoom
Browse files Browse the repository at this point in the history
Pin 3D camera zoom between min and max values
  • Loading branch information
patudom authored Jan 6, 2024
2 parents 8524d67 + d36484a commit 3892b37
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions radwave/src/Radwave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ import { Coordinates } from "@wwtelescope/engine";
import { GotoRADecZoomParams } from "@wwtelescope/engine-pinia";
import { AltTypes, AltUnits, MarkerScales, RAUnits } from "@wwtelescope/engine-types";
import { zoom } from "./wwt-hacks";
import sunCsv from "./assets/Sun_radec.csv";
import bestFitCsv from "./assets/radwave/RW_best_fit_oscillation_phase_radec_downsampled.csv";
Expand Down Expand Up @@ -552,6 +554,9 @@ export default defineComponent({
previousMode: mode as "2D" | "3D" | "full" | null,
fullwavePosition: fullwavePosition,
minZoom: 160763995.5927744,
maxZoom: 22328103718.39476
};
},
Expand Down Expand Up @@ -593,6 +598,14 @@ export default defineComponent({
this.resizeObserver = new ResizeObserver((_entries) => {
this.shinkWWT();
});
// Pin the min and max zoom in 3D mode
WWTControl.singleton.setSolarSystemMinZoom(this.minZoom);
WWTControl.singleton.setSolarSystemMaxZoom(this.maxZoom);
// Patch the zoom function to account for min zoom as well
// See upstream fix at https://github.com/WorldWideTelescope/wwt-webgl-engine/pull/292
WWTControl.singleton.zoom = zoom.bind(WWTControl.singleton);
},
Expand Down
20 changes: 20 additions & 0 deletions radwave/src/wwt-hacks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

/* eslint-disable */

import { Settings } from "@wwtelescope/engine";

export function zoom(factor: number) {
this.renderContext.targetCamera.zoom *= factor;
if (this.renderContext.targetCamera.zoom > this.get_zoomMax()) {
this.renderContext.targetCamera.zoom = this.get_zoomMax();
}
if (this.renderContext.targetCamera.zoom < this.get_zoomMin()) {
this.renderContext.targetCamera.zoom = this.get_zoomMin();
}

if (!Settings.get_globalSettings().get_smoothPan()) {
this.renderContext.viewCamera = this.renderContext.targetCamera.copy();
}
}

0 comments on commit 3892b37

Please sign in to comment.