From 677309be6bd0d2d87c3aab6c2306150b80bd839b Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 17 Dec 2024 12:06:06 +0100 Subject: [PATCH] #11 - add reset view on track change --- .../project/virtual-sample/Interactive360.vue | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/components/project/virtual-sample/Interactive360.vue b/src/components/project/virtual-sample/Interactive360.vue index c81c21f..264b11d 100644 --- a/src/components/project/virtual-sample/Interactive360.vue +++ b/src/components/project/virtual-sample/Interactive360.vue @@ -35,22 +35,6 @@ const virtualSampleStore = useVirtualSampleStore(); const isHelperHidden = ref(localStorage.getItem("isHelperHidden")); localStorage.setItem("isHelperHidden", true); -// Images preload -const imageUrls = computed(() => activeTrack.files.map((file) => file.url)); -watch( - imageUrls, - () => { - preloadImages(); - }, - { immediate: true } -); -function preloadImages() { - imageUrls.value.forEach((imageUrl) => { - const image = new Image(); - image.src = imageUrl; - }); -} - // Grab interaction const yMax = computed(() => { return parseInt( @@ -136,6 +120,11 @@ function handleVerticalRotation(event) { } } +function resetView() { + currentX.value = 0; + currentY.value = 0; +} + const throttledDragToRotate = throttle(dragToRotate, 50); watch(isDragToRotateEnabled, (newValue) => { @@ -170,4 +159,21 @@ watch(isLoopAnimationEnabled, (newValue) => { clearInterval(animationIntervalId); } }); + +// Images preload +const imageUrls = computed(() => activeTrack.files.map((file) => file.url)); +watch( + imageUrls, + () => { + preloadImages(); + resetView(); + }, + { immediate: true } +); +function preloadImages() { + imageUrls.value.forEach((imageUrl) => { + const image = new Image(); + image.src = imageUrl; + }); +}