From 695e27f5bf1b5afe05cc7e67f98ec037974734ed Mon Sep 17 00:00:00 2001 From: BernatBC Date: Sat, 8 Jun 2024 16:04:19 +0200 Subject: [PATCH] Fix raycast trespassing UI --- interaction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interaction.js b/interaction.js index 4e9e924..8b7620d 100644 --- a/interaction.js +++ b/interaction.js @@ -74,7 +74,7 @@ function addInteraction(cam, sce, cntrls) { function onClick() { event.preventDefault(); // Avoid clicking images behind GUI - if (event.target.tagName === "DIV") return; + if (event.target.tagName !== "CANVAS") return; mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; raycaster.setFromCamera(mouse, camera); @@ -143,7 +143,7 @@ function onHover() { if (mDragging) return; event.preventDefault(); // Avoid clicking images behind GUI - if (event.target.tagName === "DIV") return; + if (event.target.tagName !== "CANVAS") return; mouse.x = (event.clientX / window.innerWidth) * 2 - 1; mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; raycaster.setFromCamera(mouse, camera);