Utility layer events propagated into the scene


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:


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.

@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:


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!


Hey there! Any update about this issue? :sweat_smile:

@PolygonalSun do you have any free cycles to look at this?

Sorry, I haven’t had any luck with this yet but I should have a little time this week to see if I can figure out what’s going on.


I think that the problem i encounterd in my scene is related to this, when I trigger the gizmo in an other utility layer (moving an object) and switch back to the main layer (where there isn’t the gizmo) I can click on the invisible gizmo and drag more my object even if that gizmo is correctly in the other layer, it happens only after I trigger the gizmo moving the object (in the other layer).
Maybe it can help to solve this or let you know about something related idk.
Thanks for all your work!

I’ll just say that we resolved the issue in our project by getting rid of the utility layer altogether.
We use a separate rendering group to render our gizmos on top of other objects and that’s really all we needed.
Maybe this’ll help you

1 Like

Unfortunately I can’t easily use that method in my scene, I fixed it disposing and resetting the gizmo and all its components when the viewport changes.
Still hoping for a patch about this later on anyway :sweat_smile:

Hey, sorry that this took so long to find a fix. The issue was an incredibly subtle one to find but I am currently testing a fix. If I don’t find anything weird in the edge cases, all that’s left is to just create a quick test for it and create the PR. I’ll let you know when the PR is live.