如果ARKit的hitTest(_:options:)方法在选择放置的3D对象时不起作用,可能有几个原因导致。以下是一些可能的解决方法:
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .horizontal
arSession.run(configuration)
guard let currentFrame = arSession.currentFrame else {
return
}
let hitTestResults = currentFrame.hitTest(screenCenter, types: [.existingPlane, .existingPlaneUsingExtent])
let screenCenter = CGPoint(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height / 2)
let hitTestResults = currentFrame.hitTest(userTappedLocation, types: [.featurePoint])
这些解决方法应该能够帮助你解决ARKit的hitTest(_:options:)不起作用的问题。请根据你的具体情况进行调整和调试。
下一篇:ARKit的开源替代方案