Remove 3d model when AR image not focused

Hi , I'm implementing POC for image recognization using ARkit. I was successfully recogniza the image and add 3D model on top the camera view. Now I have to remove 3D model as soon as image un focused (When user moves camrea away from image). Is this possibel to acheive any suggestion ?

Replies

initialize SCNNode in below method


public func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {

let node = SCNNode()

//here give you code for create 3d model

return node

}

hope it will work try once give me feedback,

Thanks

If your 3D model is attached to the ARImageAnchor then it will disappear whenever the image isn't recognised in the frame anymore.



But it sounds like you're attaching it to the screen? If so, then you should make sure that you have set up an ARSessionDelegate, and use the function from there session(_:didRemove:). Check that the removed anchor is your ARImageAnchor, and when it happens remove or hide your SCNNode or Entity (SceneKit or RealityKit respectively) containing the model.