Problem with the Trigger Enter/Out with VR

Hey, I have a problem with triggers Enter and Out . Look at this playground : https://playground.babylonjs.com/#M779CA#14. It is for the trigger onPointerEnterObservable and Out. I don’t understand, in this PG, it is working, but on my demonstration look at the console
On PG my function work, but on VS Code, it thinks I am out when I am moving into the ellipse GUI. Do you know why ? The problem is when I am in VR. So use Firefox or edge or Safari for my version and PG.

My functions are at the line 150 in my demo. And I am agree that my test “if” is useless here ^^ it’s a copypaste ^^ but that change nothing about it thinks that I am out when I am moving into the mesh.

Here is my demo demo.zip (3.9 MB)
I use TweenLite, but I can’t send you that, it’s too big. That’s why I set rect1.top to 0px and -180px
Thank you for your time and your kindness :slight_smile:

Heya Mathieu. Um… I don’t have any VR gear… but I used the PG “goggles” button, anyway.

Have you noticed that… pointerEnter/Out… works ok, if you do it slowly? Seems that way, here.

PointerOut QUICKLY, and it seems to get stuck in “entered” (over).

I can do the same in NON-VR mode… by placing the button on left side of canvas… then pointerOut quickly to the left… onto the code-editor area. Button sticks in ‘entree’ mode THAT way, too.

Test #1: When you add plane.showBoundingBox = true; in line 54 area, do you see improvement? I do… but still testing.

Test #2: When you make plane double-sized (10) in line 52, do you see improvements? I do.

There might be a “polling” time-interval for GUI. ie. HOW OFTEN does GUI check for Enter/Out? In VR mode, the “plane” is a very small area, and we might be pointer-outing SO FAST that… the “next check” is NOT over the plane anymore.

In other words, maybe GUI must do at least ONE Enter/Out check… while pointer is OUT-of button, but MUST still be OVER the plane. If we leave button and plane too quickly, GUI has no chance to “read” an “OUT from button but still OVER plane”. GUI system might NEED an “out from button, but still over plane” -check… to shut-off the button’s OVER (to set it to OUT state). Understand?

For ease of text typing, let’s abbreviate “Out Of Button, Over Plane”… as “oobop” :slight_smile:

Comedy aside: Good song title? “Too Fast to Oobop!” heh

By making the plane bigger, or doing pointer-out more slowly, we give the GUI more time to see/sample an oobop state.

Conversely, by leaving the button (and plane) too quickly, GUI time-interval doesn’t have time to “see” (test for) oobop condition.

Just possibly, there is a way to speed-up the GUI pointer-event time intervals. Not sure.

I’m not sure if I am on the correct investigation track… but maybe. Perhaps you can do some tests… based-upon these “speed” thoughts… and see if you can verify things. Report discoveries, please. :slight_smile: (You always do, and I’m glad - it helps us all learn things.)

Perhaps we/others can do some research - to see if we can learn about pointer-test time-intervals, and perhaps speed it up a bit, with no performance problems in your low-mesh-count scene/project. It MIGHT involve the speed of the observer/observable system… which the GUI system likely uses. And also, perhaps the scene.inputManager. Thinkin’. :slight_smile:

1 Like

Hi, I don’t have problem on PG, it’s only in demo.zip. It’s weird, because the Trigger is Enter, but even when I move over the ellipse, the trigger OUT and ENTER are triggered.
NO VR : What? I have set the vr with vrHelper. ?
#test1: I have always the problem on my zip.

I have already done the trigger Enter&Out on GUI3D and it has been working well since. Maybe the ellipse and the plane are intertwined so when I am moving, the gaze of VR is confused ? and it thinks I am on the plane and not the ellipse ?
Maybe @trevordev knows ?
Thank you Wingnut, as always you are very kind and you give me a lot of explainations !

1 Like

