Skip to content

Commit

Permalink
Merge pull request #133 from BernatBC/fix-intersection
Browse files Browse the repository at this point in the history
Fix raycast trespassing UI
  • Loading branch information
BernatBC authored Jun 8, 2024
2 parents 6ecaf09 + 695e27f commit 18ed5b5
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 18ed5b5

Please sign in to comment.