我在 iOS 11 上的 SceneKit 中使用 hitTest:options: 时遇到了困难。
在地图应用程序中,我有一个地形节点。使用 hitTest:options: 我能够长时间通过触摸屏幕来发现地形上的一个点。它仍然可以在 iOS 11 上发布的二进制文件上按预期工作,也可以在 Xcode 9 为 iOS 10 模拟器编译的二进制文件上正常工作。
但 iOS 11 SDK 上的 iOS 11 二进制文件给出了完全不稳定的结果。 hitTest:options: 返回数组可能不包含结果或包含太多结果。此外,大多数时候没有一个结果是有效的。下面的图片可以说明这一点。所有图像都来自没有隐藏节点的场景。
Edit:我今天使用 hitTestWithSegment From Point:to Point:options: 进行了测试,也得到了错误的结果。
首先使用工作模拟器。
It shows a normal hit on the terrain. The hit point is illustrated with a red ball. It is half inset in the terrain as its center is right on the terrain.
These two images show a case where the "ray" cross the terrain 3 times. We got 3 hits all placed correctly on the terrain.The second image change the angle of view to show the 3 points.
现在iOS 11失败的情况:
On this picture we got one hit but it is "nowhere" between the two mountains, not on the terrain.
最后两张图片显示了其他尝试,分别有 4 次和 16 次命中,全部“在蓝色中”,与地形无关。
有时击中点“远离”地形,有时击中点位于摄像机和地形之间。