Show hidden characters
Let’s take a closer look at the situation.
With the aid of supportFragmentManager and the fragment id, we first get the fragment we inserted in our layout code.
The model must then be loaded into the scene. The ModelRenderable class from the Sceneform SDK is used for this. We can load our model by passing the name of the generated.sfb file to ModelRenderable’s setSource() process.
Since the model is being constructed in the background, it is introduced to the main thread once it is loaded, which makes it to the scene.
The model is passed into the thenAccept form. An exception is thrown if the model is built incorrectly.
Now that our model has been loaded, it’s time to put it in the scene.
Step 8:Adding the Model to the AR Scene
Since our AR fragment is the scene’s container, we need to add a model to it once it is clicked. As a result, we’ll have a onTapListener in our fragment.
Scene:
This is where our three-dimensional world will be made.
It’s an imaginary ray of light that comes from infinity, and the point of tap is its first point of intersection with the real world.
AnchorNode:
This is the node that places itself in the world automatically. When the plane is detected, this is the first node to be set.
A fixed position in the physical world is referred to as an anchor. Used to convert local coordinates (as seen by the user) to real-world coordinates.
TransformableNode
: A node that responds to user interactions including rotation, zooming, and dragging.
The following is an example of your final Java file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.