Start a new topic

addImageTargetCamDrawables is not a function

Looking at the documentation for tracking multiple targets, there are references to this.addImageTargetCamDrawables. However, this function doesn't seem to exist. I tried using AR.ImageTrackable.addImageTargetCamDrawables as well and that doesn't exist either.


https://www.wikitude.com/external/doc/documentation/latest/android/multipletargets.html#multiple-targets


What should be used instead?


Thank you in advance!


Hi Eric,


please try your AR-Experience in our cordova sample app to check if the same issue is happening there.

Based on your Screenshot it seems to me that an older version of architect.js(the file including the AR.ImageTrackable) is used.


Best Regards,

Alex

So it was a false positive. There was a cached version of a different code so it seemed like the fix worked but it didn't. The scoping fix didn't work and it seems like it is because the function addImageTargetCamDrawables isn't part of ImageTrackable as it's supposed to. Here is a screenshot of the debug output and it shows the other expected properties and functions for ImageTrackable except addImageTargetCamDrawables and removeImageTargetCamDrawables.


image


Hi Alex,


Ah yes, that works. Knew it was something silly. Thank you much for the help!


Best,

Eric

Hi Eric,


please note that when using javascript arrow functions (=>{}) the scope is limited.

In your case "this" is not the trackable because of this you get the TypeError. 


To fix this i would suggest you use anonymous functions instead.

 

trackable = new AR.ImageTrackable(this.tracker, '*', {
    onImageRecognized: function(target) {
        var model = new AR.Model("assets/models/" + target.name + ".wt3");
        this.addImageTargetCamDrawables(target, model);
    },
    onImageLost:  function(target) {
        this.removeImageTargetCamDrawables(target);
    },
    onError: function(err) {
        alert(err);
    }
}); 

 

Best Regards,

Alex

Hi Eva,


Sure thing. It's using SDK 7.1.

https://github.com/Wikitude/wikitude-cordova-plugin.git#88861f0


Thank you,

Eric

Hello Eric,

Could you also tell me the the SDK version? Are you working for example, with our SDK 7.1?

Thanks
Eva

 

Hi Eva,


Wikitude-cordova-plugin within an Ionic environment.


Thank you,

Eric

Hello Eric,

Can you please tell me which SDK version you are testing with? Because this is exactly how we have it in our samples and it is working there.

Thanks
Eva

 

I'm still getting an error that the method is not a function. I'm probably missing something silly but the following doesn't work:

   

trackable = new AR.ImageTrackable(this.tracker, '*', {
    onImageRecognized: (target) => {
        var model = new AR.Model("assets/models/" + target.name + ".wt3");
        this.addImageTargetCamDrawables(target, model);
    },
    onImageLost: (target) => {
        this.removeImageTargetCamDrawables(target);
    },
    onError: (err) => {
        alert(err);
    }
}); 

Exact error: 'TypeError: this.addImageTargetCamDrawables is not a function.'

Hi Eric,

If you go to the link I posted above and choose Methods, then you will see the method addImageTargetCamDrawables. Please see the screenshot below

image

Thanks
Eva

 

Hi Eva,


Thank you for the response. Perhaps I'm not seeing correctly but there's no mention of that method 'addImageTargetCamDrawables' on that page. Is it replaced by the 'drawables: { cam : circle }' assignment? If so, how should the new drawable be added when 'onImageRecognized' is fired?


I tried a few different ways, such as 'this.drawables.cam = [circle]', but it didn't work.


Thank you,

Eric

Hello Eric,

There was an error with the link in the documentation. Please refer here to find all the information provided regarding the addImageTargetCamDrawables method.

Thanks
Eva

 

Login or Signup to post a comment