GuidesReferenceIssuesSupportGet API Key


Setting the Point of View

Scenes in Viro are full 3D environments that can be viewed from any angle. By default, the scene is viewed from the origin [0, 0, 0], pointing in the negative Z direction [0, 0, -1]. To change this, you can make use of the Camera object.

Multiple Cameras can be created, and each can be attached to the scene graph directly to Node via Node.setCamera(Camera). To make a Camera active, you set its Node as the point of view with `ViroView.setPointOfView(Node). In the example below, we create a Camera and position it at [0, 2, 0], and rotate it to look down.

Node cameraNode = new Node();
cameraNode.setPosition(new Vector(0, 2, 0));
cameraNode.setRotation(new Vector((float)-Math.PI / 2.0f, 0, 0));

Camera camera = new Camera();


On AR and VR platforms, the camera is also controlled by the user. In platforms with 3DOF (3 degrees of freedom), the user controls the rotation of the camera directly through the headset. In platforms with 6DOF platform (6 degrees of freedom), the user controls both the rotation and position of the camera ViroViewGVR and ViroViewOVR support 3DOF, and ViroViewARCore supports 6DOF.

Orbit Camera

Camera also has a RotationType property, which can be used to create an Orbit camera. The Orbit Camera is an alternative camera that enables the user to orbit about a focal point. This is useful for exploring a single point in a 3D scene from all angles: as the user tilts her head, the camera orbits about that single point.

The example below utilizes an orbit camera. The focalPoint is set to [0, 0, -1]. Since the Box in the scene below is also positioned at [0, 0, -1], this means the user will stay focused on that 3D model as he tilts his head, revealing it from all angles.

Node cameraNode = new Node();

Camera camera = new Camera();
camera.setOrbitFocalPoint(new Vector(0, 0 -1));

Node boxNode = new Node();
boxNode.setPosition(new Vector(0, 0 -1));
Box box = new Box(1, 1, 1);


You can also define a cameras within <ViroNode> objects. By doing so, you 'attach' the camera to the node: it is transformed within the node like any other element in the scene graph.