Start a new topic

onSnappedToScreen breaks my code. Please advise me why.

onSnappedToScreen breaks my code. Please advise me why.


Hello! 

 

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,

                                                 zOrder:1,

                                                 isTransparent:isVideoTransparent,

                                                 onLoaded: function videoLoaded() {

      

                                                  },

                                                  onPlaybackStarted: function videoPlaying () {

 

                                                },

                                                 onFinishedPlaying: function videoFinished () {

 

                                                  }

                                                }

                                                );

 

 

         }, snapToScreen: {

                 enabledOnExitFieldOfVision: true,

                 snapContainer: document.getElementById(snapContainerName),

                onSnappedToScreen:   function myOnSnappedToScreen()    { }

        },

          onExitFieldOfVision: function onExitFieldOfView() {

           }

     });

 

  }

  

 

   

 

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

Andreas

Hi Andreas! 

Thank you very much for your reply. In the onEnterFieldOfVision I am not "enabeling" but rather "disabeling" the snapToScreen because in my onEnterFieldOfVision I set the snapToScreen to "false". And I thought this is the right way to do it. 

 myco_inner.snapToScreen.enabled = false;

and then I set the enabledOnExitFieldOfVision to true and expect the myOnSnappedToScreen() function to be called right after the video drawable spans to  a snapContainer. But the function myOnSnappedToScreen does not get called even though video drawable does get snaped to a snapContainer when camera view is taken away from target image. 

When user decides to take camera view away I need myOnSnappedToScreen() function to be called right after video drawable gets attached to a snap container. When myOnSnappedToScreen() gets called I want the "Close" button to appear so that user can close the snapped to screen video drawable. But the way it works now is: Target image is recognized and video drawable starts playing video. Then user takes camera view away and video drawable gets attached to a snap container. Except the javascript function myOnSnappedToScreen() does not get called. 

What do I do differently? 

 

 

Hi Sergey,
Thanks for your continuous feedback regarding the Wikitude SDK. You found another bug ;)

I already fixed the problem and we will release the next Developer Channel Release on Monday. If you need earlier access, I can send you a SDK tomorrow evening that fixes the issue.

Thanks again for your feedback!

Best regards

Andreas

Andreas, thank you very much for your message! 

Yes, please, if you can share an SDK with me earlier than Monday, I will be very thankfulll! I guess you can do it already tonight?

Thank you Andreas! 

Sergey

 

 

Hi Andreas!

Just wanted to learn if you can already share with me an updated version of SDK with this issue fixed? 

Thank you Andreas!

Hi Sergey,
Sorry for my late response but the good news is that as I'm typing the SDK 4.0.2 build is running and I'll send you a link later today (around 16:00 CET). We already have your email address ;)

Best regards

Andreas

Have you guys fixed this bug yet? I'm using the latest version of Wikitude and the onSnappedToScreen function still doesn't get called.

Also, your HTML/JavaScript API documentation is really hard to find. You should consider linking it directly from the developer menu.

Also, your AR.logger error messages are... unhelpful. It tells me texture memory exceeded but doesn't give me a stack trace or any information about what exactly failed to load, or how much texture memory was available, or anything really. Just "texture memory exceeded" and I'm left fumbling around in the dark wondering what I'm doing wrong. And any other kind of JavaScript error, again has no stack trace, so I'll get some arbitrary error and no idea what caused it without having to paste log messages all through my code.

Also, you should add the snapToScreen functionality to your demo app (or if it's there, I couldn't find it, if so, my bad I guess?). All in all, this piece of functionality really kinda feels untested. Seeing as you're advertising it as a feature, it'd be nice to see you build a serious demo around, utilising a number of different snappable targets.

Also, the latest Wikitude crashes on my iPhone 4S, with iOS7, when I try to access the menu. I have rebooted the phone and tried everything I can think of. Unfortunately, this means I can't test my world on my iPhone. Not sure if this is a known issue.

Hi Nathan,

Thx for your feedback. To your points:


Have you guys fixed this bug yet? I'm using the latest version of Wikitude and the onSnappedToScreen function still doesn't get called.

: we are not aware that this isn't fixed. If you have issues there, please send us your code snippet(s) (or even your project if you're allowed to provide us with it - pls. send it to forum{at}wikitude.com)

