{"_id":"5b36797811baf70003a153a1","category":{"_id":"5b36797811baf70003a15361","version":"5b36797811baf70003a153e5","project":"578c4badbd223d2000cc1441","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-08-01T23:04:12.838Z","from_sync":false,"order":8,"slug":"api-reference","title":"API Reference"},"project":"578c4badbd223d2000cc1441","user":"576c22a3808cf02b00d37419","parentDoc":null,"version":{"_id":"5b36797811baf70003a153e5","project":"578c4badbd223d2000cc1441","__v":0,"forked_from":"5b17376c3b44af00030764f0","createdAt":"2018-04-23T20:03:35.726Z","releaseDate":"2018-04-23T20:03:35.726Z","categories":["5b36797811baf70003a1535c","5b36797811baf70003a1535d","5b36797811baf70003a1535e","5b36797811baf70003a1535f","5b36797811baf70003a15360","5b36797811baf70003a15361","5b36797811baf70003a15362","5b36797811baf70003a15363","5b36797811baf70003a15364"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.8.1","version":"2.8.1"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-09-16T17:39:19.099Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"`ViroARSceneNavigator` is the entry point for AR applications with Viro. For more information about developing in AR, see our Develop page for [Augmented Reality (AR)](doc:augmented-reality-ar).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Props\"\n}\n[/block]\n##Required Props\n[block:parameters]\n{\n  \"data\": {\n    \"h-1\": \"PropType\",\n    \"h-0\": \"PropKey\",\n    \"0-0\": \"**apiKey**\",\n    \"0-1\": \"**PropTypes.string.isRequired
**
\\n\\nRequired API Key\",\n    \"2-0\": \"**initialScene**\",\n    \"2-1\": \"**PropTypes.shape( {scene: PropTypes.func.isRequired
} ),**
\\n\\nThe initial AR scene to display for your application on application start.\\n\\nNote: ViroARSceneNavigator only accepts [ViroARScene](doc:viroarscene)\",\n    \"4-0\": \"**worldAlignment**\",\n    \"4-1\": \"*iOS only - has no effect on Android/ARCore*\\n\\n**PropTypes.oneOf([\\\"Gravity\\\", \\\"GravityAndHeading\\\", \\\"Camera\\\"])**\\n\\nThis property determines the initial orientation/alignment of the world's coordinate system.\\n\\nGravity - origin is the device's starting location and the X-Z plane is perpendicular to gravity.\\nGravityAndHeading - origin is the device's starting location and the X and Z axes are latitudinally and longitudinally aligned.\\nCamera - coordinate system is locked to the camera's current orientation.\",\n    \"1-0\": \"**autofocus**\",\n    \"1-1\": \"**iOS 11.3+/ARKit 1.5+ only**\\n\\n**PropTypes.bool**\\n\\nWhether or not to enable autofocus for this AR session.\\n\\nDefault value is true.\",\n    \"3-0\": \"**videoQuality**\",\n    \"3-1\": \"**iOS 11.3+/ARKit 1.5+ only**\\n\\n**PropTypes.oneOf([\\\"High\\\", \\\"Low\\\"])**\\n\\nSets the video quality either to the highest or lowest possible if the device supports more than 1 applicable video quality.\\n\\nDefault value is \\\"High\\\".\"\n  },\n  \"cols\": 2,\n  \"rows\": 5\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Methods\"\n}\n[/block]\nThe following functions are available on the `ViroARSceneNavigator` component. You can get the handle to the `ViroARSceneNavigator` in 2 ways:\n\n1. Use the built-in React Native `ref` property to grab a reference\n2. From your `ViroScene`. Each `ViroScene` added to a `ViroARSceneNavigator` provides its parent navigator in the variable: `this.props.sceneNavigator`.\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Push the given scene onto scene stack, displaying the scene to the user.\\n\\n|Parameters    | Description |        \\n| ------------- |:------------- |\\n|scene    | Scene that will be pushed onto the stack and displayed to the user |\",\n    \"h-0\": \"push(scene: ViroARScene)\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"pop()\",\n    \"0-0\": \"Pop the top most scene of the stack, effectively going back to the previous scene.\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"pop(n: number)\",\n    \"0-0\": \"Go back n scenes at once. If n is equal to 1 this is equivalent to calling pop().\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"jump(scene: ViroARScene)\",\n    \"0-0\": \"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.\\n\\n|Parameters    | Description |        \\n| ------------- |:------------- |\\n|scene    | Scene that will be moved or pushed to the top of the stack and displayed to the user |\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"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.\\n\\n|Parameters    | Description |        \\n| ------------- |:------------- |\\n|scene    | Scene that will replace the scene at the top of stack and be displayed to the user |\",\n    \"h-0\": \"replace(scene: ViroARScene)\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"resetARSession(resetTracking: boolean, removeAnchors:boolean)\",\n    \"0-0\": \"**iOS Only**\\n\\nCall this function to reset the ARSession with a combination of the two flags:\\n\\nresetTracking - if true, the scene will realign with the camera's position and orientation.\\nremoveAnchors - if true, the anchors will all be removed (`onAnchorRemoved` will be called on the [ViroARScene](doc:viroarscene)). It's recommended to also set `removeAnchor` to true if `resetTracking` is also set to true.\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"setWorldOrigin(offset:[x, y, z])\",\n    \"0-0\": \"**iOS 11.3+/ARKit 1.5+ Only!**\\n\\nThis function accepts a given translation offset to be apply to the current world origin. Multiple calls to this function are additive, translating the worldOrigin by the given translations.\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"startVideoRecording(fileName: string, saveToCameraRoll: bool, onError: func)\",\n    \"0-0\": \"Starts a recording of the ViroARSceneNavigator capturing only Viro-rendered components and external audio (microphone and camera permissions required).\\n\\n|Parameters    | Description |        \\n| ------------- |:------------- |\\n|fileName    | name of the file saved to app's temporary files. If the name matches an existing file at the location, it will be overridden. A file extension will automatically be added. |\\n|saveToCameraRoll | Whether or not the file should also be saved to the user's Photos at the end of recording. (Requires photo/video saving permissions) |\\n|onError | a function invoked w/ an errorCode if recording encounters an issue. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"async stopVideoRecording()\",\n    \"0-0\": \"[Async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function called to stop video recording.\\n\\n| Return Values | Description |\\n| ------------- |:------------- |\\n| success |  true/false if stopping was successful|\\n| url | path to the file in the application's temporary files. |\\n|errorCode | a number representing an error while stopping recording. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"async takeScreenshot(fileName: string, saveToCameraRoll: bool)\",\n    \"0-0\": \"[Async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function called to take a screenshot of the ViroARSceneNavigator capturing only Viro-rendered components.\\n\\n|Parameters    | Description |        \\n| ------------- |:------------- |\\n|fileName    | name of the file saved to app's temporary files. If the name matches an existing file at the location, it will be overridden. A file extension will automatically be added. |\\n|saveToCameraRoll | Whether or not the file should also be saved to the user's Photos at the end of recording. (Requires photo/video saving permissions) |\\n\\n| Return Values | Description |\\n| ------------- |:------------- |\\n| success |  true/false if stopping was successful|\\n| url | path to the file in the application's temporary files. |\\n|errorCode | a number representing an error while taking/saving the screenshot. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|\"\n  },\n  \"cols\": 1,\n  \"rows\": 1\n}\n[/block]","excerpt":"","slug":"viroarscenenavigator","type":"basic","title":"ViroARSceneNavigator"}

