From aeffa70dda0905d85204d5437f94a6ce45f600e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=B6lling?= Date: Thu, 15 May 2025 01:51:44 +0900 Subject: [PATCH 1/2] implement azimuthal projection --- src/components/Globe.vue | 24 +++++++++++-- src/components/GlobeControls.vue | 22 ++++++++++++ src/components/GlobeHealpix.vue | 24 ++++++++++++- src/components/utils/colormapShaders.ts | 46 ++++++++++++++++++++++--- src/types/GlobeTypes.ts | 7 +++- src/views/GlobeView.vue | 1 + 6 files changed, 115 insertions(+), 9 deletions(-) diff --git a/src/components/Globe.vue b/src/components/Globe.vue index b1fb7f74..ce3e5b63 100644 --- a/src/components/Globe.vue +++ b/src/components/Globe.vue @@ -6,6 +6,7 @@ import { makeColormapMaterial, availableColormaps, calculateColorMapProperties, + availableProjections, } from "./utils/colormapShaders.ts"; import { decodeTime } from "./utils/timeHandling.ts"; @@ -26,6 +27,7 @@ import { storeToRefs } from "pinia"; import type { TBounds, TColorMap, + TProjection, TSources, TVarInfo, } from "../types/GlobeTypes.ts"; @@ -38,6 +40,7 @@ const props = defineProps<{ varbounds?: TBounds; colormap?: TColorMap; invertColormap?: boolean; + projection?: TProjection; }>(); const emit = defineEmits<{ varinfo: [TVarInfo] }>(); @@ -109,11 +112,18 @@ watch( } ); +watch( + () => props.projection, + () => { + updateProjection(); + } +); + const colormapMaterial = computed(() => { if (props.invertColormap) { - return makeColormapMaterial(props.colormap, 1.0, -1.0); + return makeColormapMaterial(props.colormap, 1.0, -1.0, props.projection); } else { - return makeColormapMaterial(props.colormap, 0.0, 1.0); + return makeColormapMaterial(props.colormap, 0.0, 1.0, props.projection); } }); @@ -184,6 +194,16 @@ function updateColormap() { redraw(); } +function updateProjection() { + if (props.projection) { + const myMesh = mainMesh as THREE.Mesh; + const material = myMesh.material as THREE.ShaderMaterial; + material.uniforms.projection.value = + availableProjections[props.projection!]; + redraw(); + } +} + async function getData() { store.startLoading(); try { diff --git a/src/components/GlobeControls.vue b/src/components/GlobeControls.vue index 1c8288fe..c41b114c 100644 --- a/src/components/GlobeControls.vue +++ b/src/components/GlobeControls.vue @@ -7,9 +7,11 @@ import type { TColorMap, TModelInfo, TBounds, + TProjection, TVarInfo, TSelection, } from "../types/GlobeTypes.js"; +import { availableProjections } from "./utils/colormapShaders.ts"; const props = defineProps<{ varinfo?: TVarInfo; modelInfo?: TModelInfo }>(); @@ -32,6 +34,7 @@ const defaultBounds: Ref = ref({}); const userBoundsLow: Ref = ref(undefined); const userBoundsHigh: Ref = ref(undefined); const pickedBounds = ref("auto"); +const projection: Ref = ref("perspective"); const activeBounds = computed(() => { if (pickedBounds.value === "auto") { @@ -119,6 +122,11 @@ watch( () => setDefaultColormap() ); +watch( + () => projection.value, + () => publish() +); + function toggleMenu() { menuCollapsed.value = !menuCollapsed.value; } @@ -132,6 +140,7 @@ const publish = () => { bounds: bounds.value as TBounds, colormap: colormap.value, invertColormap: invertColormap.value, + projection: projection.value, }); }; @@ -404,6 +413,19 @@ publish(); // ensure initial settings are published +
+
+ +
+