Skip to content

Raycast weird intersections #1257

Answered by drcmda
ThiagoFacchini asked this question in Q&A
Discussion options

You must be logged in to vote

the raycaster has a line threshold that you need to set, it's dependent on your fov and camera position. the default is 1 which could mean anything, in your case it positively hits that line. make it smaller and it won't. that's all just threejs doing its thing: https://threejs.org/docs/index.html?q=ray#api/en/core/Raycaster.params

you can set these props directly on the canvas as a shortcut:

<Canvas raycaster={{ params: { Line: { threshold: 0.1 } } }}

btw i hope that's not how you raycast ... you should be doing:

<mesh onPointerOver={e => ...}
<lineSegments onClick={e => ...}

that is way more comfortable but also more efficient since its only hitting the objects that have handlers on them.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ThiagoFacchini
Comment options

@drcmda
Comment options

Answer selected by joshuaellis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants