In the new arkit 2.0 documentation, it explain: and can accurately track when images disappear from view (or reappear afterward)
How could I be notified that the image is no loger visible ? I could not find the documentation about it.
Thankfully, Kevin
An ARImageAnchor conforms to the ARTrackable Protocol which:
is adopted by ARKit classes, such as the ARFaceAnchor class, that represent moving objects in a scene.
ARSCNView and ARSKView automatically hide the nodes for anchors whose isTracked property is false.
You can read more about it here.
As such you can do something like this to check if your image is visible or not:
//--------------------------
//MARK: - ARSessionDelegate
//--------------------------
extension ViewController: ARSessionDelegate{
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
//1. Enumerate Our Anchors To See If We Have Found Our Target Anchor
for anchor in anchors{
if let imageAnchor = anchor as? ARImageAnchor, imageAnchor == targetAnchor{
//2. If The ImageAnchor Is No Longer Tracked Then Handle The Event
if !imageAnchor.isTracked{
}else{
}
}
}
}
}
Whereby targetAnchor is simply an ARImageAnchor I have stored reference to as a Global Variable.
Hope it helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With