You have either attached the drawable "weatherWidget" to a AR.GeoObject or AR.Trackable2DObject depending on if you are using Geo based AR or image recognition.
Both of these objects have an onEnterFieldOfVision trigger property that you can assign a function to. This function will be executed when the object becomes visible in the field of view.
Here is a quick example for doing what you asked assuming you are using image recognition.
var trackable2DObject = new AR.Trackable2DObject(tracker, "car", { drawables : { cam : weatherWidget }, onEnterFieldOfVision: function() { // called if the target is recognized weatherWidget.evalJavaScript("startAnimation()"); } });
For this to work your splash/Spritesheet.html should have a global javascript function called startAnimation that actually starts the animation.
W
Wolfgang Damm
said
over 9 years ago
You can use the AR.Trackable2dObject's onEnterFieldOfVision and onExitFieldOfVision triggers to start and pause the animation whenever a target is recognized (onEnter..) or is lost (onExit...).
See the JS API Reference that comes with the SDK for details on the API. Examples that make use of the enter/ExitFieldOfVision triggers is e.g. the Video Example 6-2.
Wolfgang Damm