Replies: 6 comments 8 replies
-
I'll be back after doing more required reading on the post processing tooling that's already available to three.js. |
Beta Was this translation helpful? Give feedback.
-
Trying to reason through this:
|
Beta Was this translation helpful? Give feedback.
-
i've implemented mouse picking before - but it comes with greater caveats. to wire that into pointer events, well, that's gonna be complex but i think r3f exposes enough data to make this possible in user-land. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the notes! Yes this is helpful. if you guys think there's no obvious roadblocks down that path then it's good enough for me to consider the path as a potential way forward. I also forgot yesterday to mention that another method is of course utilizing a spatial acceleration structure to continue doing raycasts on the CPU! |
Beta Was this translation helpful? Give feedback.
-
Hi all. I've actually gotten mouse picking working now after going through an interesting journey into postprocessing. It seems to work! However I'm stuck on a bit of a funny problem. As you see I need to obtain the NDC coordinates of e.g. a mouse click in order to pass it in (to determine the precise location of the depth buffer to sample from the GPU back out to the CPU), I've found that attaching an event handler doesn't fire. I wonder if R3F explicitly captures all mouse events within. I wonder if there's a simple way I can get this back without hacking too much into R3F? |
Beta Was this translation helpful? Give feedback.
-
Hello @unphased, I'm about to implement a GPU picking solution to my app and I'd be very interested in seeing how you went about it ! |
Beta Was this translation helpful? Give feedback.
-
I'm a curious about whether it is possible to have hookable approaches to these techniques.
Here's an example for picking: https://threejsfundamentals.org/threejs/lessons/threejs-picking.html
A common use case for depth feedback is reading the rendered depth value at a particular pixel offset (The mouse position), this would constitute an alternative approach to raycasting, and indeed GPU Picking is somewhat of a generalization of raycasting done from the camera. (Indeed reading depth produces the 3d position, and Picking is a way to obtain some kind of object ID)
For example my present desire is to improve usability in my app by performing raycasting under the mouse to aid in navigating the 3D space (for a CAD application this isn't really an optional feature). Although it's readily doable to use CPU raycasting, it would be nice not to have to worry about complex geometry potentially impacting the performance of the routine. It also seems like there is an opportunity to put a foundation in place so that gpu based techniques can be used universally for mouse/ui raycasting needs, although it may be quite an undertaking considering the complexity of replicating a bubbling event model.
If we try to simplify and only climb a small way up the ladder of ambition, I wonder if perhaps there's something that can be hacked together with EffectComposer to just allow for reading out pixels from a depth render target or texture?
Beta Was this translation helpful? Give feedback.
All reactions