Wikitude ARchitect v2.0 API Documentation

Wikitude ARchitect > AR > context

static Class context

context includes some general functions which allow interaction with system components.

The Singleton instance of the class will automatically be created on World startup and can be accessed via AR.context.

context also allows for some custom functionality, for example onLocationChanged, which will be triggered by the system as soon as the user's location changes. It enables the developer to find out about the user's location and thus setup the AR scene to his needs.

AR.context.onLocationChanged = function(latitude, longitude, altitude, accuracy){
  //now, add custom functionality to build the AR scene based on the location


clickBehavior - string

clickBehavior controls what should be considered a click. The following options are available:

  • AR.CONST.CLICK_BEHAVIOR.CLICK: the platform considers a click only when the user presses and releases the screen at the same screen region. The click is fired after the user releases the finger from the screen
  • AR.CONST.CLICK_BEHAVIOR.TOUCH_DOWN: click fires as soon as the user touches the screen
  • AR.CONST.CLICK_BEHAVIOR.TOUCH_UP: click fires as soon as the user puts the finger off the screen, regardless of where the user started the touch on the screen.

scene.cullingDistance - int

The maximum distance at which objects are visible in the scene, in meters. If an object's distance to the user is further than the culling distance, the object will not be visible in the scene.
Default Value: 50000 - boolean

Controls if the camera is active or not.

If the property is set to true, the camera is visible on the screen, and computer vision components are activated. If the property is set to false, the camera will be disabled, a black background will be visible and computer vision components are specifically deactivated.

It is recommended to disable the camera service temporarily when fullscreen HTML is shown. This reduces power consumption and increases performance.
Default Value: true

services.sensors - boolean

Controls if the sensors are active or not. Sensors include GPS, mangetometer, accelerometer and gyroscope.

If the property is set to true, any geo-related components (such as GeoObjects and ActionRanges) are active. If the property is set to false, any geo-related components will not be visible on the screen, and triggers will not fire.

It is recommended to disable the sensors service when only computer vision components are used. This reduces power consumption and increases performance.
Default Value: true



void destroyAll ( )
Destroys all objects. See AR.ARchitectObject.destroy() for effects of this call.
Returns: void


void onLocationChanged ( latitude , longitude , altitude , accuracy )
The function will be called as soon as
  • the location is fetched the first time, or
  • the location of the user changes.
The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onLocationChanged.
latitude <double> the current latitude of the user, based on WGS84
longitude <double> the current longitude of the user, based on WGS84
altitude <double> the current altitude of the user, based on WGS84
accuracy <double> The accuracy of the reported location, see AR.CONST.LOCATION_ACCURACY for details
Returns: void


void onScreenClick ( )
Executed when the user clicks on the screen, no HTML element was hit and either
  • no Drawable was hit on the click, or
  • Drawables were hit on the click, but even the last Drawable in the click queue returned false in its onClick trigger.
See AR.Drawable.onClick() for details on the click-queue.
Returns: void


void openInBrowser ( url , forceNativeBrowser )
Opens the specified url in the native Browser. If forceNativeBrowser is true, the URL will be opened in the native browser (e.g. Safari on iOS), otherwise it will be opened in a new webview.
url <string> the url to be opened
forceNativeBrowser <boolean> open URL in native browser (true) or in a webview within the application (false). If not specified, default value is false.
Returns: void


void startVideoPlayer ( uri )
Starts the native video player and plays the video at the specified URI. Will close the video player automatically when the video finished.
uri <string> the uri to the video
Returns: void

Copyright © 2013 Wikitude GmbH. All rights reserved.