Now that we have ARCore and Sceneform enabled and our 3D model included in the project, let's add the code that will make the model appear on the screen when a flat surface is detected and the user taps on the screen. Let's get started:
- Open your MainActivity.java file from app/java/com.banana.arprototype and add the following imports:
import android.net.Uri;import android.view.Gravity;import android.view.MotionEvent;import android.widget.Toast;import com.google.ar.core.Anchor;import com.google.ar.core.HitResult;import com.google.ar.core.Plane;import com.google.ar.sceneform.AnchorNode;import com.google.ar.sceneform.rendering.ModelRenderable;import com.google.ar.sceneform.ux.ArFragment;import com.google.ar.sceneform.ux.TransformableNode; ...