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:
import React from 'react';
import { Viro3DSceneNavigator } from '@viro-community/react-viro';
import MyScene from './MyScene';

function ViroSceneNav() {
  return (
	<Viro3DSceneNavigator
		initialScene={{ scene: MyStartScene }}
	/>
  );
}

Props

initialScene (* required)

TypeDescription
{ scene: React.Component }The initial scene to display for your application on application start.

bloomEnabled

TypeDescription
booleanEnable 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

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

hdrEnabled

TypeDescription
booleanWhen 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

TypeDescription
FunctionCalled if the user presses the "X" button to exit.

pbrEnabled

TypeDescription
booleanEnable 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 for details.

shadowsEnabled

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

viroAppProps

TypeDescription
ObjectA 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: ViroARScene, passProps: Object })

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

ArgumentTypeDescription
sceneViroSceneScene that will be pushed onto the stack and displayed to the user
passPropsObjectProps to pass to the rendered scene

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: ViroARScene, passProps: Object })

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.

ArgumentTypeDescription
sceneViroSceneScene that will be moved or pushed to the top of the stack and displayed to the user
passPropsObjectProps to pass to the rendered scene

replace({ scene: ViroARScene, passProps: Object })

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.

ArgumentTypeDescription
sceneViroSceneScene that will replace the scene at the top of stack and be displayed to the user
passPropsObjectProps to pass to the rendered scene

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.