This article is a practical case revolving around existing code, which you can download here.
Overview
If you are familiar with ARCore and Sceneform, I’m sure that you’ll be well aware of its major drawback: It uses only .sfb files to load a model in AR.
No doubt that Sceneform provides a tool to convert models into files with .sfb extension, but that can only be done while developing the app.
If we think about it in depth, it’s a huge limitation of ARCore as we cannot select and load models at runtime.
But no worries, Google knows about this and has provided a solution for it. It has developed a library which accepts the path of a model hosted on a remote server and loads it in AR.
This also helps us to avoid bundling models with APK, resulting in a tremendous size reduction.
I’m sure that you’ve already started wondering about the possible use cases.
A small demo will provide a deeper way to visualize apps that are possible with this library. So, let’s dive in…!
Prerequisites
Note: Don’t forget to include all the related files for the model in the model’s directory such as .bin file and texture files, if any.
I’ll use a model of Santa Claus as in the image below.
Code
First things first, we’ll add the required dependency for the library.
Add the following code snippets in onCreate() method of the activity.
The above code generates a renderable from the model stored at a remote server. modelLink is a string which points the .gltf model.
The below code snippet is for listener which listens to the tap on the plan detected and ultimately adds a transformable node, built using the renderable on the plane.
That’s it…! Isn’t it a piece of cake?
Let’s run the code…
Liked the concept? Wanna experiment with it? Please feel free to play around with the code.
Use cases
A dynamic AR app with an API for 3D models can be imagined. The models can be managed from an admin panel without affecting app’s codebase.
Conclusion
For me, the main uses of this library are that the app size will be reduced and dynamic apps can be developed. Even though it only supports .gltf files currently, this feature can be handy in a lot of ways.
Find more top mobile app developers worldwide on AppFutura.