Wikitude ARchitect v2.0 API Documentation

Wikitude ARchitect > AR > GeoObject
Filters

Class GeoObject - extends ARObject

A GeoObject represents a virtual object bound to specific locations in the earth's 3-dimensional space. Any GeoObject is linked to at least one Location.

A GeoObject
  • must have at least one location and can never exist without at least one location.
  • can have Drawables associated with it. These Drawables will represent the GeoObject in the camera view.
  • can have triggers associated with it. Triggers fire on certain events and execute functions to react on these actions.
On creation, a reference to Locations must be passed to define where the GeoObject is located in the real world.

A GeoObject can either be enabled or disabled (see ARObject.enabled). Enabled means that the GeoObject will be considered in the calculations to project its drawables onto the camera screen, and its triggers will fire on the appropriate events. In case the GeoObject is disabled, it will not be considered in the calculations, and it will not fire any triggers.

On creation, setup parameters can be passed to customize the properties of the GeoObject.

Example:
// a GeoObject which is disabled per default
var geoObject1 = new AR.GeoObject(geoLocation1, {
  enabled : false
});
// now, we enable geoObject1 so it will is considered for projection.
geoObject1.enabled = true;

// a GeoObject which reacts when the GeoObject becomes visible and invisible. // whenever it becomes visible, the altitude is increased by 1 meter // whenever it becomes invisible, the altitude decreases by 1 meter. var geoObject2 = new AR.GeoObject(geoLocation1); geoObject2.onEnterFieldOfVision = function() {   geoObject2.locations[0].altitude++; }; geoObject2.onExitFieldOfVision = function() {   geoObject2.locations[0].altitude--; };
// a GeoObject which has two locations set var geoObject3 = new AR.GeoObject( [ geoLocation1, geoLocation2 ], null);
// a GeoObject with triggers and drawables set on creation date var geoObject4 = new AR.GeoObject(locations, {   //the function executed when the GeoObject enters the field of vision   onEnterFieldOfVision : function(){ ... },   //the function executed when the GeoObject exits the field of vision   onExitFieldOfVision : function(){ ... },   drawables : { cam :       [drawable1, drawable2] //the drawables representing the GeoObject in the camera view   } });
//The Drawables can also be specified as a single object: new AR.GeoObject(locations,   { ...     drawables : { cam : drawable1}   } );
For the render size of attached Drawables, see the chapter on SDUs.

Constructor

GeoObject ( location , options )
Parameters:
location <Location|Array(Location)> Reference(s) to where this GeoObject is located.
options <object> Setup-Parameters to customize additional object properties.

Accepted options-properties are
  • enabled
  • renderingOrder
  • onEnterFieldOfVision
  • onExitFieldOfVision
  • onClick
  • drawables.cam

Properties

drawables.indicator - Array(Drawable2D)

The Drawable2Ds which will be used to indicate the direction where the GeoObject is located, in case the GeoObject is currently not visible on the screen.

Drawables in the array will be printed starting with the Drawable at position 0, causing Drawables at later indices to overlap the previously drawn Drawables.

The indicator Drawables will be rendered on the edge of the screen and will move around the screen edges as the user is moving the phone. For indicator Drawables, 1 SDU is defined to be the width of the screen in landscape orientation. Thus, if an ImageDrawable with width 0.5 SDUs is created, it will take up half the width of the screen.

As the indicator Drawables move around the edges of the screen, their x and y orientation changes. Thus, the following behavior is defined for any manipulation (offsetX, offsetY, rotation, scaling etc.) on the Drawable2D: The manipulations are applied when the Drawable2D is located on the top edge of the screen, horizontally centered. A positive offsetY, for example, make the Drawable move further away from the top screen edge. As the Drawable moves around the edges of the screen and is finally located on the left edge of the screen, offsetY will still cause the drawable to be drawn further away from the left edge of the screen. The offsetX setting behaves accordingly with left/right shifting of the Drawable.

Remark:

The array content should not be manipulated via the [] operator, as it cannot be guaranteed that the changes will be propagated through to the native application. The property should only be manipulated with geoobject.drawables.addIndicatorDrawable() and geoobject.drawables.removeIndicatorDrawable(), or directly set with geoobject.drawables.indicator = new Array(...);.

Remark:

Clicks on the indicator Drawable2Ds (Drawable.onClick) will not be handled. Assigning a function to the click trigger of Drawable2Ds used as indicators is allowed, however, they will not be triggered.

drawables.radar - Array(Drawable2D)

The Drawable2Ds which will be used to represent the ARObject in the radar. The drawables will only show if AR.radar is enabled and initialized with valid values.

Drawables in the array will be printed starting with the Drawable at position 0, causing Drawables at later indices to overlap the previously drawn Drawables.

In the radar, 1 SDU is defined to be the radius of the radar. Thus, if a Circle with radius 1 SDU is created, the circle will take up the entire space of the radar.

Remark:

The array content should not be manipulated via the [] operator, as it cannot be guaranteed that the changes will be propagated through to the native application. The property should only be manipulated with geoobject.drawables.addRadarDrawable() and geoobject.drawables.removeRadarDrawable(), or directly set with geoobject.drawables.radar = new Array(...);.

Remark:

Clicks on the Drawable2Ds (Drawable.onClick) in the radar will not be handled. Assigning a function to the click trigger of Drawable2Ds in the radar is allowed, however, they will not be triggered. Refer to AR.radar.onClick() for event handling on radar clicks.

locations - Array(Location)

The array of Locations of the GeoObject. When a single Location is set as location, it will implicitly be transformed into an Array of Locations with only one entry. Thus, the following four statements have the same effect:
geoObject = new AR.GeoObject(location);
geoObject.locations = location;
geoObject.locations = new Array(location);
geoObject.locations = [ location ];

Properties inherited from ARObject:

Properties inherited from ARchitectObject:

Methods

drawables.addIndicatorDrawable

void drawables.addIndicatorDrawable ( drawable , position )
Adds Drawable2Ds as off-screen-indicators to the GeoObject.
Parameters:
drawable <Drawable2D|Array(Drawable2D)> The drawable(s) that should be added. Can either be a single Drawable2D, or an Array of Drawable2Ds.
position <int> The position where the Drawable2D should be added in the array. If not specified, the Drawable2D will be added at the end of the array.
Returns: void

drawables.addRadarDrawable

void drawables.addRadarDrawable ( drawable , position )
Adds Drawable2Ds to the GeoObject in the radar.
Parameters:
drawable <Drawable2D|Array(Drawable2D)> The drawable(s) that should be added to the radar. Can either be a single Drawable2D, or an Array of Drawable2Ds.
position <int> The position where the Drawable2D should be added in the array. If not specified, the Drawable2D will be added at the end of the array.
Returns: void

drawables.removeIndicatorDrawable

void drawables.removeIndicatorDrawable ( drawable|position )
Removes Drawable2Ds as indicators from the GeoObject.
Parameters:
drawable|position <Drawable2D|Array(Drawable2D)|int> When a single Drawable2D or an Array of Drawable2Ds is given, these Drawable2Ds will be removed from the array. When an integer is given, the Drawable2D at the specified position will be removed.
Returns: void

drawables.removeRadarDrawable

void drawables.removeRadarDrawable ( drawable|position )
Removes Drawable2Ds from the GeoObject in the radar.
Parameters:
drawable|position <Drawable2D|Array(Drawable2D)|int> When a single Drawable2D or an Array of Drawable2Ds is given, these Drawable2Ds will be removed from the array. When an integer is given, the Drawable2D at the specified position will be removed.
Returns: void


Copyright © 2013 Wikitude GmbH. All rights reserved.