当应用程序在 ARKit 中检测到至少一架飞机时,如何获得通知?
我目前正在执行类似操作,但与 firing/it 无关:
extension MyViewController: ARSCNViewDelegate, ARSessionDelegate {
internal func setupAR() {
let scene = SCNScene()
sceneView.scene = scene
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal]
sceneView.session.delegate = self
sceneView.session.run(configuration)
}
public func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
if !anchors.isEmpty {
print("ANCHORS NOT EMPTY")
planesDetectedState()
} else {
print("Anchors is empty")
}
}
}
2 回答
请先添加锚点,然后再更新那些锚点。您需要使用以下功能:
另外,除非您在锚点上添加一个节点,否则您将看不到任何平面,这可以通过以下方式完成:
我还建议您下载入门代码,该代码对于您正在考虑的事情很容易遵循。
https://developer.apple.com/documentation/arkit/building_your_first_ar_experience
如果要检测
ARAnchors
,可以使用多种方法。**第一:**您可以使用
ARSessionDelegate
回调:哪一个:
因此,使用此回调的示例如下:
**第二:**您可以使用
ARSCNViewDelegate
回调:哪一个:
因此,使用此回调的示例如下: