Search code examples
androidarcoresceneform

How do I despawn a rendered model in SceneForm?


I am new to SceneForm. I have created a code that renders a model when user taps on a point on screen. How do I remove this model on say, when user taps a clear all button. Here is my spawn function

 private void addModeltoScene(ModelRenderable modelRenderable) {


    TransformableNode transformableNode = new TransformableNode(arFragment.getTransformationSystem());
    transformableNode.setParent(anchorNode);
    transformableNode.setRenderable(modelRenderable);
    //now add to scene
    arFragment.getArSceneView().getScene().addChild(anchorNode);
    transformableNode.select();



}

Solution

  • arFrameFragment.arSceneView.scene.removeChild(node)
    

    Where node is AnchorNode for your 3D model and arFrameFragment is ArFragment