gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:53:18 25 4
gpt4 key购买 nike

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

如何在他们的委托(delegate)方法中知道检测到的平面是水平的还是垂直的?

func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor)

最佳答案

一个 ARPlaneAnchor 有一个 alignment 属性,它描述了:

The general orientation of the detected plane with respect to gravity.

因此,如果您想记录对齐,您可以这样做:

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

}

}

希望对你有帮助

关于ios - 如何知道检测到的节点在 ARKit 中是垂直的还是水平的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51056460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com