Layar Developer Documentation

Back to layar.com

object

JSON Response - Object

Image Map
object json dictionary v3.0; in v6.2 introduced "AR video" object for Vision layer.
Mandatory/Optional: optional for Geo layers ; mandatory for Vision layers
Path: root.hotspots
Detailed Description: In the Camera view, a POI can be represented by:
  • 2D image (introduced in API v3.0), file size should be smaller than 100Kb.
  • 3D model (introduced in API v3.0), file size should be smaller than 1Mb.
  • AR Video (introduced in API v6.2), videos need to be in MP4 container with h264 codec for video and AAC codec for audio. The resolution should be 320x240 pixels.
  • HTML Widgets (introduced in API v7.1), need to represent small snippets of web content that can be dynamic and interactive, created using HTML, javascript, and CSS.
  • Transparent videos (introduced in API 8.3), videos need to be encoded in a special way, where the color and alpha information are placed side-by-side. A tutorial can be found here
These objects will be rendered realistically as if they are placed in the real world. More detailed explanations on how to add objects to a layer and how layar clients render objects are documented here .
Example:
"object": {
  "contentType": "model/vnd.layar.l3d",
  "url": "http://example.com/example_full.l3d",  
  "reducedURL": "http://example_reduced.l3d",  
  "size": 2
}
contentType string The content type of the object.
Mandatory/Optional: mandatory
Path: root.hotspots.object
Detailed Description: This determines whether a POI should be represented by a 2D image, a 3D model or an AR Video. The available options are:
  • image/vnd.layar.generic for any supported image type (PNG, GIF, JPEG);
  • image/jpeg, image/gif, image/png for images.                    
  • model/vnd.layar.l3d for 3D models.
  • video/mp4 for AR video.
  • text/html for HTML Widgets
  • video/vnd.layar.splitalpha for transparent videos (alpha channel)
url string The URL of the object to be displayed./HTML Widgets: the URL of the page that the viewport refers to is hosted
Introduced API: v7.1
Mandatory/Optional: mandatory
Path: root.hotspots.object
Detailed Description: HTML Widgets: This URL should point to the webpage that can be displayed in HTML Widgets. Only pages written in HTML, javascript, and CSS will be recognized. Availability of the page is checked inline and reported if 404 error is found, as a warning.
size float The height of the object in meters.
Mandatory/Optional: mandatory
Path: root.hotspots.object
Detailed Description: This is used to specify the size of the object. For 2D images and AR videos, this determines the size at which the object will be rendered. For 3D models, this is a cue to the client whether to select the full model or the reduced model (if there is a reduced model) to download. For HTML Widgets this value specifies the size of the widget with respect to the reference image/Page, preserving the aspect ratio of the widget. This also affects the size of the content within the viewport, i.e. the pixel size within the viewport will scale proportionally as the value of size is changed.
reducedURL string Geo Layer Only: the URL of a smaller version of object to be displayed.
Mandatory/Optional: optional for Geo layer / deprecated for Vision layer
Default value: null
Path: root.hotspots.object
Detailed Description: This defines a smaller version to be rendered when the POI is further away from the user. Specifying this can improve performance when there are many POIs on the screen. NOTE: Do not put the same URL here as for object.url, it will not have any functional effect and only consume bandwidth.            
previewImage string Vision Layer Only: a placeholder of the AR video
Mandatory/Optional:
  • Not needed for 2d image and 3d model
  • mandatory for AR video
Path: root.hotspots.object
Detailed Description: This image is used while buffering the video. To make the AR video work across all platforms, developers can provide an image as the placeholder when no AR video playback is available on the device.
showLoadingIndicator Bool Flag indicating whether to show the indicator for an object
Mandatory/Optional: Optional
Path: root.hotspots.object
Detailed Description: By default, Layar shows loading indicators for all objects in the AR view. Layar 8.4 adds a boolean flag indicating whether we need to show the indicator for an object (default value remains true).
showPlayBackControls Bool Flag indicating whether to show play/replay buttons on videos
Mandatory/Optional: Optional
Path: root.hotspots.object
Detailed Description:  If set to false the play/replay button on top of the video does not show up. If the video finishes playing, the last frame of the video is shown.
allowFullscreenPlayback Bool Vision Layer Only: a placeholder of the AR video
Mandatory/Optional:
Path: root.hotspots.object
Detailed Description: If set to false, we disable the tap to open fullscreen functionality of the video augment.
loopPlayback Bool Vision Layer Only: a placeholder of the AR video
Mandatory/Optional:
  • Not needed for 2d image and 3d model
  • mandatory for AR video
