Search code examples
androidarcore

How to remove all the transformableNodes already placed in the scene in ARCore?


I need to delete all the nodes from the scene after I place them, I added this Code to place transformableNodes in the scene

val anchorNode = AnchorNode(anchor)
    val transformableNode = TransformableNode(arFragment.transformationSystem)
    transformableNode.setParent(anchorNode)
    transformableNode.renderable = viewRenderable
    arFragment.arSceneView.scene.addChild(anchorNode)
    transformableNode.select()

After placing the AnchorNodes I want to remove all the transformableNodes from the scene


Solution

  • I found the answer after many tries

    for (node in nodesList){
            node.isEnabled = false
            arFragment.arSceneView.scene.removeChild(node)
        }