Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Interactive 3D models can be displayed in AR in a variety of ways. Using Scene Viewer with intents directly from your Android native app is one of those methods.
In this article, I will guide you through this app-based experience and different preview options.
Scene Viewer
Scene Viewer is an immersive viewer that lets users of your website or Android app experience 3D and augmented reality. It makes it simple for Android mobile device users to preview, position, view, and interact with 3D models that are hosted online.
Most Android browsers support Scene Viewer. Many Google partners have successfully deployed Scene Viewer to support 3D and AR experiences. These experiences are likewise supported by it Google Search.
The implementation process is simple:
All needed for web-based interactions are correctly formatted links on a web page.
Only a few lines of Java code must be included for app-based experiences.
Runtime Requirements
Users must have an to utilize Scene Viewer to experience AR.
A device running Android 7.0 Nougat (API Level 24) or later supports ARCore.
Google Play Services was most recently released for AR. On the great majority of ARCore-supported devices, this service is automatically installed and kept up to date.
The Google app is in its most recent iteration. This software is pre-installed and continuously updated on most ARCore-compatible devices.
You can give a fallback URL that opens an alternative experience, such as a web page, an error message, or a fallback experience that you have generated if Google Play Services for AR or the Google app isn't present or the installed versions are too old.
Common Use Cases and Challenges
When using Scene Viewer rather than developing your own native AR feature, there are several use scenarios to take into account:
Show off static 3D models of objects in space, like couches and chairs.
Display 3D models with basic animation, like in a zoo app that uses basic animation to show different species.
You should be aware of Scene Viewer's restricted capability and the following drawbacks:
It only allows for one animation per glTF file.
Intent parameters cannot be used to set the model transformation or scale.
It does not support every feature of the glTF format
Launch Scene Viewer Using an Explicit Intent (3D or AR)
Use an explicit Android intent to start Scene Viewer to support the greatest number of Android devices. A native Android app or an HTML page can start the explicit intent. The Google app that is pre-installed on Android devices that enable ARCore will handle the intent.
Interactive 3D models can be displayed in a 3D viewer or placed in the user's environment depending on the configured intent parameters and device capabilities.
Scene Viewer will display the model in either a 3D or AR native view if Google Play Services for AR is installed and current on the device.
Scene Viewer gently reverts to showing the model in a 3D view if Google Play Services for AR isn't available or isn't current.
The S.browser fallback URL argument is used to display a fallback web page if a 3D model cannot be displayed, for instance, if the Google app is not installed or is an outdated version.
Launch Scene Viewer from HTML or Java
Java
To trigger the explicit intent from Java, use the following code:
Intent sceneViewerIntent = new Intent(Intent.ACTION_VIEW);
sceneViewerIntent.setData(Uri.parse("https://arvr.google.com/scene-viewer/1.0?file=https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf"));
sceneViewerIntent.setPackage("com.google.android.googlequicksearchbox");
startActivity(sceneViewerIntent);
HTML
To trigger the explicit intent from HTML, use the following syntax:
The version number after arvr.google.com/scene-viewer indicates the intent version. For instance, version 1.0 was utilized in the initial release. You can launch Scene Viewer with a higher intended version corresponding to the newer capabilities you need as they are needed.
Support for intent:/ links, which can open an Android app instead of a URL, was added to Intent in version 1.1. Launch Scene Viewer with intent to intent:/arvr.google.com/scene-viewer/1.1 if you want to ensure that this capability is present when it is launched and fails to launch otherwise.
Supported Intent Parameters
The Google Search package supports the following arguments for explicit intent.
Intent Parameter
Allowed Values
Comments
file(required)
A valid URL.
The glTF or glb file that should be loaded into Scene Viewer is specified by this URL. It has to be URL-escaped.
S.browser_fallback_url (required for HTML-based intents)
A valid URL.
Google Chrome only supports web-based implementations of this capability. This is the URL that Google Chrome navigates to when the Google app is not available on the device.
mode (optional)
3d_preferred (default)
3d_only
ar_prefered
Ar_only
The model is shown in 3D mode with a button that says "View in your space" in Scene Viewer. The View in your space button is not visible if Google Play Services for AR is not installed on the device.
Even though Google Play Services for AR is installed on the device, Scene Viewer begins with the model displayed in 3D mode. The button for "View in your space" is never visible.
Scene Viewer's entrance mode launches in native AR mode. The View in your environment and View in 3D buttons allow the user to alternate between AR and 3D modes. Without Google Play Services for AR, Scene Viewer smoothly switches to 3D mode as the default entry mode.
When utilizing this value, you should launch to com.google.ar.core using an explicit Android intent. Avoid using ar only mode when launching a Google app with a specific Andro id purpose.
link(optional)
A valid URL
An external website's URL If it is, a button will emerge in the user interface that, when clicked, will take the user to this URL.
title(optional)
Valid String
A model's moniker. It will be shown in the UI if it is there. After 60 characters, the name will be abbreviated using ellipses.
sound(optional)
A valid URL
A glTF file containing a URL to a looping audio track is timed to the initial animation. It must be offered with a glTF with animation of the same length. After the model has loaded, the sound is looped if it is present. It has to be URL-escaped.
resizeable(optional),
true(default), or false
Users won't be able to scale the model in the AR experience if the setting is false. In the 3D environment, scaling functions as expected.
enable_vertical_placement (optional),
true(default), or false
Users can position the model on a vertical surface if the value is true.
Launch Scene Viewer Using an Explicit Intent to Google Play Services for AR (AR mode only)
Google Play Services for AR is used to power the AR functionality in Scene Viewer.
You can use an explicit Android intent from a website or native Android app to launch Scene Viewer via the com.google.ar.core package and supply a browser fallback URL to ensure that AR is supported in Scene Viewer. Using Scene Viewer, you can ensure that every user either has a native AR experience or a fallback experience you have created yourself. You may create a gracious error message or your 3D viewer as examples of fallback experiences.
Use the following syntax to cause HTML to express its explicit intent:
Use the following code to cause Java to express its explicit intent:
Intent sceneViewerIntent = new Intent(Intent.ACTION_VIEW);
Uri intentUri =
Uri.parse("https://arvr.google.com/scene-viewer/1.0").buildUpon()
.appendQueryParameter("file", "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Avocado/glTF/Avocado.gltf")
.appendQueryParameter("mode", "ar_only")
.build();
sceneViewerIntent.setData(intentUri);
sceneViewerIntent.setPackage("com.google.ar.core");
startActivity(sceneViewerIntent);
Supported Intent Parameters
The following parameters are supported for an explicit intent to the Google Play Services for AR package.
Intent parameters
Allowed Values
Comments
browser_fallback_url (required for HTML-based intents)
A valid URL
There is only support for web-based implementations of this. This is the URL navigated to when the device's Google Play Services for AR are unavailable or out-of-date.
mode (optional)
Ar_only
Ar_preferred
Scene Viewer never shows any UI for switching to the Scene Viewer 3D viewer; instead, it always launches the 3D model in a native AR view.
Scene Viewer launches the URL you provide in the browser fallback URL for web-based experiences if Google Play Services for AR is unavailable. Scene Viewer switches to an alternative experience, such as an error message or another experience you created yourself, for app-based experiences.
The View in your area and View in 3D buttons allow users to move between AR and 3D modes, while Scene Viewer first runs in native AR mode as the entrance mode.
Scene Viewer launches the URL you provide in the browser fallback URL for web-based experiences if Google Play Services for AR is unavailable. Scene Viewer switches to an alternative experience, such as an error message or another experience you created yourself, for app-based experiences.
link(optional)
A valid URL
A website's external link or URL. If it's there, a button that, when clicked, intents to this URL will appear in the user interface.
title(optional)
Valid string
A model's moniker. It will be shown in the UI if it is there. After 60 characters, the name will be abbreviated using ellipses.
sound (optional)
A valid URL
A link to an audio track loop in time with the opening animation in a glTF file. It must be offered with a glTF with animation of the same length. After the model has loaded, the sound is looped if it is present.
resizable (optional)
true (default)
false
Users won't be able to scale the model in the AR experience if the setting is false. In the 3D environment, they are scaling functions as expected.
disable_occlusion (optional)
false (default)
true
When set to true, added items display in front of the scene's existing real-world elements. For further details, see [Enable occlusion](/ar/develop/depth#enable occlusion).
UX Guidance
We advise adhering to these recommendations to give users the best UX possible.
The visible call to action for AR experiences should indicate to the user that they are about to enter an immersive environment. Use the View in your space call to action, which we advise you to do:
Users' devices might not already have Google Play Services for AR installed. You are welcome to start with the following line of code to implement the fallback in model-viewer>.
// Check whether this is an Android device.
const isAndroid = /android/i.test(navigator.userAgent);
// This fallback URL is used if the Google app is not installed and up to date.
const fallbackUrl = 'https://arvr.google.com/scene-viewer?file=https%3A%2F%2Fstorage.googleapis.com%2Far-answers-in-search-models%2Fstatic%2FTiger%2Fmodel.glb&link=https%3A%2F%2Fgoogle.com&title=Tiger';
// This intent URL triggers Scene Viewer on Android and falls back to
// fallbackUrl if the Google app is not installed and up to date.
const sceneViewerUrl = 'intent://arvr.google.com/scene-viewer/1.0?file=https://storage.googleapis.com/ar-answers-in-search-models/static/Tiger/model.glb&title=Tiger#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=' +
fallbackUrl + ';end;';
// Create a link.
var a = document.createElement('a');
a.appendChild(document.createTextNode('Tiger'));
// Set the href to the intent URL on Android and the fallback URL
// everywhere else.
a.href = isAndroid ? sceneViewerUrl : fallbackUrl;
// Add the link to the page.
document.body.appendChild(a);
Using <model-viewer> to Launch Scene Viewer
Integrating the model-viewer> web component with the ar property may make Scene Viewer accessible from your website.
<model-viewer ar
ar-modes="scene-viewer webxr quick-look"
alt=" A 3D model of an astronaut."
src="Astronaut.gltf"></model-viewer>
A webpage with the model-viewer> component with the ar property displays a button as seen in the example below when viewed on an Android device that supports ARCore.
The scene-viewer mode in AR modes invites the user to position the model in their environment using Scene Viewer and transitions to a native AR view.
In the absence of Google Play Services with AR, hitting this button causes the model to appear in the 3D viewer of the model-viewer> app.
File Requirements for Models
The following model limits and support are available in Scene Viewer.
File format support
glTF 2.0/glb, using these extensions:
KHR_materials_unlit
KHR_texture_transform
Animation
Looping skeletal animation
Looping rigid animation
Looping transform animation
The animation will be shown repeatedly. Scene Viewer only plays the first animation when a glTF file contains numerous animations.
Recommended limits
Setting restrictions and choosing between vertices, materials, texture resolution, mesh per material, and other aspects affect an asset's overall performance. Utilize the following recommendations to maximize your resources
A number of triangles: The recommended limit is 100,000 triangles, but targeting the lowest number will maintain high performance in Scene Viewer. 30,000 to 50,000 is an ideal range.
Number of materials: The recommended limit is 10 materials, two of which can be alpha. Target the lowest number possible to keep the asset performing well.
Mesh per material: 1
Maximum texture resolution: 2048 × 2048
Bone (including non-weighted joints): 254 (hard limit)
Bone weights per vertex limit: 4 (hard limit)
UV: 1 UV per mesh (hard limit)
Model size: 10 MB (Bigger models may result in poor user experience.
Shadow support
We advise against baking shadows into your model because hard shadows are immediately drawn by Scene Viewer when an object is placed.
Texture support
PNG format: PNG-24, indexed PNG-8.
JPGs are preferred when there is no transparency because they reduce size.
Color space: sRGB
Material
PBR
File loading
HTTPS
Scene
Axis: right-handed, with these properties:
+X is right
+Y is up
-Z points forward from the origin (in other words, the "front" of an asset should be facing +Z)
Scale: 1 unit = 1 meter (as defined by the glTF specification to ensure the model is placed in AR in true scale
Use our online previewer tool to confirm the files on your PC will display correctly in Scene Viewer before importing your 3D model file.
Validating Your 3D Model
The previewer program requires one glb or glTF file, any related picture and bin files, and an optional audio file to validate a model. Both the audio file and animation 0 will loop.
You can pick many files at once and zip up the glb or glTF along with any related files. (Audio files cannot be used with the zip file approach.)
How to verify your 3D model
Launch a browser and access the online previewer tool.
To add the files to the previewer tool, choose one of the following methods:
Drag and drop: Drag the chosen files or zip file to the previewer tool after choosing a glb or glTF file and all related files (or a zip file containing these files).
From the previewer tool: Select Scene Viewer > Load File in the previewer tool. Click Open after choosing a glb or glTF file and all of its related files (or a zip file containing these files).
The findings, including any error notices, are displayed in a console at the bottom of the browser once you load the files that make up your 3D model into the previewer tool.
Adding 3D Models for Validation
Add the files that make up a 3D model to our Model Editor tool to evaluate it. The previewer requires the model's glb or glTF file, any related picture and bin files, and an optional audio file to validate the model. You can add a single zip file or select many individual files simultaneously. The previewer loads the first glb or glTF it finds when adding a zip file, along with any accompanying image and bin files.
Launch the Model Editor browser extension.
To add the files to the previewer tool, choose one of the following methods:
Drag & drop files to the previewer tool by multi-selecting the glb or glTF file and any related files (or choosing a zip file containing these items).
I am choosing files with the previewer tool. Select Scene Viewer > Load File in the previewer tool. Click Open after selecting multiple items from the glb or glTF file's accompanying files (or a zip file containing these files).
Frequently Asked Questions
Does ARCore use OpenGL?
You can launch the hello ar kotlin or hello ar java sample apps provided with the ARCore SDK to start using ARCore with Android. These sample apps use the programming interface OpenGL, which can produce 2D and 3D vector graphics.
Is ARCore open source?
In 2018, Google released ARCore, the best open-source augmented reality SDK (Apache license). It will contribute to the wonderful AR experiences available for Android devices. Three key capabilities of ARCore include motion tracking, light estimation, and ambient comprehension.
How does ARCore compatibility work?
The following requirements must be satisfied for the Android devices on this list to support ARCore via Google Play Services for AR, which enables augmented reality (AR) experiences created with an ARCore SDK: The Google Play Store was first included with the device.
Which is preferred for a 3D model in AR?
Developers may edit and build 3D models in various formats using the tools provided by Maya, and they can also use these tools to animate these models. The production of huge studios is better suited to Maya.
When did ARCore get its start?
A Google software development kit called ARCore was introduced in 2018. Developers can construct augmented reality apps using Google ARCore, often called "Google Play Services for AR."
Conclusion
In this article, we learned about ARCore intent, its different parameters, different requirements, and its use cases. That’s all from the article. I hope you all like it.
Check out our articles on Passion for AR & VR leads to Snake Snack Game to learn more.