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

Viro3DSceneNavigator

Viro3DSceneNavigator is the entry point for applications that want to render a 3D Scene (<ViroScene>) in a non AR/VR fashion. Please see the Scene Navigation Guide for more information on how to properly navigate between scenes.

Example use:
var MyStartScene = require('./MyStartScene');

import {
  AppRegistry,
  ViroScene,
  Viro3DSceneNavigator,
} from 'react-viro';

var ViroSceneNav = React.createClass({
  render: function() {
    return (
      <Viro3DSceneNavigator
        initialScene={{
          scene: MyStartScene,
        }}
      />
    );
  }
})

Props

Required Props

PropKey
PropType

apiKey

PropTypes.string.isRequired


Required API Key

initialScene

PropTypes.shape( {scene: PropTypes.func.isRequired
} ),

The initial scene to display for your application on application start.

Optional Props

PropKey
PropType

bloomEnabled

PropTypes.bool

Enable or disable bloom. Bloom adds a soft glow to bright areas in scene, simulating the way bright highlights appear to the human eye. To make an object bloom, this property must be enabled, and the objects's threshold for bloom must be set via its material's bloomThreshold property.

debug

PropTypes.bool

Used to enable the Dev menu on Android Nougat devices with Cardboard.

hdrEnabled

PropTypes.bool

When HDR rendering is enabled, Viro uses a deeper color space and renders to a floating point texture, then applies a tone-mapping algorithm to preserve fine details in both bright and dark regions of the scene. If HDR is disabled, then features like Bloom and PBR will not work, and tone-mapping will be disabled.

HDR is not supported on all devices.

onExitViro

PropTypes.func

Called if the user presses the "X" button to exit.

pbrEnabled

PropTypes.bool

Enable or disable physically-based rendering. Physically based rendering, or PBR, produces more realistic lighting results for your scenes, and provides a more intuitive workflow for artists. To use PBR, this property must be enabled, and materials must use the physicallyBased lighting model. PBR is controlled by a variety of properties, see PBR guide for details.

shadowsEnabled

PropTypes.bool

Enable or disable rendering dynamic shadows. If shadows are disabled here, shadow casting lights will simply not cast a shadow.

viroAppProps

PropTypes.object

A Javascript object containing properties for this Viro app. This can be used to pass in properties from native if you're using a hybrid application.

Methods

The following functions are available on the Viro3DSceneNavigator component. You can get the handle to the Viro3DSceneNavigator in 2 ways:

  1. Use the built-in React Native ref property to grab a reference
  2. From your ViroScene. Each ViroScene added to a Viro3DSceneNavigator provides its parent navigator in the variable: this.props.sceneNavigator.
push(scene: ViroScene)

Push the given scene onto scene stack, displaying the scene to the user.

Parameters Description
scene Scene that will be pushed onto the stack and displayed to the user
pop()

Pop the top most scene of the stack, effectively going back to the previous scene.

pop(n: number)

Go back n scenes at once. If n is equal to 1 this is equivalent to calling pop().

jump(scene: ViroScene)

Move to the given scene in the stack, removing it from its current position in the stack and placing it on top, thereby displaying it to the user. If the scene is not already on the stack, this method pushes the scene to the top of the stack, displaying it to the user. This is best used in applications where the user jumps between a set of scenes frequently.

Parameters Description
scene Scene that will be moved or pushed to the top of the stack and displayed to the user
replace(scene: ViroScene)

Replace the currently displayed scene (the scene at the top of the stack) with the given scene, displaying it to the user. This leaves the remainder of the stack unchanged.

Parameters Description
scene Scene that will replace the scene at the top of stack and be displayed to the user
recenterTracking()

Reorients the virtual world such that directly forward of the user is [0, 0, -1] by rotating the scene by the user's y-rotation.

Viro3DSceneNavigator


Suggested Edits are limited on API Reference Pages

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