Utility layer events propagated into the scene

Hello,

so we updated our project to Babylon 5 and we encountered some problems.
After some time, I managed to isolate the issue, so here I am :slight_smile: :

If you open this playground with latest babylon and click on the sphere, you’ll see a console log click event emitted on the scene

If you switch to version 4, this is no longer true.

Does anyone know whether this is a bug or a feature?

If it’s a feature, how can I ignore the scene pointer events when a mesh in utility layer was picked in babylon 5?

I have some ideas, but I would love to hear from the experts :scientist:

Thanks!

1 Like

let me add @PolygonalSun our input expert to the thread

So from what I can see, clicking on the sphere will return picking information that shows either a hit on the ground if your cursor is over the ground mesh or null if it’s not. The sphere is not pickable through scene.onPointerObservable so that’s a at least a good sign. As far as why there’s a behavior change, I’m not sure. I’ll have to investigate and see what’s happening.

Thanks! Maybe I’ll just provide some extra information why we need this:

We use the utility layer to draw some control points on the scene:

  • clicking on the scene ground creates a new point (that’s why we listen to scene.onPointerObservable).
  • clicking on the point removes the point (we use ActionManager for that).

This worked nicely in version 4.
In version 5, when I click on the point, it will get removed, but a new point will be created immediately after that :slight_smile:

We also have problems with PointerDragBehavior on these points, but I suspect the root cause is the same.

Hello,
@PolygonalSun sorry to bother, but do you have any news here?
Just wanted to know whether you guys are going to change it back to original behavior, or I’ll just deal with the new one somehow :construction_worker_man:

Thanks!

Hey @MichalZr,

Sorry about the delay in response. I haven’t been able figure out the root cause on this one. As far as I’ve found whatever caused this change in behavior has been happened during one of the early 5.0 alpha pushes (prior to our repo refactor). I’ll keep digging and once I have something, I’ll let you know.

Hey, I just wanted to give an update on this. After talking with the team, I was able to find that the issue was related to when the pointer’s event information was being handled vs when the utilityLayer’s scene handles things. As it turns out, the utilityLayer does everything within the prepointer observable and pointer handling was being “released” after that point so there’s a bit of a timing mismatch. While I can address that, there’s another issue that I have to figure out before I could release a fix. That problem is, when the mouse is clicked on the active scene and released on an element in the utilityLayer scene, it can cause the pointerup event to not be received properly. That’s what I’m curently working on fixing.

Interesting reading. I wouldn’t have thought of that. Thinking back about some issues I had in my projects with multiple utilityLayers, it now kind of rings a bell for me. I hope you’ll find a solution for it. It would definitely be a nice fix :smiley:

@PolygonalSun just checking, any updates on this?

Hey, sorry I have no updates yet.

Actually, from my understanding @Evgeni_Popov is about to look into this management of utilityLayers. We might just add this thread to it (sry for the additional load) :grin: :wink:

Actually no :slight_smile:

@PolygonalSun is the king of everything related to inputs so the issue can’t be in better hands!

2 Likes