Get the direction arrow toward the SCNNode once that node is not visible in ARCamera

本秂侑毒 提交于 2019-12-13 12:41:18

问题


If ARCamera moving left, right, up or down and if that node becomes invisible in ARCamera. I want to indicate the arrow that you need to move camera up/down/right/left.


回答1:


    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:) here checks if node is visible in ARCamera.
Use it inside renderer(_:updateAtTime:)

Edit: Arrow here is a node (3d arrow). Remember the point of arrow need to face -z axis

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


来源:https://stackoverflow.com/questions/53083642/get-the-direction-arrow-toward-the-scnnode-once-that-node-is-not-visible-in-arca

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!