I have created line in scene kit. i cant able to touch the line. Its not detect. But box, capsule is detecting. How can i touch the line?
I created line using SCNGeometryElement
Thanks
I have created line in scene kit. i cant able to touch the line. Its not detect. But box, capsule is detecting. How can i touch the line?
I created line using SCNGeometryElement
Thanks
There is no way to hitTest a geometry made of lines. What you can do maybe is to have a plain object with the same topology in your scene at the same location (for example make it a child node). Then make it hidden, and pass the option SCNHitTestIgnoreHiddenNodesKey=NO when doing the hitTest. When the hidden node is touched, select the corresponding version made of lines.
Your line is something like one point wide? Maybe one pixel, even? Your finger is about 44 points wide. A user is not going to reliably target something so small. (If they can target it at all — I'm not sure lines have width as far as hit testing is concerned.)
You're using hit testing to map touches to scene elements, right? You can set an option to use bounding-box hit testing instead of geometry hit testing, and maybe even set the bounding box to have nonzero volume so that hit testing can hit it.
Of course, if you do that, you'll also need to orient your node so that its bounding box follows the line. (Otherwise, the axis-aligned bounding box for a diagonal line is pretty big, including lots of space not near the line. This question discusses techniques for that... though at that point, you might just do the other stuff in that question so your lines have visible volume and not just hit-testable volume.