Start a new topic

Caching and Destroy Mechanism

Caching and Destroy Mechanism


I have a small AR product with a different amount of trackables and videos.

I made following code and it works. Sometimes (if there are a lot of trackables e.g 45 in the code below) some videos does not work. I think it´s a performance problem.

Someone told me it´s necessary to install a caching and destroy mechanism for the videos - but I have no idea.

Maybe someone can help me  - this would be great!




var iC = 45;

var vN  = 'assets/AdjektiveVideo';

var tN  = '';


var World = {

    loaded : false,

    init : function initFn() { this.createOverlays(); },

    createOverlays : function createOverlaysFn() {

        this.tracker = new AR.ClientTracker("assets/", { onLoaded: this.worldLoaded });


        World.overlays  = ;

        World.trackables  = ;

        for (var i = 1; i<=iC; i++) {

            World.overlays  = new AR.VideoDrawable(vN+i+'.mov', 0.47, { offsetY: 0.09});

            World.trackables = new AR.Trackable2DObject(this.tracker, tN+i, {

                                                           drawables : {cam: },

                                                           onEnterFieldOfVision: (function (x) {

                                                                                  return function(e) { };


                                                           onExitFieldOfVision: (function (x) {

                                                                                 return function(e) { World.overlays.pause() };





    worldLoaded : function worldLoadedFn() { document.getElementById("loadingMessage").remove();}




Hi there!

Approaches for caching and asset-loading highly depend on your usecase.
I can give you some hints, but implementation needs to be done by a JS developer

- Do not load all videos at once, your code loads all videos on start-up which will result in loading issues and high network traffic. Recomendation: Use wildcard as targetName ("*") and load the video of the recognized target on demand

- If you already know that scanning e.g. page #1 and #10 is very common, load (only) those videos on startup

- Remember the video you recognized the last time and destroy its assets once a new target was recognized. That way you have assets in place after target got los and is scanned two times in a row but you free memory when you already know that the user most likely won't scan a target twice

- Use AR.Trackable2DObject's add- and removeCamDrawables functions to update augmentations of current scene instead of creating Trackable2DObjects per target-image

Hope this helps,

Best regards,

Login or Signup to post a comment