{"__v":0,"_id":"58f7a4c8cbd001190056cc14","category":{"version":"58f7a4c8cbd001190056cbf8","project":"578c4badbd223d2000cc1441","_id":"58f7a4c8cbd001190056cbfe","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-08-01T23:04:12.838Z","from_sync":false,"order":5,"slug":"api-reference","title":"API Reference"},"parentDoc":null,"project":"578c4badbd223d2000cc1441","user":"57bb7defafc18c0e00529cf1","version":{"__v":1,"_id":"58f7a4c8cbd001190056cbf8","project":"578c4badbd223d2000cc1441","createdAt":"2017-04-19T17:56:24.172Z","releaseDate":"2017-04-19T17:56:24.172Z","categories":["58f7a4c8cbd001190056cbf9","58f7a4c8cbd001190056cbfa","58f7a4c8cbd001190056cbfb","58f7a4c8cbd001190056cbfc","58f7a4c8cbd001190056cbfd","58f7a4c8cbd001190056cbfe"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-18T04:07:31.656Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":12,"body":"A component used to display 2D images.\n\n######Example use:\n```\n<ViroImage\n    height={2}\n    width={2}\n    placeholderSource={require(\"./res/local_spinner.jpg\")}\n    source={{uri:\"https://my_s3_image.jpg\"}}\n />\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Props\"\n}\n[/block]\n##Required Props\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**source**\",\n    \"0-1\": \"**PropTypes.oneOfType( [PropTypes.shape( {uri:  PropTypes.string} ), PropTypes.number] )**\\n\\nThe image source, a remote URL or a local file resource. PNG and JPG images accepted.\\n\\nTo invoke with remote url: \\n```\\n{uri:\\\"http://example.org/myimage.png\\\"}\\n```\\nTo invoke with local source:\\n```\\nrequire('./image.png');\\n```\"\n  },\n  \"cols\": 2,\n  \"rows\": 1\n}\n[/block]\n##Optional Props\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"**format**\",\n    \"2-0\": \"**materials**\",\n    \"8-0\": \"**onHover**\",\n    \"17-0\": \"**position**\",\n    \"18-0\": \"**rotation**\",\n    \"19-0\": \"**scale**\",\n    \"22-0\": \"**transformBehaviors**\",\n    \"23-0\": \"**visible**\",\n    \"h-0\": \"PropKey\",\n    \"h-1\": \"PropType\",\n    \"0-1\": \"**PropTypes.oneOf(['RGBA8', 'RGBA4', 'RGB565'])**\\n\\nImage texture formats for storage on the GPU.\\n\\n|Format|Description|\\n|:------|:----------:|\\n|RGBA8| Each pixel is described with 32-bits, using eight bits per channel|\\n|RGBA4|  Each pixel is described with 16 bits, using four bits per channel|\\n|RGB565|  Formats the picture into 16 bit color values without alpha|\",\n    \"2-1\": \"**PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string),PropTypes.string])**\\n\\nAn array of strings that each represent a material that was created via ViroMaterials.createMaterials(). \\n\\nViroImage takes 1 material. The diffuseTexture of the material will be the image shown unless a source prop is specified. The other material properties will preserve as the source prop changes.\",\n    \"8-1\": \"**React.PropTypes.func**\\n\\nCalled when the user hovers on or off the control.\\n\\nFor example:\\n```  \\n_onHover(isHovering, source)  {\\n    if(isHovering) {\\n        // user is hovering over the box\\n    } else {\\n        // user is no longer hovering over the box\\n    }\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\",\n    \"17-1\": \"**PropTypes.arrayOf(PropTypes.number)**\\n\\nCartesian position in 3D space, stored as [x, y, z].\",\n    \"18-1\": \"**PropTypes.arrayOf(PropTypes.number)**\\n\\nThe rotation of the transform in world space stored as Euler angles [x, y, z]. Units for each angle are specified in degrees.\",\n    \"19-1\": \"**PropTypes.arrayOf(PropTypes.number)**\\n\\nThe scale of the image in 3D space, specified as [x,y,z]. A scale of 1 represents the current size of the image. A scale value of < 1 will make the image proportionally smaller while a value >1 will make the image proportionally bigger along the specified axis.\",\n    \"22-1\": \"**PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string),PropTypes.string])**\\n\\nAn array of transform constraints that affect the transform of the image. For example, putting the value \\\"billboard\\\" will ensure the image is facing the user as the user rotates their head on any axis. This is useful for having the image always face the user on a particular axis, which especially useful for tappable icons.\\n\\nAllowed values(values are case sensitive):\\n\\n|Value|Description|\\n|:------|:----------:|\\n|billboard| Billboard object on x,y,z axis |\\n|billboardX| Billboard object on the x axis|\\n|billboardY| Billboard object on the y axis|\",\n    \"23-1\": \"**PropTypes.bool**\\n\\nFalse if the image should be hidden. By default the button is visible and this value is true.\",\n    \"10-0\": \"**onLoadStart**\",\n    \"10-1\": \"**React.PropTypes.func**\\n\\nCallback triggered when we are processing the image to be displayed as specified by the source prop.\",\n    \"11-1\": \"**React.PropTypes.func**\\n\\nCallback triggered when we have finished loading the image to be displayed. Whether or not the image was loaded and displayed properly will be indicated by the parameter \\\"success\\\".\\n For example:\\n  \\n      _onLoadEnd(event:Event) {\\n      // Indication of asset loading success\\n        if(event.nativeEvent.success) {\\n           //our image successfully loaded!\\n        }\\n      }\",\n    \"11-0\": \"**onLoadEnd**\",\n    \"16-0\": \"**placeholderSource**\",\n    \"16-1\": \"**PropTypes.oneOfType([ PropTypes.shape({ uri: PropTypes.string }), PropTypes.number ])**\\n\\nA static placeholder image that is shown until the source image is loaded it. It not specified, nothing will show until the source image is finished loading. PNG and JPG images accepted.\\n\\nExample:\\n\\nTo invoke with local source:\\n```\\nrequire('./image_placeholder.png');\\n```\",\n    \"21-0\": \"**style**\",\n    \"21-1\": \"**stylePropType**\\n\\nRefers to a style property that is only used if within a ViroFlexView. Style properties determine the position and scale of the view within a ViroFlexView. Please see our guide on styles for my information.\",\n    \"24-0\": \"**width**\",\n    \"24-1\": \"**PropTypes.number**\\n\\nThe width of the image in 3D space. Default value is 1.\",\n    \"1-0\": \"**height**\",\n    \"1-1\": \"**PropTypes.number**\\n\\nThe height of the image in 3D space. Default value is 1.\",\n    \"3-0\": \"**mipmap**\",\n    \"3-1\": \"**PropTypes.bool**\\n\\nIf true, we dynamically generate mipmaps for the source of this given image.\",\n    \"4-0\": \"**onClick**\",\n    \"4-1\": \"**React.PropTypes.func**\\n\\nCalled when an objeect has been clicked.\\n\\nExample code:\\n```  \\n_onClick(source)  {\\n    // user has clicked the object\\n}\\n```\",\n    \"5-0\": \"**onClickState**\",\n    \"6-0\": \"**onDrag**\",\n    \"5-1\": \"**React.PropTypes.func**\\n\\nCalled for each click state an object goes through as it is clicked. Supported click states and their values are the following:\\n\\n|State Value|Description|\\n|:------|:----------:|\\n|1| Click Down: Triggered when the user has performed a click down action while hovering on this control.|\\n|2| Click Up: Triggered when the user has performed a click up action while hovering on this control.|\\n|3| Clicked: Triggered when the user has performed both a click down and click up action on this control sequentially, thereby having \\\"Clicked\\\" the object.|\\n\\nExample code:\\n```  \\n_onClickState(stateValue, source)  {\\n    if(stateValue == 1) {\\n        // Click Down\\n    } else if(stateValue == 2) {\\n        // Click Up\\n    } else if(stateValue == 3) { \\n        // Clicked\\n    }\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\",\n    \"6-1\": \"**React.PropTypes.func**\\n\\nCalled when the view is currently being dragged. The dragToPos parameter provides the current 3D location of the dragged object. \\n\\nExample code:\\n```  \\n_onDrag(dragToPos, source)  {\\n    // dragtoPos[0]: x position\\n    // dragtoPos[1]: y position\\n    // dragtoPos[2]: z position\\n}\\n``` \\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section. \\n\\nUnsupported VR Platforms: Cardboard iOS\",\n    \"12-0\": \"**onScroll**\",\n    \"13-0\": \"**onSwipe**\",\n    \"14-0\": \"**onTouch**\",\n    \"12-1\": \"**React.PropTypes.func**\\n\\nCalled when the user performs a scroll action, while hovering on the control.\\n\\nFor example:\\n```  \\n_onScroll(scrollPos, source)  {\\n    // scrollPos[0]: x scroll position from 0.0 to 1.0. \\n    // scrollPos[1]: y scroll position from 0.0 to 1.0.\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\\n\\nUnsupported VR Platforms: Cardboard(Android and iOS)\",\n    \"13-1\": \"**React.PropTypes.func**\\n\\nCalled when the user performs a swipe gesture on the physical controller, while hovering on this control. \\n\\nFor example:\\n```  \\n_onSwipe(state, source)  {\\n    if(state == 1) {\\n        // Swiped up\\n    } else if(state == 2) {\\n        // Swiped down\\n    } else if(state == 3) { \\n       // Swiped left\\n    } else if(state == 4) { \\n       // Swiped right\\n    }\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\\n\\nUnsupported VR Platforms: Cardboard(Android and iOS)\",\n    \"14-1\": \"**React.PropTypes.func**\\n\\nCalled when the user performs a touch action, while hovering on the control. Provides the touch state type, and the x/y coordinate at which this touch event has occurred.\\n\\n|State Value|Description|\\n|:------|:----------:|\\n|1| Touch Down: Triggered when the user  makes physical contact with the touch pad on the controller. |\\n|2| Touch Down Move: Called when the user moves around the touch pad immediately after having performed a Touch Down action. |\\n|3| Touch Up: Triggered after the user is no longer in physical contact with the touch pad after a Touch Down action. |\\n\\nFor example:\\n```  \\n_onTouch(state, touchPos, source)  {\\n   var touchX = touchPos[0];\\n   var touchY = touchPos[1];\\n    if(state == 1) {\\n        // Touch Down\\n    } else if(state == 2) {\\n        // Touch Down Move\\n    } else if(state == 3) { \\n        // Touch Up\\n    }\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\\n\\nUnsupported VR Platforms: Cardboard(Android and iOS).\",\n    \"15-0\": \"**opacity**\",\n    \"15-1\": \"**PropTypes.number**\\n\\nA number from 0 to 1 that specifies the opacity of the object. A value of 1 translates into a fully opaque object while 0 represents full transparency.\",\n    \"9-0\": \"**onError**\",\n    \"9-1\": \"**React.PropTypes.func**\\n\\nCallback invoked when the Image fails to load. The error message is contained in event.nativeEvent.error\",\n    \"20-1\": \"**PropTypes.oneOf(['leftRight', 'rightLeft', 'topBottom', 'bottomTop', 'none'])**\\n\\nSpecifies the alignment mode of the provided stereo image in source. Given image mode alignments are rendered in the order of Lefteye-Righteye. Defaults to none.\\n\\nNote: There's a known issue with stereoscopic images of the format RGB565 (the fix is on the roadmap).\",\n    \"20-0\": \"**stereoMode**\",\n    \"7-0\": \"**onFuse**\",\n    \"7-1\": \"**PropTypes.oneOfType**\\n```  \\nPropTypes.oneOfType([\\n      React.PropTypes.shape({\\n        callback: React.PropTypes.func.isRequired,\\n        timeToFuse: PropTypes.number\\n      }),\\n      React.PropTypes.func,\\n])\\n```  \\nAs shown above, onFuse takes one of the types - either a callback, or a dictionary with a callback and duration. \\n\\nIt is called after the user hovers onto and remains hovered on the control for a certain duration of time, as indicated in timeToFuse that represents the duration of time in milliseconds. \\n\\nWhile hovering, the reticle will display a count down animation while fusing towards timeToFuse.\\n\\nNote that timeToFuse defaults to 2000ms.\\n\\nFor example:\\n```  \\n_onFuse(source){\\n   // User has hovered over object for timeToFuse milliseconds\\n}\\n```\\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\"\n  },\n  \"cols\": 2,\n  \"rows\": 25\n}\n[/block]","excerpt":"","slug":"viroimage","type":"basic","title":"ViroImage"}
A component used to display 2D images. ######Example use: ``` <ViroImage height={2} width={2} placeholderSource={require("./res/local_spinner.jpg")} source={{uri:"https://my_s3_image.jpg"}} /> ``` [block:api-header] { "type": "basic", "title": "Props" } [/block] ##Required Props [block:parameters] { "data": { "0-0": "**source**", "0-1": "**PropTypes.oneOfType( [PropTypes.shape( {uri: PropTypes.string} ), PropTypes.number] )**\n\nThe image source, a remote URL or a local file resource. PNG and JPG images accepted.\n\nTo invoke with remote url: \n```\n{uri:\"http://example.org/myimage.png\"}\n```\nTo invoke with local source:\n```\nrequire('./image.png');\n```" }, "cols": 2, "rows": 1 } [/block] ##Optional Props [block:parameters] { "data": { "0-0": "**format**", "2-0": "**materials**", "8-0": "**onHover**", "17-0": "**position**", "18-0": "**rotation**", "19-0": "**scale**", "22-0": "**transformBehaviors**", "23-0": "**visible**", "h-0": "PropKey", "h-1": "PropType", "0-1": "**PropTypes.oneOf(['RGBA8', 'RGBA4', 'RGB565'])**\n\nImage texture formats for storage on the GPU.\n\n|Format|Description|\n|:------|:----------:|\n|RGBA8| Each pixel is described with 32-bits, using eight bits per channel|\n|RGBA4| Each pixel is described with 16 bits, using four bits per channel|\n|RGB565| Formats the picture into 16 bit color values without alpha|", "2-1": "**PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string),PropTypes.string])**\n\nAn array of strings that each represent a material that was created via ViroMaterials.createMaterials(). \n\nViroImage takes 1 material. The diffuseTexture of the material will be the image shown unless a source prop is specified. The other material properties will preserve as the source prop changes.", "8-1": "**React.PropTypes.func**\n\nCalled when the user hovers on or off the control.\n\nFor example:\n``` \n_onHover(isHovering, source) {\n if(isHovering) {\n // user is hovering over the box\n } else {\n // user is no longer hovering over the box\n }\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.", "17-1": "**PropTypes.arrayOf(PropTypes.number)**\n\nCartesian position in 3D space, stored as [x, y, z].", "18-1": "**PropTypes.arrayOf(PropTypes.number)**\n\nThe rotation of the transform in world space stored as Euler angles [x, y, z]. Units for each angle are specified in degrees.", "19-1": "**PropTypes.arrayOf(PropTypes.number)**\n\nThe scale of the image in 3D space, specified as [x,y,z]. A scale of 1 represents the current size of the image. A scale value of < 1 will make the image proportionally smaller while a value >1 will make the image proportionally bigger along the specified axis.", "22-1": "**PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string),PropTypes.string])**\n\nAn array of transform constraints that affect the transform of the image. For example, putting the value \"billboard\" will ensure the image is facing the user as the user rotates their head on any axis. This is useful for having the image always face the user on a particular axis, which especially useful for tappable icons.\n\nAllowed values(values are case sensitive):\n\n|Value|Description|\n|:------|:----------:|\n|billboard| Billboard object on x,y,z axis |\n|billboardX| Billboard object on the x axis|\n|billboardY| Billboard object on the y axis|", "23-1": "**PropTypes.bool**\n\nFalse if the image should be hidden. By default the button is visible and this value is true.", "10-0": "**onLoadStart**", "10-1": "**React.PropTypes.func**\n\nCallback triggered when we are processing the image to be displayed as specified by the source prop.", "11-1": "**React.PropTypes.func**\n\nCallback triggered when we have finished loading the image to be displayed. Whether or not the image was loaded and displayed properly will be indicated by the parameter \"success\".\n For example:\n \n _onLoadEnd(event:Event) {\n // Indication of asset loading success\n if(event.nativeEvent.success) {\n //our image successfully loaded!\n }\n }", "11-0": "**onLoadEnd**", "16-0": "**placeholderSource**", "16-1": "**PropTypes.oneOfType([ PropTypes.shape({ uri: PropTypes.string }), PropTypes.number ])**\n\nA static placeholder image that is shown until the source image is loaded it. It not specified, nothing will show until the source image is finished loading. PNG and JPG images accepted.\n\nExample:\n\nTo invoke with local source:\n```\nrequire('./image_placeholder.png');\n```", "21-0": "**style**", "21-1": "**stylePropType**\n\nRefers to a style property that is only used if within a ViroFlexView. Style properties determine the position and scale of the view within a ViroFlexView. Please see our guide on styles for my information.", "24-0": "**width**", "24-1": "**PropTypes.number**\n\nThe width of the image in 3D space. Default value is 1.", "1-0": "**height**", "1-1": "**PropTypes.number**\n\nThe height of the image in 3D space. Default value is 1.", "3-0": "**mipmap**", "3-1": "**PropTypes.bool**\n\nIf true, we dynamically generate mipmaps for the source of this given image.", "4-0": "**onClick**", "4-1": "**React.PropTypes.func**\n\nCalled when an objeect has been clicked.\n\nExample code:\n``` \n_onClick(source) {\n // user has clicked the object\n}\n```", "5-0": "**onClickState**", "6-0": "**onDrag**", "5-1": "**React.PropTypes.func**\n\nCalled for each click state an object goes through as it is clicked. Supported click states and their values are the following:\n\n|State Value|Description|\n|:------|:----------:|\n|1| Click Down: Triggered when the user has performed a click down action while hovering on this control.|\n|2| Click Up: Triggered when the user has performed a click up action while hovering on this control.|\n|3| Clicked: Triggered when the user has performed both a click down and click up action on this control sequentially, thereby having \"Clicked\" the object.|\n\nExample code:\n``` \n_onClickState(stateValue, source) {\n if(stateValue == 1) {\n // Click Down\n } else if(stateValue == 2) {\n // Click Up\n } else if(stateValue == 3) { \n // Clicked\n }\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.", "6-1": "**React.PropTypes.func**\n\nCalled when the view is currently being dragged. The dragToPos parameter provides the current 3D location of the dragged object. \n\nExample code:\n``` \n_onDrag(dragToPos, source) {\n // dragtoPos[0]: x position\n // dragtoPos[1]: y position\n // dragtoPos[2]: z position\n}\n``` \nFor the mapping of sources to controller inputs, see the [Events](doc:events) section. \n\nUnsupported VR Platforms: Cardboard iOS", "12-0": "**onScroll**", "13-0": "**onSwipe**", "14-0": "**onTouch**", "12-1": "**React.PropTypes.func**\n\nCalled when the user performs a scroll action, while hovering on the control.\n\nFor example:\n``` \n_onScroll(scrollPos, source) {\n // scrollPos[0]: x scroll position from 0.0 to 1.0. \n // scrollPos[1]: y scroll position from 0.0 to 1.0.\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\n\nUnsupported VR Platforms: Cardboard(Android and iOS)", "13-1": "**React.PropTypes.func**\n\nCalled when the user performs a swipe gesture on the physical controller, while hovering on this control. \n\nFor example:\n``` \n_onSwipe(state, source) {\n if(state == 1) {\n // Swiped up\n } else if(state == 2) {\n // Swiped down\n } else if(state == 3) { \n // Swiped left\n } else if(state == 4) { \n // Swiped right\n }\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\n\nUnsupported VR Platforms: Cardboard(Android and iOS)", "14-1": "**React.PropTypes.func**\n\nCalled when the user performs a touch action, while hovering on the control. Provides the touch state type, and the x/y coordinate at which this touch event has occurred.\n\n|State Value|Description|\n|:------|:----------:|\n|1| Touch Down: Triggered when the user makes physical contact with the touch pad on the controller. |\n|2| Touch Down Move: Called when the user moves around the touch pad immediately after having performed a Touch Down action. |\n|3| Touch Up: Triggered after the user is no longer in physical contact with the touch pad after a Touch Down action. |\n\nFor example:\n``` \n_onTouch(state, touchPos, source) {\n var touchX = touchPos[0];\n var touchY = touchPos[1];\n if(state == 1) {\n // Touch Down\n } else if(state == 2) {\n // Touch Down Move\n } else if(state == 3) { \n // Touch Up\n }\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section.\n\nUnsupported VR Platforms: Cardboard(Android and iOS).", "15-0": "**opacity**", "15-1": "**PropTypes.number**\n\nA number from 0 to 1 that specifies the opacity of the object. A value of 1 translates into a fully opaque object while 0 represents full transparency.", "9-0": "**onError**", "9-1": "**React.PropTypes.func**\n\nCallback invoked when the Image fails to load. The error message is contained in event.nativeEvent.error", "20-1": "**PropTypes.oneOf(['leftRight', 'rightLeft', 'topBottom', 'bottomTop', 'none'])**\n\nSpecifies the alignment mode of the provided stereo image in source. Given image mode alignments are rendered in the order of Lefteye-Righteye. Defaults to none.\n\nNote: There's a known issue with stereoscopic images of the format RGB565 (the fix is on the roadmap).", "20-0": "**stereoMode**", "7-0": "**onFuse**", "7-1": "**PropTypes.oneOfType**\n``` \nPropTypes.oneOfType([\n React.PropTypes.shape({\n callback: React.PropTypes.func.isRequired,\n timeToFuse: PropTypes.number\n }),\n React.PropTypes.func,\n])\n``` \nAs shown above, onFuse takes one of the types - either a callback, or a dictionary with a callback and duration. \n\nIt is called after the user hovers onto and remains hovered on the control for a certain duration of time, as indicated in timeToFuse that represents the duration of time in milliseconds. \n\nWhile hovering, the reticle will display a count down animation while fusing towards timeToFuse.\n\nNote that timeToFuse defaults to 2000ms.\n\nFor example:\n``` \n_onFuse(source){\n // User has hovered over object for timeToFuse milliseconds\n}\n```\nFor the mapping of sources to controller inputs, see the [Events](doc:events) section." }, "cols": 2, "rows": 25 } [/block]