From 43eeb30925b598d03927b1d021cebb0f046d1b8f Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Thu, 4 Jan 2024 17:23:53 +0000 Subject: [PATCH 1/5] Pin camera zoom between min and max values. --- radwave/src/Radwave.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/radwave/src/Radwave.vue b/radwave/src/Radwave.vue index f04f0dfe..e4991055 100644 --- a/radwave/src/Radwave.vue +++ b/radwave/src/Radwave.vue @@ -552,6 +552,9 @@ export default defineComponent({ previousMode: mode as "2D" | "3D" | "full" | null, fullwavePosition: fullwavePosition, + + minZoom: 260763995.5927744, + maxZoom: 7328103718.39476 }; }, @@ -1058,6 +1061,21 @@ export default defineComponent({ return; } + }, + + wwtZoomDeg(zoom: number) { + if (mode !== "3D") { + return; + } + const pinnedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); + if (pinnedZoom !== zoom) { + this.gotoRADecZoom({ + raRad: this.wwtRARad, + decRad: this.wwtDecRad, + zoomDeg: pinnedZoom, + instant: true + }); + } } } From 390d99feb1578bfc72a2859fe36d32e02336520e Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 5 Jan 2024 18:10:30 +0000 Subject: [PATCH 2/5] Implement zoom bounds in WWT directly. --- radwave/src/Radwave.vue | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/radwave/src/Radwave.vue b/radwave/src/Radwave.vue index e4991055..b0b301fc 100644 --- a/radwave/src/Radwave.vue +++ b/radwave/src/Radwave.vue @@ -596,6 +596,10 @@ 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); }, @@ -1061,21 +1065,6 @@ export default defineComponent({ return; } - }, - - wwtZoomDeg(zoom: number) { - if (mode !== "3D") { - return; - } - const pinnedZoom = Math.min(Math.max(zoom, this.minZoom), this.maxZoom); - if (pinnedZoom !== zoom) { - this.gotoRADecZoom({ - raRad: this.wwtRARad, - decRad: this.wwtDecRad, - zoomDeg: pinnedZoom, - instant: true - }); - } } } From 917cc825842baedcd9c610fe4d9facd90ee4b56f Mon Sep 17 00:00:00 2001 From: John Arban Lewis Date: Fri, 5 Jan 2024 15:02:34 -0500 Subject: [PATCH 3/5] add patch to fix min zoom settings --- radwave/package.json | 4 ++-- radwave/zoom_patch.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 radwave/zoom_patch.sh diff --git a/radwave/package.json b/radwave/package.json index e027a373..95823e4f 100644 --- a/radwave/package.json +++ b/radwave/package.json @@ -10,10 +10,10 @@ "webpack-plugin-vuetify": "^2.0.1" }, "scripts": { - "build": "vue-cli-service build", + "build": "./zoom_patch.sh; vue-cli-service build", "clean": "rimraf dist", "lint": "vue-cli-service lint src --no-fix", - "serve": "vue-cli-service serve" + "serve": "./zoom_patch.sh; vue-cli-service serve" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^6.13.2", diff --git a/radwave/zoom_patch.sh b/radwave/zoom_patch.sh new file mode 100755 index 00000000..c34c675d --- /dev/null +++ b/radwave/zoom_patch.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +filepath=node_modules/@wwtelescope/engine/src/index.js +if ! test -f ${filepath}; then + filepath="../${filepath}" +fi + +# Check whether the patch has already been run +# If so, no need to continue +altered_line=$(sed -n "/this.renderContext.targetCamera.zoom < this.get_zoomMin()/=" ${filepath} | head -n 1) +if [[ ! -z ${altered_line} ]] +then + echo "Zoom patch already applied!" + exit 0 +fi + +# zoom: function (factor) +teststring="> this.get_zoomMax()" # string must be unique +zoom_function_line=$(sed -n "/${teststring}/=" ${filepath}) + +insert_line=$((${zoom_function_line} + 2)) + +if [[ ! -z ${insert_line} ]] +then + sed -i.bak "${insert_line}a\\ + if (this.renderContext.targetCamera.zoom < this.get_zoomMin()) {\\ + this.renderContext.targetCamera.zoom = this.get_zoomMin();\\ + }\\ + + " ${filepath} + rm ${filepath}.bak +fi \ No newline at end of file From d18069df53c94db4e06871553190dd76223b94aa Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Fri, 5 Jan 2024 20:33:55 +0000 Subject: [PATCH 4/5] Remove zoom patch and hack in updated function instead. --- radwave/package.json | 4 ++-- radwave/src/Radwave.vue | 6 ++++++ radwave/src/wwt-hacks.ts | 20 ++++++++++++++++++++ radwave/zoom_patch.sh | 32 -------------------------------- 4 files changed, 28 insertions(+), 34 deletions(-) create mode 100644 radwave/src/wwt-hacks.ts delete mode 100755 radwave/zoom_patch.sh diff --git a/radwave/package.json b/radwave/package.json index 95823e4f..e027a373 100644 --- a/radwave/package.json +++ b/radwave/package.json @@ -10,10 +10,10 @@ "webpack-plugin-vuetify": "^2.0.1" }, "scripts": { - "build": "./zoom_patch.sh; vue-cli-service build", + "build": "vue-cli-service build", "clean": "rimraf dist", "lint": "vue-cli-service lint src --no-fix", - "serve": "./zoom_patch.sh; vue-cli-service serve" + "serve": "vue-cli-service serve" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^6.13.2", diff --git a/radwave/src/Radwave.vue b/radwave/src/Radwave.vue index b0b301fc..5469e56f 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"; @@ -600,6 +602,10 @@ export default defineComponent({ // 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(); + } +} diff --git a/radwave/zoom_patch.sh b/radwave/zoom_patch.sh deleted file mode 100755 index c34c675d..00000000 --- a/radwave/zoom_patch.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -filepath=node_modules/@wwtelescope/engine/src/index.js -if ! test -f ${filepath}; then - filepath="../${filepath}" -fi - -# Check whether the patch has already been run -# If so, no need to continue -altered_line=$(sed -n "/this.renderContext.targetCamera.zoom < this.get_zoomMin()/=" ${filepath} | head -n 1) -if [[ ! -z ${altered_line} ]] -then - echo "Zoom patch already applied!" - exit 0 -fi - -# zoom: function (factor) -teststring="> this.get_zoomMax()" # string must be unique -zoom_function_line=$(sed -n "/${teststring}/=" ${filepath}) - -insert_line=$((${zoom_function_line} + 2)) - -if [[ ! -z ${insert_line} ]] -then - sed -i.bak "${insert_line}a\\ - if (this.renderContext.targetCamera.zoom < this.get_zoomMin()) {\\ - this.renderContext.targetCamera.zoom = this.get_zoomMin();\\ - }\\ - - " ${filepath} - rm ${filepath}.bak -fi \ No newline at end of file From d36484ae3756656d4e7fc8e447ea51addedc02ec Mon Sep 17 00:00:00 2001 From: Pat Udomprasert Date: Fri, 5 Jan 2024 18:14:38 -0500 Subject: [PATCH 5/5] Expand limits. Full MW should fit in screen --- radwave/src/Radwave.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radwave/src/Radwave.vue b/radwave/src/Radwave.vue index 5469e56f..91b03149 100644 --- a/radwave/src/Radwave.vue +++ b/radwave/src/Radwave.vue @@ -555,8 +555,8 @@ export default defineComponent({ fullwavePosition: fullwavePosition, - minZoom: 260763995.5927744, - maxZoom: 7328103718.39476 + minZoom: 160763995.5927744, + maxZoom: 22328103718.39476 }; },