Hello everybody,
I am relatively new to ARKit and SceneKit and I have been experimenting with it.
I have been exploring plane detection and I want to keep only one plane in the view. If other planes are found I want the old ones to be removed.
This is the solution I found: I have an array with all found anchors and before adding a new child node I remove all the anchors from my scene.
What do you think of this solution? Do you think I should do it in any other way? Thank you!
I am relatively new to ARKit and SceneKit and I have been experimenting with it.
I have been exploring plane detection and I want to keep only one plane in the view. If other planes are found I want the old ones to be removed.
This is the solution I found: I have an array with all found anchors and before adding a new child node I remove all the anchors from my scene.
What do you think of this solution? Do you think I should do it in any other way? Thank you!
Code Block private var planes = [UUID: Plane]() private var anchors = [UUID: ARAnchor]() func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { // we only care about planes guard let planeAnchor = anchor as? ARPlaneAnchor else { return } print("Found plane: \(planeAnchor)") for anchor in anchors { sceneView?.session.remove(anchor: anchor.value) } let plane = Plane(anchor: planeAnchor) planes[anchor.identifier] = plane anchors[anchor.identifier] = anchor node.addChildNode(plane) }