AR Toolkit Change Marker


I am writing an AR authoring tool with PlayCanvas, and I need to be able to change the AR marker in real time (programatically).

I am using the artoolkitmin.js script to provide AR capabilities and the playcanvas-ar.js script, which provides an ArMarker and ArCamera objects.

So far, I have been able to change the pattern (.patt) asset of the ArMarker object with this code:

var assetPattern = new pc.Asset(sMarkerPatternFileName, "binary", {url: sMarkerPatternPath,});;

    this._ARRoot.script.arMarker.width = width;
    this._ARRoot.script.arMarker.enabled = true;
    this._ARRoot.script.arMarker.pattern = assetPattern;

    var self = this;
    var onAssetLoad = function() 
        self._ARRoot.script.arMarker.pattern = assetPattern;

    assetPattern.once('load', onAssetLoad);

but it only works once. I mean, the pattern is apparently changed every time I use the code, but it only effectively recognizes a different marker the fist time I make a change.

Is it possible to change the AR marker in real time as many times as desired?
What am I doing wrong?