Wikitude ARchitect v3.2 API Documentation

Wikitude ARchitect > AR > context
Filters

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.

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

Properties

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.
Default Value: AR.CONST.CLICK_BEHAVIOR.CLICK

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

scene.maxScalingDistance - float

The distance, in meters, at which objects will keep their size on the screen even when the user moves further away. If the user is further than maxScalingDistance, the object will not appear any smaller than the size it took on at maxScalingDistance. Must be a positive number.
Default Value: 20000

scene.minScalingDistance - float

The distance, in meters, at which objects will start to appear smaller on the screen when the user moves further away. If the user is closer than minScalingDistance, the object will not appear any bigger than the size it took on at minScalingDistance. Must be a positive number.
Default Value: 10

scene.scalingFactor - float

The amount of scaling that is applied between minScalingDistance and maxScalingDistance. The scalingFactor controls the size the object takes on at maxScalingDistance, in percentage of the size it took on at minScalingDistance.

Must be in the range of [0,1].

Set the scalingFactor to 1 if no scaling should be applied for the objects.
Default Value: 0.1

services.camera - 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

Methods

destroyAll

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

onLocationChanged

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.
Parameters:
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

onScreenClick

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

openInBrowser

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.
Parameters:
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

startVideoPlayer

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.
Parameters:
uri <string> the uri to the video
Returns: void


Copyright © 2013 Wikitude GmbH. All rights reserved.