From 75210c3db33e08efbdacf416c4789a950bfbc182 Mon Sep 17 00:00:00 2001 From: quez-fun <54435650+quez-fun@users.noreply.github.com> Date: Fri, 14 Jun 2024 16:43:08 +0800 Subject: [PATCH] Update index.html fixed a minor bug (after hovering over an object with link, clicking on white space will also trigger jumping to another page) --- index.html | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index ba58a32..e46aa3d 100644 --- a/index.html +++ b/index.html @@ -163,7 +163,7 @@

My Projects

}; let initialAnimation = true; - let oldPickNdx = -1; + let oldPickNdx = -1, isPicked = false; //create frame buffer const targetTexture = gl.createTexture(); @@ -345,23 +345,25 @@

My Projects

const pixels = new Uint8Array(4); gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - if (pixels[3] > 0) { + if (pixels[3] > 0) { - const pickNdx = (pixels[0] - 1) * rowNum + pixels[1]; + const pickNdx = (pixels[0] - 1) * rowNum + pixels[1]; - if (pickNdx == 9) { - tag.style.display = 'block'; - - tag.style.left = e.clientX - 35 + 'px'; - tag.style.top = e.clientY - 50 + 'px'; - tag.innerHTML = 'visit gallery'; - window.addEventListener('mousedown', pageJump, false); - } else { - tag.style.display = 'none'; - window.removeEventListener('mousedown', pageJump, false); - } + if (pickNdx == 9) { + tag.style.display = 'block'; + + tag.style.left = e.clientX - 35 + 'px'; + tag.style.top = e.clientY - 50 + 'px'; + tag.innerHTML = 'visit gallery'; + + isPicked = true; + + } else { + tag.style.display = 'none'; + isPicked = false; + } - if (oldPickNdx < 0) { + if (oldPickNdx < 0) { objects[(pickNdx - 1) * 4].colorUniforms.u_colorMult = [0.5, 0.3, 0.8, 0.55]; objects[(pickNdx - 1) * 4 + 1].colorUniforms.u_colorMult = [0.5, 0.3, 0.8, 0.55]; @@ -372,7 +374,7 @@

My Projects

drawScene(); - } else { + } else { if (oldPickNdx !== pickNdx) { @@ -407,6 +409,7 @@

My Projects

oldPickNdx = -1; tag.style.display = 'none'; + isPicked = false; } @@ -530,6 +533,8 @@

My Projects

window.addEventListener('resize', drawScene, false); window.addEventListener('mousemove', renderPicking, false); + + window.addEventListener('mousedown', pageJump, false); } } @@ -557,7 +562,11 @@

My Projects

} function pageJump() { - window.location.href = "https://quez-fun.github.io/gallery.html"; + + if (isPicked) { + window.location.href = "https://quez-fun.github.io/gallery.html"; + } + } main();