一旦该节点在ARCamera中不可见,获取指向SCNNode的方向箭头

时间:2018-10-31 12:44:09

标签: ios swift xcode arkit scnnode

如果ARCamera向左,向右,向上或向下移动,并且该节点在ARCamera中不可见。我想指出您需要向上/向下/向右/向左移动相机的箭头。

1 个答案:

答案 0 :(得分:2)

    if let pointOfView = sceneView.pointOfView{
        let isMaybeVisible = sceneView.isNode((displayNode.presentation), insideFrustumOf: pointOfView)
        if isMaybeVisible{
            if arrowVisible{
                 arrow.removeFromParentNode()
            }
        }else{
            if !arrowVisible{
                 sceneView.pointOfView?.addChildNode(arrow)
            }
        }
    }

isNode(_:insideFrustumOf:)在此检查节点是否在ARCamera中可见。
renderer(_:updateAtTime:)

中使用它

编辑: 这里的箭头是节点(3d箭头)。记住箭头需要面对-z轴

    let scene = SCNScene(named: "art.scnassets/arrow.dae")
    let arrow = scene?.rootNode.childNode(withName: "arrow", recursively: false)
    arrow.constraints = [SCNLookAtConstraint.init(target: node)]