Slider on ADT on mesh rotates camera

Hi,

I assume this is a soimple fix but cant seem to get it to work. I have an ADT on a mesh and the texture has a slider control. When I adjust the slider with mouse/pointer move the pointer events are still sent to the camera so that the camera rotates. How can I disable the camera events when over a slider, other than doing an onpointerenter/exit to attach/detach the camera - or is that the way it should be done?
I have a number of slider controls.
PG: Babylon.js Playground

Adding @msDestiny14

what about this?:
https://playground.babylonjs.com/#4LYMKY#1

Not sure it’s the sexiest, but it works for me;)

Oh, and if there is a better way, I shall take it.

I’d usually attach this to a panel.

and then @msDestiny14 , if this is not the way I’d really like to understand how it should be done. Thanks in advance for your(s) amazing support.

Thanks @mawa your solution with pointer enter out observables is what i meant as the, as you describe, non-sexy solution. Even if i put them in a panel and do the observables on the panel it is not ideal as i also intend to support this in WebXR…but i guess usinge scene.activeCamera would capture that.

Interestingly, i have other sliders in a panel on another ADT that behaves well. Maybe panels do this activeCamera attach/detach by default?
Worth investigating.

This is pretty much how I would do it too. :slight_smile: if you have a lot of sliders or GUI elements that will require the same treatment just make a function call.

Fun fact this is how it works in the upcoming GUI Editor as well for dragging around the controls :wink:

Thanks @mawa and @msDestiny14, if I use a rectangle as an container then I can put the attach/detach in observables for the rectangle (or any other container such as grid etc).

I had to add a check for if the pointer was down when entering the panel because there was undesireable behaviour if not, ie if the user was scrolling the camera and the pointer entered the panel then scrolling would stop unexpectedly. This PG takes care of that situation: https://playground.babylonjs.com/#4LYMKY#2
There might be a nicer way to do it but this gets the job done.

1 Like

Yes that would work. I did it at least once.

In my opinion, the only nice way is when it works :relieved: And BJS is pretty versatile when using this approach. Quite amazing, actually. GL with your project and have a great day, :sunglasses:

thanks for the insider info. I now know I should expect a reworked GUI. Sounds yummy :smiley:

Yep, I agree. There is however still a problem but I cannot reproduce it in the PG. Sometimes when I leave the rectangle the camera’s control is not being reattached, it is like it drops the onPointerOut event or something is handling it and stopping it from propagating. It must be a timing thing as it happens only rarely.

Right. I hear you. I kind of remember a similar issue I had but on handling the mouse scroll on a scroll viewer. Let me see if I can find this part again. It isn’t on mobile, yes? You are not loosing context, right?

I haven’t tested it on a mobile yet, so far just on PC browser. I don’t think i lose context because when it happens if i just move the mouse over the rectangle and out again then the camera controls do get reattached.

Yes, give me a minute. I might have added a pointerDown event (although pointerDown is know as not being returned by all browsers). Or I might have given an additional parameter to the camera to make sure it resets. Did you add a console log like ‘in’ and ‘out’ to check if the in and out is accounted under all circumstances? Search underway…

Oh, just realized. Did you also attach it to your controls? Because the controls come ‘on top’ of the (so-called) panel (in this case a rectangle). It also comes ‘on top’ when using i.e. a stackpanel. So, admitting you would quickly move from your control area on top of the panel (rectangle or stackpanel) and then in ‘scene’ or ‘viewport’ the transition might mess it up. If you haven’t done this yet, attach it to both (controls and panels) and check again…

Ok, just checked again and I’d say you are likely facing the issue I tried to explain above (sry, I’m not a teacher, sometimes my explanations are ‘cumbersome’ (as per my ex-wife who is a teacher;)
Let’s assume your panel (detected area for mouse in and out) which hosts your controls with no or little padding. When you’d move the mouse (on desktop) from your control quickly to your scene (just quickly in ms passing over the (in this case) rectangle, it would detect that you have moved out of your control (but not out of your rectangle or area for detection). Can you please check that and come back to us?

Thanks. Yes i understood your previous description, it makes sense. I will try tomorrow. We are presumably in different timezones, it is 8pm here and i have knocked off. About to reach for a wine so wise to stay away from the keyboard :slight_smile:

Oh, are you an OZ? If so, please tell Health Australia, I do not have covid and would like to go back to my winter/summer retreat in Byron Bay;) Else if you are US west-coast, please let the cook know that I’m still waiting on getting my awesome t-bone steak. The meat here in Switzerland, is just terrible;) Good night and things will likely become clearer after a good rest (it works for me, …most of the time;)

Yeah I am in Oz (BrisVegas at moment). I don’t think i have much influence with Health Australia. :slight_smile:

LoL! Cheers. I actually don’t think your governance as much influence with Health AU;) Good night and cya later,

1 Like