Camera can not rotate when cursor end inside gui

My app is in mobile h5 platform. I use Freecamera, so when I touch and move on the screen , the camera will rotate. The problem which occurs ONLY ON MOBILE platform is that, when I touch screen outside GUI area, and then move into GUI area, then stop touching the screen, the camera’s rotation will not response to my touch anymore.

But you said you are moving the camera by touching in the screen (root), yes? Or do you have another way of controlling the camera in the scene?
Usually for mobile, you would check whether the touch is made on a GUI control or on the root. If you touch outside the GUI, your scene camera should be working and the GUI (i.e. scrollviewer) should be blocked. And the other way round.

cc @PolygonalSun, there have been some input changes lately, maybe it’s related.

Did you try with an earlier version of Babylon (like 4.2.1)?

1 Like

I think this might be the problem , I had 2 cameras, one is FreeCamera which control camera rotation by its inside function. The other camera shows GUI, when my finger leave screen on gui, the gui camera consume the event so that the FreeCamera can not response to the event ? Is this the cause of problem?

you mean by sliding the finger without releasing it from the screen? If so, yes, because you would need to release and touch again on the root (else you are still in the GUI). Though it would be kind of annoying in my opinion, if when you would move your finger slightly out of a gui container (i.e. a slider or a sv), the camera on the gui would straight freeze and the scene camera become active again.
I’m not sure what would be the best behavior. I guess it depends on the design. The main issue here on mobile is that enter and out cannot be used. I believe you would need to add a custom behavior and if so I would likely have any scrollviewer or slider inside a container with a padding so that the camera does not instantly switch to the scene when you move your finger a little bit beyond the control (which I believe would not serve the UI)-

Edit: Sry, I did just read the title of your post again and realized your issue is the other way round, is it? :wink: What you are saying is that when you touch in the scene to act with scene camera and move your finger over a GUI control, the scene camera looses context, correct? Well, this part can be fixed quite easily. You can set ‘isPointerBlocker = false’ on your controls and containers that do not come with this default. By default, i.e. a textBlock IS a pointer blocker, same as a button. I.E. a rectangle shouldn’t be blocking pointer events.

2 Likes

Yeah, this could work somehow, but there are many buttons and I can’t set the button’s isPointBlocker to false as such they will not work anymore

Ok ,I was wrong. IsPointerBlocker does not affect its own response to interaction

1 Like

advancedTexture.getDescendants().forEach(function(control) {
control.isPointerBlocker = false;
});

All GUI interaction happens at the onPrePointerObservable level (before the actual input handled by the non-GUI scene elements like the Camera and any observers linked to scene.onPointerObservable). What isPointerBlocker will do is to set a flag on the pre-pointer observer to skip its associated onPointerObservable call (eg. isPointerBlocked on a down event will skip the non-gui down event handling associated with it like starting camera movement). If this is false, it will do whatever interaction is there behind the gui element.

1 Like