The Viro Developer Hub

Welcome to the Viro developer hub. You'll find comprehensive guides and sample code to help you start working with Viro as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

Portals are an AR effect where a 'window' or 'door' is displayed that users can use to peer into a virtual world, as shown below.

PortalScene is the root of the subgraph of Nodes that is displayed through a Portal. Each PortalScene can contain any number of child nodes and content, and each PortalScene can have its own background texture. If a PortalScene is set to passable, users are able to walk through the Portal into the PortalScene.

The following example shows how to create a simple Portal that transports you from your current location to a beach-like resort.

// Add a Light so the ship door portal entrance will be visible
OmniLight light = new OmniLight();
light.setColor(Color.WHITE);
light.setPosition(new Vector(0, 1, -4 ));
scene.getRootNode().addLight(light);

// Load a model representing the ship door
Object3D shipDoorModel = new Object3D();
shipDoorModel.loadModel(Uri.parse("file:///android_asset/portal_ship.vrx"), Object3D.Type.FBX, null);

// Create a Portal out of the ship door
Portal portal = new Portal();
portal.addChildNode(shipDoorModel);
portal.setScale(new Vector(0.5, 0.5, 0.5));

// Create a PortalScene that uses the Portal as an entrance.
PortalScene portalScene = new PortalScene();
portalScene.setPosition(new Vector(0, 0, -5));
portalScene.setPortalEntrance(portal);

// Add a 'beach' background for the Portal scene
final Bitmap beachBackground = getBitmapFromAssets("beach.jpg");
final Texture beachTexture = new Texture(beachBackground, Texture.Format.RGBA8, true, false);
portalScene.setBackgroundTexture(beachTexture);

scene.getRootNode().addChildNode(portalScene);

To try this example, you can download the beach 360 photo and portal ship door assets here. Unzip these and store in your applications assets folder. The resulting scene is shown below.

Portals


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.