Also, your HTML/JavaScript API documentation is really hard to find. You should consider linking it directly from the developer menu.

: we're in the process of improving the documentation, so this will be taken into consideration

Also, your AR.logger error messages are... unhelpful. It tells me texture memory exceeded but doesn't give me a stack trace or any information about what exactly failed to load, or how much texture memory was available, or anything really. Just "texture memory exceeded" and I'm left fumbling around in the dark wondering what I'm doing wrong. And any other kind of JavaScript error, again has no stack trace, so I'll get some arbitrary error and no idea what caused it without having to paste log messages all through my code.

: we're in the process of improving the logging as well

Also, you should add the snapToScreen functionality to your demo app (or if it's there, I couldn't find it, if so, my bad I guess?). All in all, this piece of functionality really kinda feels untested. Seeing as you're advertising it as a feature, it'd be nice to see you build a serious demo around, utilising a number of different snappable targets.

: we have 2 snap-2-screen samples in our sample app (snapping video and snapping 3D model)

Also, the latest Wikitude crashes on my iPhone 4S, with iOS7, when I try to access the menu. I have rebooted the phone and tried everything I can think of. Unfortunately, this means I can't test my world on my iPhone. Not sure if this is a known issue.

: I just tested with our iOS devices (both iOS7 and iOS8) and can't reproduce this issue with the Wikitude app. Can you please provide me with detailed steps to reproduce.

Thx and greetings

Nicola

Thanks for your reply. I've included a snippet of my code below, but it's worth noting that none of the sample world scripts in Wikitude's Github repository make use of the onSnappedToScreen event. In my code, I am very clearly achieving a snap event, and my onSnappedToScreen function does not get called at all. I've tried everything I can think of to get it to be called, but nothing works. I'd suggest updating the samples with code that verifies that the bug is actually fixed, which as a bonus (once fixed) will give a sample of that event for people to try out and for you to point people at when they're having trouble.



var overlay = new AR.Trackable2DObject(tracker, name, {

    drawables: {

        cam:

    },

    snapToScreen: {

        enabledOnExitFieldOfVision: true,

        snapContainer: snapFrameElement,

        onSnappedToScreen: function(e) {

            AR.logger.info('Video snapped: ' + name); // This line never runs

            if(video.play) video.play();

        },

    },

    onEnterFieldOfVision: function() {

        onOverlayEnteringFieldOfVision(video, name);

    },

    onExitFieldOfVision: function() {

        onOverlayExitingFieldOfVision(video, name);

    }

});

 

 

Hi,
You can verify the 'onSnappedToScreen' functionality by added a snapped function to the e.g. snapping 3d model. Just replace (beginning in imagerecognitionand3d.js line 107) the Trackable2dObject creation with the following snippet and you should see a JS alert. Please verify that you have the SDK 4.0.2 running!

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

drawables: {

cam:

},

snapToScreen: {

snapContainer: document.getElementById('snapContainer'),

                onSnappedToScreen: function() {

                    alert('snapped');

                }

},

onEnterFieldOfVision: this.appear,

onExitFieldOfVision: this.disappear

});

 


Best regards

Andreas

Andreas, right before your reply is my own reply, illustrating that I have already done that, to no avail. Unfortunately, for some reason the post is hidden unless I'm logged in, which suggests I'm either silenced, or the post is awaiting moderation or something. I have no idea if you can see it, but given that your post suggests that I do something I've already done, I'm guessing I'm the only one who can see it.

In any case, onSnappedToScreen doesn't work. If you could update one of your github demos and include that event in order to verify that it does in fact work, then we can resolve this because I'll have evidence of code that is successfully triggering that event, but as best I can tell, I am declaring it exactly as the documentation says to do, and the overlay does successfully snap to the snap container as it should, and yet the onSnappedToScreen event never fires.

Hi,

Can you please send us your complete (buildable and runnable) project, so we can have a look where the issue is in the code directly. Please send it to forumwikitude.com.

Thx and greetings

Nicola

I only downloaded the current iOS package from our website and modified the 3d snap to screen sample with the snippet I posted before.

Do you use our SDK 4.0.2?

Best regards

Andreas
Login or Signup to post a comment