Skip to content

Commit

Permalink
fix(ScatterPlot): keep from switching to camera mode
Browse files Browse the repository at this point in the history
When switching between 2D and 3D points, pan/camera mode
was always becoming active.
  • Loading branch information
PaulHax committed Jan 21, 2025
1 parent 1ef4c58 commit 5e5f818
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions vue-components/src/components/ScatterPlot.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch, onMounted, toRefs, computed, watchEffect } from 'vue'
import { ref, watch, onMounted, toRefs, computed } from 'vue'
import { ScatterGL } from 'scatter-gl'
import { createColorMap, linearScale } from '@colormap/core'
Expand Down Expand Up @@ -90,10 +90,6 @@ const dataset = computed(() => {
return new ScatterGL.Dataset(allPoints)
})
watch([scatterPlotRef, dataset, selectedPoints, highlightedPoint, colorMap, hideSourcePoints], () =>
scatterPlot?.render(dataset.value)
)
const sequences = computed(() => {
return transformedPointIds.value.map((id) => ({
indices: [idToIndex(id, false), idToIndex(id, true)]
Expand All @@ -108,6 +104,17 @@ watch([sequences, scatterPlotRef], () => {
}
})
watch(
[scatterPlotRef, dataset, selectedPoints, highlightedPoint, colorMap, hideSourcePoints],
() => {
scatterPlot?.render(dataset.value)
if (selectMode.value) {
// When switching bettween 3D and 2D, ScatterGL pan/rotate mode is always active. Stop that.
scatterPlot?.setSelectMode()
}
}
)
onMounted(() => {
if (!plotContainer.value) {
return
Expand All @@ -116,9 +123,6 @@ onMounted(() => {
scatterPlot = new ScatterGL(plotContainer.value, {
rotateOnStart: false,
selectEnabled: true,
styles: {
axesVisible: true
},
pointColorer(i) {
const id = indexToId(i)
const isTrans = isTransformed(i)
Expand Down

0 comments on commit 5e5f818

Please sign in to comment.