I couldn't get hitTest (with no options) to detect geometries that are hidden behind some other geometry in iOS 11. My code worked fine on iOS 10. Anyone know how to fix?
Example: let hitResults = scnView.hitTest(location, options: nil)
Should return several nodes - but does only return one node.
You should use the symbolic constant SCNHitTestSearchMode.all
instead of 1
, it's more descriptive.
if #available(iOS 11.0, *) {
hitResults = scnView.hitTest(location, options: [.searchMode: SCNHitTestSearchMode.all.rawValue]) }
}
The other options are .closest
and .any
.
Adding some additional details - in my experience, there has been a major change from iOS 10 to iOS 11 in the way SceneKit handles touches. Specifically, the DEFAULT operation in SceneKit, as Bernd notes above, is now that only the first node touched in the "ray" is returned in the [SCNHitTestResult].
The additional comment is that if you were hoping for backward compatibility to iOS 10 or before, I couldn't seem to get it to work, because the solution noted above requires iOS 11 Deployment Target. So Apple seems to have changed the default way touches are handled, and if you want it to work the original way, you must change the default of [SCNHitTestOption.searchMode : 1], which is only available if/when you change your Deployment Target to iOS 11 or higher. ( thanks, Apple)
Here are some futher oddities I found as I searched for a way to make an iOS 10 deployment work with Xcode 9 / iOS 11 updates. (note: I had upgraded my phone to iOS 11 when testing these scenarios with an iOS 10.3 Deployment Target build)
Bottom line, from what I can tell, is that Apple does everything in its power to force devs to upgrade to the latest OS (either wittingly or unwittingly), which then "encourages" end users to have to upgrade to get the latest app updates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With