问题
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