让配置= ARWorldTrackingConfiguration() configuration.planeDetection = [.horizontal,.vertical]
如何通过委托方法知道检测到的平面是水平还是垂直?
func renderer(_ renderer:SCNSceneRenderer,didAdd节点:SCNNode,锚点:ARAnchor)
答案 0 :(得分:2)
ARPlaneAnchor
具有alignment
属性,该属性描述:
检测到的平面相对于重力的大致方向。
这样,如果您想登录alignment
,可以执行以下操作:
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
//1. Check We Have A Valid ARPlaneAnchor
guard let planeAnchor = anchor as? ARPlaneAnchor else { return }
//2. Get It's Alignment
if planeAnchor.alignment == .horizontal{
print("The ARPlaneAnchor Alignment == Horizontal")
}else if planeAnchor.alignment == .vertical{
print("The ARPlaneAnchor Alignment == Vertical")
}
}
希望有帮助...