Start a new topic

onClick on ImageDrawable not responding

onClick on ImageDrawable not responding
1 Comment


I needed Snaptoscreen feature for a 2D image for my android app. The Video and 3D image snaptoscreen in the SDK 5.0 examples works fine on my setup. Im trying the same changes on my js file, but the onClick event for ImageDrawable is not working. Below are my changes in JS. Do I have to handle touch and gesture events too?? Any suggestions would help me proceed. Thanks!..

createOverlays: function createOverlaysFn() {
First an AR.ClientTracker needs to be created in order to start the recognition engine. It is initialized with a URL specific to the target collection. Optional parameters are passed as object in the last argument. In this case a callback function for the onLoaded trigger is set. Once the tracker is fully loaded the function worldLoaded() is called.
Important: If you replace the tracker file with your own, make sure to change the target name accordingly.
Use a specific target name to respond only to a certain target or use a wildcard to respond to any or a certain group of targets.
this.tracker = new AR.ClientTracker("assets/", {
onLoaded: this.worldLoaded,
physicalTargetImageHeights: {
pageOne: 268

var imgRotate = new AR.ImageResource("assets/rotateButton.png");
this.buttonRotate = new AR.ImageDrawable(imgRotate, 0.2, {
offsetX: 0.35,
offsetY: 0.45,
//onClick: this.rotate

var imgSnap = new AR.ImageResource("assets/snapButton.png");
this.buttonSnap = new AR.ImageDrawable(imgSnap, 0.2, {
offsetX: -0.35,
offsetY: -0.45,
//onClick: this.toggleSnapping
onClick: function() {

The next step is to create the augmentation. In this example an image resource is created and passed to the AR.ImageDrawable.
A drawable is a visual component that can be connected to an IR target (AR.Trackable2DObject) or a geolocated object (AR.GeoObject).
The AR.ImageDrawable is initialized by the image and its size. Optional parameters allow for position it relative to the recognized target.

/* Create overlay for page one */
var imgOne = new AR.ImageResource(decodeURIComponent(imagePath));
overlayOne = new AR.ImageDrawable(imgOne, 1, {
offsetX: -0.15,
offsetY: 0

/* The last line combines everything by creating an AR.Trackable2DObject with the previously created tracker, the name of the image target and the drawable that should augment the recognized image.
Please note that in this case the target name is a wildcard. Wildcards can be used to respond to any target defined in the target collection. If you want to respond to a certain target only for a particular AR.Trackable2DObject simply provide the target name as specified in the target collection.
pageOne = new AR.Trackable2DObject(this.tracker, "*", {
drawables: {
snapToScreen: {
//enabledOnExitFieldOfVision: true,
snapContainer: document.getElementById('snapContainer')
onEnterFieldOfVision: this.appear,
onExitFieldOfVision: this.disappear



Login or Signup to post a comment