Start a new topic

Accessing imageDrawables after instantiating

Accessing imageDrawables after instantiating

Is there anyway to actually retrieve property values set after initializing an imageDrawable? I'm trying to change the opacity of an image I draw after the user has reached certain distance. I tried pushing my image drawable to an array or object to later call that element and change the value but it proved unsuccessful. Inside my createOverlays I tried this:


var overlayOne = new AR.ImageDrawable(imgOne, 1, {

                                              offsetX: -0.15,

                                              offsetY: 0,




and inside my Tracklabe2DObject I tried this:


var pageOne = new AR.Trackable2DObject(this.tracker, "*", {

                                               drawables: {

                                                    cam: references




But it doesn't work. Cam would only take the actual element by itself and not the one from the array. Any direction or suggestion is mroe than appreciated.





I'm an idiot! I wasn't referencing the variable on the right scope. Instead of doing: 

cam: references


I should have done:

cam: World.references


It works now!

Hi Mauricio, are you able to dynamically change the image's opacity after it has loaded?

I am trying to do something similar using a slider to adjust its opacity but for videoDrawables. I wasn't able to get it to change opacity without recreating the video (which restarts the video)

my current code is something like this, which doesn't work :(

updateOpacityValues: function updateOpacityValuesFn(){
World.video1Opacity = $("#panel-opacity-slider").val();
World.video1.opacity = World.video1Opacity;


nvm, noob mistake :) forgot to parseFloat

World.video1.opacity = parseFloat(World.video1Opacity);


Ha ha ha nice! Make sure you can expose your variables. Either by storing them in objects or arrays so taht you can fully use JS outside or the World object literal. Would make your code look cleaner.


Best of luck!


Login or Signup to post a comment