Skip to content

Commit

Permalink
Fix raycast trespassing UI
Browse files Browse the repository at this point in the history
  • Loading branch information
BernatBC committed Jun 8, 2024
1 parent 8336332 commit 695e27f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 695e27f

Please sign in to comment.