From 0fd246d14f651b54991399dcdce22eddc2c1fab3 Mon Sep 17 00:00:00 2001 From: Tonyyu-1 <128781638+Tonyyu-1@users.noreply.github.com> Date: Tue, 9 Jul 2024 21:59:51 +0800 Subject: [PATCH] Update main.js --- src/main.js | 99 +---------------------------------------------------- 1 file changed, 1 insertion(+), 98 deletions(-) diff --git a/src/main.js b/src/main.js index 22f3591..ab12aed 100644 --- a/src/main.js +++ b/src/main.js @@ -1138,104 +1138,7 @@ async function main() { startY = 0; }); - let altX = 0, - altY = 0; - canvas.addEventListener( - "touchstart", - (e) => { - e.preventDefault(); - if (e.touches.length === 1) { - carousel = false; - startX = e.touches[0].clientX; - startY = e.touches[0].clientY; - down = 1; - } else if (e.touches.length === 2) { - // console.log('beep') - carousel = false; - startX = e.touches[0].clientX; - altX = e.touches[1].clientX; - startY = e.touches[0].clientY; - altY = e.touches[1].clientY; - down = 1; - } - }, - { passive: false }, - ); - canvas.addEventListener( - "touchmove", - (e) => { - e.preventDefault(); - if (e.touches.length === 1 && down) { - let inv = invert4(viewMatrix); - let dx = (4 * (e.touches[0].clientX - startX)) / innerWidth; - let dy = (4 * (e.touches[0].clientY - startY)) / innerHeight; - - let d = 4; - inv = translate4(inv, 0, 0, d); - // inv = translate4(inv, -x, -y, -z); - // inv = translate4(inv, x, y, z); - inv = rotate4(inv, dx, 0, 1, 0); - inv = rotate4(inv, -dy, 1, 0, 0); - inv = translate4(inv, 0, 0, -d); - - viewMatrix = invert4(inv); - actualViewMatrix = invert4(inv); - startX = e.touches[0].clientX; - startY = e.touches[0].clientY; - } else if (e.touches.length === 2) { - // alert('beep') - const dtheta = - Math.atan2(startY - altY, startX - altX) - - Math.atan2( - e.touches[0].clientY - e.touches[1].clientY, - e.touches[0].clientX - e.touches[1].clientX, - ); - const dscale = - Math.hypot(startX - altX, startY - altY) / - Math.hypot( - e.touches[0].clientX - e.touches[1].clientX, - e.touches[0].clientY - e.touches[1].clientY, - ); - const dx = - (e.touches[0].clientX + - e.touches[1].clientX - - (startX + altX)) / - 2; - const dy = - (e.touches[0].clientY + - e.touches[1].clientY - - (startY + altY)) / - 2; - let inv = invert4(viewMatrix); - // inv = translate4(inv, 0, 0, d); - inv = rotate4(inv, dtheta, 0, 0, 1); - - inv = translate4(inv, -dx / innerWidth, -dy / innerHeight, 0); - - // let preY = inv[13]; - inv = translate4(inv, 0, 0, 3 * (1 - dscale)); - // inv[13] = preY; - - viewMatrix = invert4(inv); - - startX = e.touches[0].clientX; - altX = e.touches[1].clientX; - startY = e.touches[0].clientY; - altY = e.touches[1].clientY; - } - }, - { passive: false }, - ); - canvas.addEventListener( - "touchend", - (e) => { - e.preventDefault(); - down = false; - startX = 0; - startY = 0; - }, - { passive: false }, - ); + let jumpDelta = 0; let vertexCount = 0;