I want to put 2d arrows on the edge of the screen that point to a node off screen to show which way to turn the camera so it becomes visible,The node is a real world location represented by a map pin.
I wrote code to find if the node sits to the left or right of the frustum when not visible.
The way i am trying to do it is by getting a camera coordinate for the node, then -X is on left, +X on the right but it doesnt work as expected, any help really appreciated.
var deltaTime = TimeInterval()
public func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
deltaTime = time - lastUpdateTime
if deltaTime>1{
if let annotation = annotationsByNode.first {
let node = annotation.key.childNodes[0]
if !renderer.isNode(node, insideFrustumOf: renderer.pointOfView!)
{
print("Pin is not visible");
}else {
print("Pin is visible");
}
let pnt = renderer.projectPoint(node.position)
print("pos ", pnt.x)
let dir = (isVisible) ? "visible" : ( (pin.x<0) ? "left" : "right")
}
lastUpdateTime = time
}
}