diff --git a/src/components/Globe.vue b/src/components/Globe.vue index b1fb7f7..ce3e5b6 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 1c8288f..c41b114 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 +
+
+ +
+