ViroARSceneNavigator


`ViroARSceneNavigator` is the entry point for AR applications with Viro. For more information about developing in AR, see our Develop page for [Augmented Reality (AR)](doc:augmented-reality-ar). [block:api-header] { "type": "basic", "title": "Props" } [/block] ##Required Props [block:parameters] { "data": { "h-1": "PropType", "h-0": "PropKey", "0-0": "**apiKey**", "0-1": "**PropTypes.string.isRequired
**
\n\nRequired API Key", "2-0": "**initialScene**", "2-1": "**PropTypes.shape( {scene: PropTypes.func.isRequired
} ),**
\n\nThe initial AR scene to display for your application on application start.\n\nNote: ViroARSceneNavigator only accepts [ViroARScene](doc:viroarscene)", "4-0": "**worldAlignment**", "4-1": "*iOS only - has no effect on Android/ARCore*\n\n**PropTypes.oneOf([\"Gravity\", \"GravityAndHeading\", \"Camera\"])**\n\nThis property determines the initial orientation/alignment of the world's coordinate system.\n\nGravity - origin is the device's starting location and the X-Z plane is perpendicular to gravity.\nGravityAndHeading - origin is the device's starting location and the X and Z axes are latitudinally and longitudinally aligned.\nCamera - coordinate system is locked to the camera's current orientation.", "1-0": "**autofocus**", "1-1": "**iOS 11.3+/ARKit 1.5+ only**\n\n**PropTypes.bool**\n\nWhether or not to enable autofocus for this AR session.\n\nDefault value is true.", "3-0": "**videoQuality**", "3-1": "**iOS 11.3+/ARKit 1.5+ only**\n\n**PropTypes.oneOf([\"High\", \"Low\"])**\n\nSets the video quality either to the highest or lowest possible if the device supports more than 1 applicable video quality.\n\nDefault value is \"High\"." }, "cols": 2, "rows": 5 } [/block] [block:api-header] { "type": "basic", "title": "Methods" } [/block] The following functions are available on the `ViroARSceneNavigator` component. You can get the handle to the `ViroARSceneNavigator` 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 `ViroARSceneNavigator` provides its parent navigator in the variable: `this.props.sceneNavigator`. [block:parameters] { "data": { "0-0": "Push the given scene onto scene stack, displaying the scene to the user.\n\n|Parameters | Description | \n| ------------- |:------------- |\n|scene | Scene that will be pushed onto the stack and displayed to the user |", "h-0": "push(scene: ViroARScene)" }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "pop()", "0-0": "Pop the top most scene of the stack, effectively going back to the previous scene." }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "pop(n: number)", "0-0": "Go back n scenes at once. If n is equal to 1 this is equivalent to calling pop()." }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "jump(scene: ViroARScene)", "0-0": "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.\n\n|Parameters | Description | \n| ------------- |:------------- |\n|scene | Scene that will be moved or pushed to the top of the stack and displayed to the user |" }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "0-0": "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.\n\n|Parameters | Description | \n| ------------- |:------------- |\n|scene | Scene that will replace the scene at the top of stack and be displayed to the user |", "h-0": "replace(scene: ViroARScene)" }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "resetARSession(resetTracking: boolean, removeAnchors:boolean)", "0-0": "**iOS Only**\n\nCall this function to reset the ARSession with a combination of the two flags:\n\nresetTracking - if true, the scene will realign with the camera's position and orientation.\nremoveAnchors - if true, the anchors will all be removed (`onAnchorRemoved` will be called on the [ViroARScene](doc:viroarscene)). It's recommended to also set `removeAnchor` to true if `resetTracking` is also set to true." }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "setWorldOrigin(offset:[x, y, z])", "0-0": "**iOS 11.3+/ARKit 1.5+ Only!**\n\nThis function accepts a given translation offset to be apply to the current world origin. Multiple calls to this function are additive, translating the worldOrigin by the given translations." }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "startVideoRecording(fileName: string, saveToCameraRoll: bool, onError: func)", "0-0": "Starts a recording of the ViroARSceneNavigator capturing only Viro-rendered components and external audio (microphone and camera permissions required).\n\n|Parameters | Description | \n| ------------- |:------------- |\n|fileName | name of the file saved to app's temporary files. If the name matches an existing file at the location, it will be overridden. A file extension will automatically be added. |\n|saveToCameraRoll | Whether or not the file should also be saved to the user's Photos at the end of recording. (Requires photo/video saving permissions) |\n|onError | a function invoked w/ an errorCode if recording encounters an issue. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|" }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "async stopVideoRecording()", "0-0": "[Async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function called to stop video recording.\n\n| Return Values | Description |\n| ------------- |:------------- |\n| success | true/false if stopping was successful|\n| url | path to the file in the application's temporary files. |\n|errorCode | a number representing an error while stopping recording. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|" }, "cols": 1, "rows": 1 } [/block] [block:parameters] { "data": { "h-0": "async takeScreenshot(fileName: string, saveToCameraRoll: bool)", "0-0": "[Async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function called to take a screenshot of the ViroARSceneNavigator capturing only Viro-rendered components.\n\n|Parameters | Description | \n| ------------- |:------------- |\n|fileName | name of the file saved to app's temporary files. If the name matches an existing file at the location, it will be overridden. A file extension will automatically be added. |\n|saveToCameraRoll | Whether or not the file should also be saved to the user's Photos at the end of recording. (Requires photo/video saving permissions) |\n\n| Return Values | Description |\n| ------------- |:------------- |\n| success | true/false if stopping was successful|\n| url | path to the file in the application's temporary files. |\n|errorCode | a number representing an error while taking/saving the screenshot. Possible error codes [here](doc:viroconstants#section-video-recording-screenshot-errors).|" }, "cols": 1, "rows": 1 } [/block]