Commit 0e320470 authored by Percen's avatar Percen
Browse files

Update public/index.html

Showing with 15 additions and 16 deletions
+15 -16
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
let currentModel = null; let currentModel = null;
let scene, camera, hitTestSource; let scene, camera, hitTestSource;
let hitTestResults = []; let hitTestResults = [];
let isSwipe = false;
async function activateXR() { async function activateXR() {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
...@@ -101,30 +100,30 @@ ...@@ -101,30 +100,30 @@
} }
// Touch-Logik zur Unterscheidung zwischen Swipe und Tap // Touch-Logik zur Unterscheidung zwischen Swipe und Tap
let startX = 0, endX = 0, isSwiping = false; let startX = 0, startY = 0, endX = 0, endY = 0;
const threshold = 50; const swipeThreshold = 50; // Minimale Swipe-Distanz
document.body.addEventListener('touchstart', (e) => { document.body.addEventListener('touchstart', (e) => {
startX = e.touches[0].clientX; startX = e.touches[0].clientX;
isSwiping = false; startY = e.touches[0].clientY;
}); });
document.body.addEventListener('touchmove', (e) => { document.body.addEventListener('touchend', (e) => {
const moveX = e.touches[0].clientX; endX = e.changedTouches[0].clientX;
if (Math.abs(moveX - startX) > threshold) { endY = e.changedTouches[0].clientY;
isSwiping = true;
if (moveX > startX) { const deltaX = endX - startX;
const deltaY = endY - startY;
// Unterscheidung zwischen Swipe und Tap
if (Math.abs(deltaX) > swipeThreshold) {
if (deltaX > 0) {
switchModel('next'); switchModel('next');
} else { } else {
switchModel('previous'); switchModel('previous');
} }
startX = moveX; // Verhindert mehrfaches Swipen bei einem langen Touchmove } else if (Math.abs(deltaY) < swipeThreshold) {
} placeModel(); // Nur platzieren, wenn keine große Bewegung erkannt wurde
});
document.body.addEventListener('touchend', () => {
if (!isSwiping) {
placeModel();
} }
}); });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment