ARObject Class
An ARObject is an abstract class which must not be instantiated directly.
It provides basic methods and properties required for the objects rendered in the AR scene.
ARObjects are somehow registered in the real world, either with geo coordinates (GeoObject) or with visual trackable objects (ImageTrackable). They also have Drawables attached to it, which are used to represent the ARObject on the screen.
Item Index
Properties
Methods
destroy
()
Destroys the object.
drawables.addCamDrawable
-
drawable
-
position
Adds Drawables to the ARObject in the camera.
Parameters:
-
drawable
Drawable | Drawable[]The drawable(s) that should be added to the camera. Can either be a single Drawable, or an Array of Drawables.
-
position
Number optionalThe position where the Drawable should be added in the array. If not specified, the Drawable will be added at the end of the array. Must be a whole number.
drawables.removeCamDrawable
-
drawable|position
Removes Drawables from the ARObject in the cam.
Parameters:
-
drawable|position
Drawable | [Drawable] | NumberWhen a single Drawable or an Array of Drawables is given, these Drawables will be removed from the array. When an integer is given, the Drawable at the specified position will be removed.
isVisible
()
Boolean
Returns the current visibility state of the ARObject. An ARObject is defined visible when at least one of the ARObject's locations (geolocations or visual tracker) is projected onto a screen coordinate which is currently visible on the screen.
Returns:
Whether the ARObject is currently visible on the screen (true) or invisble (false).
Properties
drawables.cam
Drawable[]
The Drawables which will be used to represent the ARObject
in the camera view.
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 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 arobject.drawables.addCamDrawable() and arobject.drawables.removeCamDrawable(), or directly set with arobject.drawables.cam = new Array(...);.
renderingOrder
Number
Drawables of different ARObjects might overlap. In this case, renderingOrder defines the rendering order of the Drawables of the ARObject.
ARObjects with higher renderingOrder values cause their Drawables to be drawn on top of the Drawables of ARObjects with lower renderingOrder values.
In case two ARObjects have set the same renderingOrder, the Drawables are rendered based on the distance, causing objects closer to the user to
overlap objects further away.
For example, If you want to bring Drawables of a certain ARObject to the very front, set the renderingOrder value of the corresponding ARObject
to a very high value.
For the printing order of Drawables within the same ARObject, refer to Drawable2D.zOrder.
Must be a whole number.
Default: 0
Events
onClick
Will be executed when any of the ARObject's Drawables have been clicked,
and none of the clicked Drawables's onClick() triggers (might also be referenced by another ARObject)
have been set to quit the click chain. ARObject.onClick() will be executed after any Drawable.onClick() triggers have
been executed.
In case multiple ARObjects are hit by the click, the order of the execution is defined by the distance
of the ARObject to the user, with the closest ARObject's click trigger executed first.
The return value of the function determines if, after the onClick()-function was executed for this ARObject, the queue shall continue to execute onClick() for the next ARObject in the queue. In case the last ARObject in the queue still requests to continue the click-queue, context.onScreenClick() will be executed.
The return value of the function decides what to do next. If false, the click-queue should not stop with this ARObject. Thus, the next ARObject's onClick() function will be executed. This is the default value in case no return value is set or the function is not defined for this ARObject. If true, the queue-execution will stop at the current ARObject, underlying ARObjects will not receive onClick() calls.
onDragBegan
Executed when the user starts dragging on at least one Drawable with a single finger and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
xNormalized
Numberthe distance on the X-axis between the initiating touch position and the updated touch position [-1, 1]; always 0 in onDragBegan as no change to the drag gesture has occurred yet
-
yNormalized
Numberthe distance on the Y-axis between the initiating touch position and the updated touch position [-1, 1]; always 0 in onDragBegan as no change to the drag gesture has occurred yet
onDragChanged
Executed when the user drags on at least one Drawable with a single finger and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
onDragEnded
Executed when the user stops dragging on at least one Drawable with a single finger and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
xNormalized
Numberthe distance on the X-axis between the initiating touch position and the updated touch position [-1, 1]; always identical to the most recent distance received in onDragChanged
-
yNormalized
Numberthe distance on the Y-axis between the initiating touch position and the updated touch position [-1, 1]; always identical to the most recent distance received in onDragChanged
onPanBegan
Executed when the user starts dragging on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
xNormalized
Numberthe distance on the X-axis between the initiating touch positions and the updated touch positions [-1, 1]; always 0 in onPanBegan as no change to the pan gesture has occurred yet; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
-
yNormalized
Numberthe distance on the Y-axis between the initiating touch position and the updated touch position [-1, 1]; always 0 in onPanBegan as no change to the pan gesture has occurred yet; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
onPanChanged
Executed when the user drags on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
xNormalized
Numberthe distance on the X-axis between the initiating touch positions and the updated touch positions [-1, 1]; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
-
yNormalized
Numberthe distance on the Y-axis between the initiating touch position and the updated touch position [-1, 1]; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
onPanEnded
Executed when the user stops dragging on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
xNormalized
Numberthe distance on the X-axis between the initiating touch positions and the updated touch positions [-1, 1]; always identical to the most recent distance received in onPanChanged; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
-
yNormalized
Numberthe distance on the Y-axis between the initiating touch position and the updated touch position [-1, 1]; always identical to the most recent distance received in onPanChanged; the mid-points between the first and second touches are used to calculate the distances to allow co-operative behaviour with the scale and rotate gesture
onRotationBegan
Executed when the user starts rotating on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
angle
Numberthe CCW angle in degree between the line defined by the initiating touch positions and the line defined by the updated touch positions [0, 360); always 0 in onRotationBegan as no change to the rotation gesture has occurred yet
onRotationChanged
Executed when the user rotates on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
angle
Numberthe CCW angle in degree between the line defined by the initiating touch positions and the line defined by the updated touch positions [0, 360)
onRotationEnded
Executed when the user stops rotating on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
angle
Numberthe CCW angle in degree between the line defined by the initiating touch positions and the line defined by the updated touch positions [0, 360); always identical to the most recent angle received in onRotationChanged
onScaleBegan
Executed when the user starts scaling on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
scale
Numberthe scale value defined the ratio of the distance between the updated touches over the distance between the initiating touches [0, inf]; always 1 in onScaleBegan as no change to the scale gesture has occurred yet
onScaleChanged
Executed when the user scales on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
scale
Numberthe scale value defined the ratio of the distance between the updated touches over the distance between the initiating touches [0, inf]
onScaleEnded
Executed when the user stops scaling on at least one Drawable with two fingers and none of these Drawables quits the event propagation by returning true. This callback behaves identically to the onClick callback in terms of event propagation.
Event Payload:
-
scale
Numberthe scale value defined the ratio of the distance between the updated touches over the distance between the initiating touches [0, inf]; always identical to the most recent scale received in onScaleChanged