Path: root.hotspots.object
Detailed Description: This image is used while buffering the video. To make the AR video work across all platforms, developers can provide an image as the placeholder when no AR video playback is available on the device.
viewport Json dictionary  HTML Widgets only:The visible area of the webpage
Introduced API: v7.1
Mandatory/Optional: mandatory
Path: root.hotspots.object
Detailed Description: This defines the viewport of an HTML panel. The width and height of the viewport define the portion of the webpage visible to the augment in CSS pixels. Their values should match the page dimensions of your web page if you want to fully display it. We strongly suggest setting viewport to less than 300x400 pixels. Technically we allow a maximum viewport of 512x512 pixels.The image bellow shows how a page will be displayed if viewport's width and height values are smaller than the actual size in CSS pixels.
width pixels HTML Widgets only:The width of the viewport
Path: root.hotspots.object.viewport
Description: The width of the viewport in CSS pixels.
root.hotspots.object.viewport
Description: the height of the viewport in CSS pixels.
scrollable Boolean HTML Widgets only:Enables scrolling of the viewport
Path: root.hotspots.object.viewport
Default value: false (recommended, unless there is a good reason to set it to true)
Description: If set to true users can scroll to view the overflown content of the page. Please NOTE that on Android devices users will still be able to scroll even if value is set to false, scrolling bars will not be shown however. On iPhone, the content is not scrollable if value is set to false as expected.
In general for AR use cases it is good practice to make your HTML content fit exactly within the viewport, so that no scrolling is needed.
interactive Boolean HTML Widgets only:Enables  interaction within the viewport.
Path: root.hotspots.object.viewport
Default value: true
Description: When set to true the web view behaves like a normal browser, users can click links and select buttons. Please NOTE that users will navigate away to a new Page that is displayed in the web view in full screen.
 
If set to false it will overrule the scrollable parameter and its value will be considered as false. In that case users will no longer be able to interact with the page content but view it. Once viewport.interactive is set to false, it is possible to attach POI level actions to the HTML widget. If a user clicks on the HTML widget, the action will be triggered. For more information on actions please check actions
override json dictionary An array of material overrides (L3d objects)
Introduced API: v8.3
Optional: This parameter is optional and should be defined only for 3D objects
Path: root.hotspots.object
Detailed Description: Object "override" contains an array of material overrides
materials json dictionary An array containing all properties regarding material overrides 
Optional: This parameter is optional and should be defined only for 3D objects
Path: root.hotspots.object.override
Detailed Description: An array holding information regarding material overrides. Any property of material object is optional, except for “materialId”. Not that only existing properties will be applied to base material.
materialId decimal This value should correspond to the material name defined in the L3d file. Any number of material overrides can be applied to the same material id. In this case overrides are applied in order of appearance in JSON. mandatory
texture  Json dictionary Supported content type for textures are:  
  •  image/jp3g
  •  image/png
  •  image/gif 
  •  video/mp4
  •  video/vnd.layar.splitalpha
Flags "repeatT" and "repeatS" specify if the texture image should be repeated (true) or clamped to edge (false) if a respective texture coordinate (S or T) goes out of 0 to 1 bounds. If a flag is omitted the default value is false. Video textures are always clamped to edge, regardless of these flag values. Default (and the only supported as of L3D version 3) texture repeat method for L3D model files is 'repeat'. This is different from the default value if the flag is omitted.
optional
diffuseColor color-hex The value of diffuse colour parameter. Color format is “#RRGGBB” or “#AARRGGBB” optional
ambientColor color-hex The value of ambient colour parameter. Color format is “#RRGGBB” or “#AARRGGBB” optional
specularColor decimal The value of specular colour parameter. Color format is “#RRGGBB” or “#AARRGGBB” optional
shininess decimal Shininess value can be any  value between (and including) 0 and 128. optional
useBlending boolean when blending is true, it means that color value of this material is blended with the color of any other objects that are rendered behind it. If it is disabled, it means the objects that are rendered behind it are hidden from view. This can be used to merge virtual and real objects in a more natural way. optional
useLighting boolean Shininess value can be any  value between (and including) 0 and 128. optional
opacity decimal The material color transparency can be changed using Opacity parameter. Opacity value is in range 0.0 to 1.0. Setting “opacity” sets alpha values for all colors. Alpha values specified in “ambientColor”, “diffuseColor” and “specularColor” are ignored if “opacity” is specified. optional
<event_type>json dictionary The event types after which an action or event handler can be triggered
Introduced API: v8.5
Mandatory/Optional: optional for Geo and Vision layers
Path: root.object
Possible values:
  • onLoad
    Triggered when the object/renderable has been loaded successfully
  • onClick
    Triggered when the object/renderable has been clicked (similar behavior as the POI action)
  • onPlaybackStart
    Triggered when the video or audio object playback started
  • onPlaybackFinish
    Triggered when the video or audio object playback finished
Description See the description of event_handlers in the hotspots section to see a detailed description of the possible event handler objects that can be added to the event_type dictionary. The possible elements are:
  • action: same action object as used on a hotspot
  • handler: string uniquely identifying the handler, as defined in the event_handlers
  • update: direct update of the hotspots array by adding or deleting hotspots
Example:
"object:" {
    "url": "...",
    "contentType": "image/png",
    "size": 1.0,
    "onClick": {
        "action": {
            "contentType": "application/vnd.layar.internal",
            "uri": "layar://[layername]/?parameters"
        }
    }
}

Complete Json example

  "object": {
                "url": "http://yourlink.com/object.l3d",
                "override": {
                    "materials": [
                        {
                            "opacity": 1.0,
                            "ambientColor": "#000000",
                            "diffuseColor": "#660000",
                            "shininess": 50,
                            "materialId": "paint",
                            "specularColor": "#7f7f7f"
                        }
                    ]
                },
                "contentType": "model/vnd.layar.l3d",
                "size": 0.62765415012836456
            },