Start a new topic

onSnappedToScreen breaks my code. Please advise me why.

onSnappedToScreen breaks my code. Please advise me why.

Hi Sergey,
When do you want your video to snap? When the target image is recognized or lost?
In your code, you enable snap to screen in the onEnterFieldOfVision callback and you set the enabledOnExitFieldOfVision property to true.

Best regards




I cannot get "onSnappedToScreen" work properly with my Trackable2DObject that displays video drawable. Function specified in "onSnappedToScreen" gets never called when video drawable is snapped to screen. If I do not specify "onSnappedToScreen" then video drawable does appear and snapping does work properly when I take camera away from target image. But if I do specify the "onSnappedToScreen" then function does not get called and video drawable does not appear but does play the sound. I assume this is because of an error taking place somewhere but I do not see where the error could be with the "onSnappedToScreen" . The function which is supposed to be called onSnappedToScreen is empty and does not do anything. Where could the error be? Why does the "onSnappedToScreen" breaks my code?


I have simplified the code below to make it easier to look at.  Please advise me. 



 function MyVideoDrawable(){



  MyVideoDrawable.prototype.create = function() {



      var myco_inner = new AR.Trackable2DObject(tracker_inner, target_image_name_inner, {

         onEnterFieldOfVision: function onEnterFieldOfViewFn () {


            myco_inner.snapToScreen.enabled = false;


         video_inner = new AR.VideoDrawable(video_url_inner, scaleLevel, {


                                                 offsetX: propertiesArr,

                                                 offsetY: propertiesArr,



                                                 onLoaded: function videoLoaded() {



                                                  onPlaybackStarted: function videoPlaying () {



                                                 onFinishedPlaying: function videoFinished () {







         }, snapToScreen: {

                 enabledOnExitFieldOfVision: true,

                 snapContainer: document.getElementById(snapContainerName),

                onSnappedToScreen:   function myOnSnappedToScreen()    { }


          onExitFieldOfVision: function onExitFieldOfView() {








Login or Signup to post a comment