如何知道ARKit中检测到的节点是垂直的还是水平的?

时间:2018-06-27 07:02:05

标签: ios arkit

让配置= ARWorldTrackingConfiguration() configuration.planeDetection = [.horizo​​ntal,.vertical]

如何通过委托方法知道检测到的平面是水平还是垂直?

func renderer(_ renderer:SCNSceneRenderer,didAdd节点:SCNNode,锚点:ARAnchor)

1 个答案:

答案 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")

        }

 }

希望有帮助...