Start a new topic

Dynamically add Drawables to Trackable2DObjects

Dynamically add Drawables to Trackable2DObjects


Hi,

I am currently working on my thesis, "augmented reality tourism app", and my academy tutor told me that they are proceeding to buy license for Android and Vuzix.

At this point, I achieved requested goals except one.
My last goal is to implement this feature: "When a target is correctly recognized, a drawable pops up on the target (<done>). Then, user should be able to change the drawable with other pictures interacting through a slider (like an image gallery, but with pictures tracking the target)".

Please take a look at the code I attached to my post.

The problem is: after I load my AR.Drawables into an Array (line 63), I don't know how to dynamically add new Drawables to Trackable2DObject.

I will appreciate any help you can give.

Greeting,

Diego

Hi there!

well there are different ways on how to tackle your problem. Depending on the number of images that you want to display you could think about loading them all at the beginning or loading them on demand once they are needed. 

In the first case you would load all the image resources and drawables and attach them to the trackable2dobject by adding them to the drawables.cam array of the object. You can easily toggle their visibility by setting the "enabled" property to true or false.

in the second case you need a logic that loads the image resources and drawables once the user clicks the slider. You can then also add the drawable to the drawables.cam array of the trackable2dobject.

Hope that helps,

Markus

Could you kindly provide a sample code that would do that part : "You can then also add the drawable to the drawables.cam array of the trackable2dobject."

I am not sure how I can access the array for this wikitude object

Thanks

let's say obj is your trackable2dObject and newImgDrawable is your new image. Then all you need to do is get the current array of drawables and append the new image and assign it back to the trackable2dobject's cam drawables.

var drawables = obj.drawabls.cam;
drawables.push(newImgDrawable);
obj.drawables.cam = drawables;

 
Login or Signup to post a comment