Similar to VR experience, you can add AR Button to enable AR experiences. Additionally, you can specify the required and optional AR features your experience will use.
Add a controller: Returns a Group representing the so called target ray space of the controller. Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction.
When we are hitting a surface, to indicate the surface, we will create a reticle to our scene.
Let's define the onSelect event that we attached to controller. When the select event happen, meaning user decides to place the object and we create it on the chosen location.
Finally in our render function, we will check in every XRFrame if we have an hit-test source to display the reticle on the surface.
To run the code on your device, you have to give access to your camera when prompted.