diff --git a/radwave/src/Radwave.vue b/radwave/src/Radwave.vue index f04f0dfe..91b03149 100644 --- a/radwave/src/Radwave.vue +++ b/radwave/src/Radwave.vue @@ -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"; @@ -552,6 +554,9 @@ export default defineComponent({ previousMode: mode as "2D" | "3D" | "full" | null, fullwavePosition: fullwavePosition, + + minZoom: 160763995.5927744, + maxZoom: 22328103718.39476 }; }, @@ -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); }, diff --git a/radwave/src/wwt-hacks.ts b/radwave/src/wwt-hacks.ts new file mode 100644 index 00000000..97ec064c --- /dev/null +++ b/radwave/src/wwt-hacks.ts @@ -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(); + } +}