I am currently having 20 targets and they all have different URL. Following the sample, all of them have to be declared one by one like:
// Create overlay for page one
var imgOne = new AR.ImageResource("assets/imageOne.png");
var overlayOne = new AR.ImageDrawable(imgOne, 1, {
offsetX: -0.15,
offsetY: 0
});
var pageOne = new AR.Trackable2DObject(this.tracker, "pageOne", {
drawables: {
cam: overlayOne
}
});
and again we declare
// Create overlay for page two
var imgTwo = new AR.ImageResource("assets/imageTwo.png");
var overlayTwo = new AR.ImageDrawable(imgTwo, 0.5, {
offsetX: 0.12,
offsetY: -0.01
});
var pageTwo = new AR.Trackable2DObject(this.tracker, "pageTwo", {
drawables: {
cam: overlayTwo
}
});
I want to put them in a loop instead. I found another thread having similar problem, and the solution is:
loop(condition){
new AR.Trackable2DObject(this.tracker, "targetName", {
drawables: {
cam: new AR.ImageDrawable(new AR.ImageResource("assets/targetImage.png"), 1, {
offsetX: -0.15,
offsetY: 0
})
}
});
}
But my overlay is html with URL, so when i tried
for(i=0;i<targetList.length;i++){
new AR.Trackable2DObject(this.tracker, targetList[i], {
drawables: {
cam: [clickMeOverlay, sparkles,
new AR.HtmlDrawable({
uri: htmlAssetFolder+targetList[i]+".html"
}, 1, {
offsetX: 1,
offsetY: 0,
horizontalAnchor: AR.CONST.HORIZONTAL_ANCHOR.RIGHT,
verticalAnchor: AR.CONST.VERTICAL_ANCHOR.TOP,
clickThroughEnabled: true,
onClick: function() {
document.location = "architectsdk://"+targetList[i];
return true;
}
})
]
}
});
all target in the list can be recognized with the correct overlay. but when i click the overlay, all of them leads to the same URL, which is the last item in the list. I have been trying for few hours T^T for your kind help please. many thanks!!!!