Hey, so I don’t know why it’s not working , but I play with these triggers and I have arrived to do something , I have a little bit do the Bob the Handyman but it works :smiley: I do use now the trigger move and not Enter. If you want to check, juste comment twennLite lines and uncomment the line with console.log.
I also code for my VR interraction so firstTimeIn is not necessary
var timerin; // setTimeOut global for the trigger Move
var timerout; // setTimeOut global for the trigger out
var firstTimeIn = true; // to know if it’s the first time we are on the GUI

  ellipse1.onPointerMoveObservable.add(()=>
    {
        if(!out) // if we weren't out but because of the bug  we were ^^ 
        {
           clearTimeout(timerout);   // finaly we aren't out of the ellipse for REAL
        }
        out = false; // we are in
        rect1.isVisible = true;
        TweenLite.to(rect1,0.5,{top: "-180px"})
        
        if(firstTimeIn) // is that we were out before or already in ? It's for my interaction with VR for those    //                                   who don't have controllers
        {
            console.log("coucou")
        timerin = setTimeout(()=> {
            ellipse1.background = "green";
        }, 1000)
    }
        firstTimeIn = false; // next time we move in, we will know that we were already in before.
        
    })
    ellipse1.onPointerOutObservable.add(()=>
    {
        // after 0.1 sec out we are OUT for REAL and not because of the bug.
        timerout = setTimeout(()=>{
            out = true;
            firstTimeIn = true;
            TweenLite.to(rect1,0.5,{top: "0px"})
        
            setTimeout(()=>{rect1.isVisible = false;},300);
            console.log("bye")
           clearTimeout(timerin);
            }, 100)
        
    })

Hope it will help some people.

2 Likes

sss… So it’s working whit my mouse, but with vr is not working, sometimes, the gaze is still “in” when it is out… even If I move slowly… @trevordev @Deltakosh do you know why ?

      var timerin; // setTimeOut global for the trigger Move
     var timerout; // setTimeOut global for the trigger out

     var out = true;
    ellipse1.onPointerEnterObservable.add(()=>
    {
    /*
    if(!out) // if we weren't out but because of the bug  we were ^^ 
    {
       clearTimeout(timerout);   // finaly we aren't out of the ellipse for REAL
    }
    out = false; // we are in
    rect1.isVisible = true;
    TweenLite.to(rect1,0.5,{top: "-180px"})
    
   */
        console.log("coucou")
    /*timerin = setTimeout(()=> {
        
    }, 1000)*/

    out = false;
    rect1.isVisible = true;
    TweenLite.to(rect1,0.5,{top: "-180px"})
    
})
ellipse1.onPointerOutObservable.add(()=>
{
    // after 0.1 sec out we are OUT for REAL and not because of the bug.
   /* timerout = setTimeout(()=>{
        out = true;
        
        TweenLite.to(rect1,0.5,{top: "0px"})
    
        setTimeout(()=>{rect1.isVisible = false;},300);
        console.log("bye")
       //clearTimeout(timerin);
        }, 100)*/
    out = true;
    TweenLite.to(rect1,0.5,{top: "0px"})
    setTimeout(()=>{rect1.isVisible = false;},300);
    console.log("bye")
})

And the ellipse is on a plane with AdvancedDynamicTexture.CreateForMesh(mesh).
I have a idea, it’s maybe I set the thickness = 0 because when I set it to 4 it’s working better , but I am still testing so ^^
Maybe make the test in/out faster ? as Wing said, because I have always some issues, less but still there.

It’s weird, I think it’s only on Firefox I have this issue. I have taken my PG I posted, then I download it, then run it in Edge, no problem, after in Firefox, I have the same Issue.

But If I use a mesh, and ActionManager, the trigger Over (not enter and move, because it’s not a Gui element) is working well

@Mathieu Are you including pep.js? as described here First Steps - Babylon.js Documentation
eg. does this result in defined

if (window.PointerEvent) {
	alert("pointer events DEFINED");
} else {
	alert("pointer events UNDEFINED");
}