ViroController

UI Control through which the user interacts with the 3D world, enabled by default. In daydream, this would represent the daydream controller and it's laser pointer. In cardboard ios, cardboard Android and GearVR, the controller is effectively the reticle.

The ViroController is also notified of all events that occur within the scene, with the exception of hover. Thus, include this controller in your scene if you would like to register to be always notified of such events. You can also toggle certain UI expects of the controller as well, such as reticle or daydream visibility.

Example use:
<ViroController
    reticleVisibility={true}
    controllerVisibility={true}
    onClick={this._onClickListenerForAllEvents}
/>

Props

controllerVisibility

TypeDescription
booleanFlag for displaying the daydream controller. True by default. Note: this only applies to Daydream headsets.

onClick

See ViroNode onClick.

onClickState

See ViroNode onClickState.

onControllerStatus

TypeDescription
(status) => voidCalled when the status of the controller has changed. This is only triggered for wireless controllers, else the return value would always be "Connected".

Unknown (1): The controller state is being initialized and is not yet known.

Connecting (2): The controller is currently scanning and attempting to connect to your device or phone.

Connected (3): The controller is connected to your device.

Disconnected (4): The controller has disconnected from your device.

Error (5): The controller has encountered an internal error and is currently unusable. This is usually triggered upon initialization.

onDrag

See ViroNode onDrag.

onFuse

See ViroNode onFuse.

onHover

See ViroNode onHover.

onPinch

See ViroNode onPinch.

onRotate

See ViroNode onRotate.

onScroll

See ViroNode onScroll.

onSwipe

See ViroNode onSwipe.

onTouch

See ViroNode onTouch.

reticleVisibility

TypeDescription
booleanFlag for displaying the reticle. True by default.

Methods

setNativeProps(nativeProps)

A wrapper function around the native component's setNativeProps which allow users to set values on the native component without changing state/setting props and re-rendering. Refer to the React Native documentation on Direct Manipulation for more information.

ParameterTypeDescription
nativePropsobjectan object where the keys are the properties to set and the values are the values to set
componentRef.setNativeProps({ position: [0, 0, -1] });

getControllerForwardAsync()

An async function used to retrieve the forward vector of the current controller used to interact with the 3D scene.For example, grabbing the async could look like this:

this.controllerRef.getControllerForwardAsync().then((forward)=>{
// Do stuff with forward vector array
});