Start a new topic

Clean way to define various Trackable2DObjects

Clean way to define various Trackable2DObjects


I found it.

also at http://pastebin.com/0RytLQQ9



function createTracker(){



                for(var i = 0; i < molecules.length; i++)



                    var trackable2DObject = new AR.Trackable2DObject(leftTracker, molecules, {onEnterFieldOfVision: toSeeMolecule(molecules), onExitFieldOfVision: toUnseeMolecule(molecules)});



            }



           



            // IR functions //



           



            function toSeeMolecule (molecule)



            {



                return function () {



                    appendStatus("Recognized " + molecule);



                                   



                    loadMolecule("models/molecules/" + molecule + ".pdb");



                    if(!leftOccupied) nMoleculesShown++;



                    appendStatus(nMoleculesShown);



                    leftOccupied = true;



                };



            }



           



            function toUnseeMolecule (molecule)



            {



                return function () {



                    appendStatus(molecule + " is gone but I'm keeping the 3D around!");



                };



            }



 

Hi all,

I have an ImageRecognition dataset with multiple images in it. Currently, my code initializing the trackable2DObjects looks like this:

trackable2DObject = new AR.Trackable2DObject(leftTracker, "Water", { onEnterFieldOfVision: seeWater, onExitFieldOfVision: unseeWater});                

trackable2DObjectTwo = new AR.Trackable2DObject(leftTracker, "Carbon_Dioxide", { onEnterFieldOfVision: seeCarbonDioxide, onExitFieldOfVision: unseeCarbonDioxide});

 

Isn't there a way to avoid this ugly, hardcoded code?

 

Can't I create an array of and two generic seeImage(param) and unseeImage(param) functions and still have the same functionality? Ideally, my list of images is dynamic. Furthermore, I hate my current hardcoded lines and code duplication.

 

Thanks in advance!
Login or Signup to post a comment