Start a new topic

Coding Problem - nothing happen after 15 Trackables

Coding Problem - nothing happen after 15 Trackables


Hello,

I have a main menu with 10 submenus. Each submenu tracks other Trackables. The submenu "Nomen" ist the biggest one with nearly 150 different trackables. My problem at the moment is following.

If I start a submenu, everything runs well for 15 Trackables. After that the trackables will not detected anymore. If I go back to the main menu and start the submenu again, everything runs well again for the next 15 Trackables.

Is this a problem with the memory of the device?

Below the code!

THX for your help!

Max

var wtcFilePath = 'assets/adjektive.wtc';

var videoFilePathPrefix = 'assets/AdjektiveVideo';

var videoFileSuffix = '.mov';

//var cacheSize = 1;

 

var World = {

    

loaded: false,

init: function() {

    // Momentaner aktiver Index (Target Index = Video Index)

    World.currentTrackableIndex = 0;

    // Momentan aktives Video

    World.currentVideoUrl = '';

    // Momentanes VideoDrawable

    World.currentVideoDrawable = null;

    

    // Tracker initialisieren mit .wtc file

    this.tracker = new AR.ClientTracker(wtcFilePath, {

                                        onLoaded: this.worldLoaded

                                        });

    

    // Trackable initialisieren

    World.trackable = new AR.Trackable2DObject(this.tracker, '*', {

                                               // Callback wenn Kamerasucher Target-Image erfasst (trackableIndex = Index des Targets im .wtc File)

                                               onEnterFieldOfVision: function(trackableIndex) {

                                               //alert(trackableIndex);

                                               // Hat sich der Index verändert (anderes Target-Image)?

                                               if (trackableIndex != World.currentTrackableIndex) {

                                               World.currentTrackableIndex = trackableIndex;

                                               //alert('video set to ' + trackableIndex);

                                               

                                               if(World.currentTrackableIndex != 0)

                                               {

                                                    World.trackable.drawables.removeCamDrawable(0);

                                               }

                                               

                                               // Setze Url des neu zu ladenden Videos

                                               World.currentVideoUrl = videoFilePathPrefix + trackableIndex + videoFileSuffix;

                                               // Erstelle neues VideoDrawable

                                               World.currentVideoDrawable = new AR.VideoDrawable(World.currentVideoUrl, 0.47, {

                                                                                                 offsetY: 0.09,

                                                                                                 // Callback wenn Video geladen

                                                                                                 onLoaded: function videoLoaded() {

                                                                                                 //alert('Video geladen mit Index ' + trackableIndex);

                                                                                                 

                                                                                                 // Füge VideoDrawable der Kamera des Trackable hinzu

                                                                                                 World.trackable.drawables.addCamDrawable(World.currentVideoDrawable);

                                                                                                 // Video abspielen

                                                                                                 World.currentVideoDrawable.play(-1);

                                                                                                 

                                                                                                 }

                                                                                                 });

                                               

                                               // Mehr als <cacheSize> Videos geladen?

                                               /*if (World.trackable.drawables.length > cacheSize) {

                                               // Ältestes geladenes Video entladen

                                               World.trackable.drawables.removeCamDrawable(0);

                                               }*/

                                               }

                                               // Index hat sich nicht geändert

                                               else {

                                               // Spiele momentan geladenes Video

                                               World.currentVideoDrawable.play(-1); // von vorne

                                               //World.currentVideoOverlay.resume(); // von letzter Position

                                               }

                                               },

                                               // Callback wenn Kamerasucher aktuelles Target-Image verlässt (trackableIndex = Index des Targets im .wtc File)

                                               onExitFieldOfVision: function(trackableIndex) {

                                               // Video pausieren

                                               //World.currentVideoDrawable.pause();

                                               //alert('onExitFieldOfVision ' + trackableIndex);

                                               }

                                               });

},

worldLoaded: function worldLoadedFn() {

    document.getElementById("loadingMessage").remove();

}

};

World.init();

Hi Markus,
Your code snippet does not contain any call to a AR objects .destroy() function, so it might actually be the case that you're facing some kind of memory issue.
Please keep in mind that you need to destroy any AR objects once you don't need it anymore. This is not done in the background for you, so you need to have a .destroy for each new.

Please try to update your implementation and post the outcome, so that we can discuss next steps if the problem still occurs.

Best regards

Andreas
Login or Signup to post a comment