0

Apologize in advance for what may be dumb questions.

I'm trying to understand the picking implementation in three.js. Last I looked at the code, it appeared to be doing mathematical intersections in JavaScript. Is that true?

If so, couldn't an off screen buffer color assignment approach work? I vaguely remember something about color precision being an issue but I would think there should be ways around that. Wouldn't this be much faster?

Or is something like this already implemented and I've missed it or just don't generally understand?

  • Ray picking will calculate intersections with mesh faces. Color picking can be used with success, but `gl.readPixels` is slow. Faster methods may also be viable depending on your use case (eg. picking a tile from a height map). It's easier to recommend an approach if you present your actual problem. – user1421750 Nov 26 '13 at 16:15
  • to complete the above comment, see "interactive cubes" and "interactive cubes gpu" sample for CPU/GPU picking examples. – GuyGood Nov 26 '13 at 18:13
  • Thanks for the answers. I hadn't seen/noticed the "cubes gpu" demo; it is exactly the approach I was asking about. But I'm confused as to why ray picking would be used with WebGL. Wouldn't readPixels (even if it is relatively slow) be faster than ray picking in any scene with more than just a few objects? – Paul Jacobs Nov 26 '13 at 19:00
  • Well, you have some overhead with the rendering of a second pass. I am not sure if the object count is important or rather the object hierarchy. I think for deeper hierarchies of a couple hundred objects, gpu picking will be faster even if it means rendering a second pass for the colorIDs. – GuyGood Nov 26 '13 at 21:52

0 Answers0