{"_id":"5a8356d8d3dc0f008636c6eb","category":{"_id":"5a8356d8d3dc0f008636c6d6","version":"5a8356d8d3dc0f008636c6d4","project":"5a065a6134873d0010b396ab","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-18T21:08:45.730Z","from_sync":false,"order":1,"slug":"develop","title":"Develop"},"project":"5a065a6134873d0010b396ab","user":"578c4a62bd223d2000cc143e","parentDoc":null,"version":{"_id":"5a8356d8d3dc0f008636c6d4","project":"5a065a6134873d0010b396ab","__v":1,"createdAt":"2018-02-13T21:21:28.228Z","releaseDate":"2018-02-13T21:21:28.228Z","categories":["5a8356d8d3dc0f008636c6d5","5a8356d8d3dc0f008636c6d6","5a8356d8d3dc0f008636c6d7","5a8356d8d3dc0f008636c6d8"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.3.0","version":"1.3.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-18T20:09:57.359Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b891975-viro_camera_diagram.png\",\n        \"viro_camera_diagram.png\",\n        607,\n        676,\n        \"#3cbbfb\"\n      ]\n    }\n  ]\n}\n[/block]\nScenes 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](https://developer.viromedia.com/virocore/reference/com/viro/core/Camera.html) object.\n\nMultiple 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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Node cameraNode = new Node();\\ncameraNode.setPosition(new Vector(0, 2, 0));\\ncameraNode.setRotation(new Vector((float)-Math.PI / 2.0f, 0, 0));\\n\\nCamera camera = new Camera();\\ncameraNode.setCamera(camera);\\n\\nview.setPointOfView(cameraNode);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nOn 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](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewGVR.html) and [ViroViewOVR](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewOVR.html) support 3DOF, and [ViroViewARCore](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewARCore.html) supports 6DOF.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Orbit Camera\"\n}\n[/block]\nCamera also has a [RotationType](https://developer.viromedia.com/virocore/reference/com/viro/core/Camera.RotationType.html) 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.\n\nThe 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.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Node cameraNode = new Node();\\n\\nCamera camera = new Camera();\\ncamera.setRotationType(Camera.RotationType.ORBIT);\\ncamera.setOrbitFocalPoint(new Vector(0, 0 -1));\\ncameraNode.setCamera(camera);\\n\\nNode boxNode = new Node();\\nboxNode.setPosition(new Vector(0, 0 -1));\\nBox box = new Box(1, 1, 1);\\nboxNode.setGeometry(box);\\n\\nscene.getRootNode().addChildNode(cameraNode);\\nscene.getRootNode().addChildNode(boxNode);\\nview.setPointOfView(cameraNode);\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nYou 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.","excerpt":"Setting the Point of View","slug":"camera","type":"basic","title":"Camera"}

Camera

Setting the Point of View

[block:image] { "images": [ { "image": [ "https://files.readme.io/b891975-viro_camera_diagram.png", "viro_camera_diagram.png", 607, 676, "#3cbbfb" ] } ] } [/block] 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](https://developer.viromedia.com/virocore/reference/com/viro/core/Camera.html) 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. [block:code] { "codes": [ { "code": "Node cameraNode = new Node();\ncameraNode.setPosition(new Vector(0, 2, 0));\ncameraNode.setRotation(new Vector((float)-Math.PI / 2.0f, 0, 0));\n\nCamera camera = new Camera();\ncameraNode.setCamera(camera);\n\nview.setPointOfView(cameraNode);", "language": "java" } ] } [/block] 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](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewGVR.html) and [ViroViewOVR](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewOVR.html) support 3DOF, and [ViroViewARCore](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewARCore.html) supports 6DOF. [block:api-header] { "type": "basic", "title": "Orbit Camera" } [/block] Camera also has a [RotationType](https://developer.viromedia.com/virocore/reference/com/viro/core/Camera.RotationType.html) 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. [block:code] { "codes": [ { "code": "Node cameraNode = new Node();\n\nCamera camera = new Camera();\ncamera.setRotationType(Camera.RotationType.ORBIT);\ncamera.setOrbitFocalPoint(new Vector(0, 0 -1));\ncameraNode.setCamera(camera);\n\nNode boxNode = new Node();\nboxNode.setPosition(new Vector(0, 0 -1));\nBox box = new Box(1, 1, 1);\nboxNode.setGeometry(box);\n\nscene.getRootNode().addChildNode(cameraNode);\nscene.getRootNode().addChildNode(boxNode);\nview.setPointOfView(cameraNode);", "language": "java" } ] } [/block] 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.