PickedMesh is null in onPointerObservable after update to 6.25.0

Hi all,

Since upgrading to 6.25, my pointerevent is not returning any meshes? has anything changed in this update?

Weirdly, If I add the inspector to the scene (import(“@babylonjs/inspector”)), my pointerEvents do start working and return the picked mesh? Am I missing something obvious?

6.24 is working fine with or without inspector.


Which pointerevent are you using? Can you set up an out of playground repro, if possible? I’ve tried with pointerpick and the pointer observable but it looks ok here.

Would be great to get a reproduction!
It might be a missed side effect, which means that it might work on the playground but not when using imports

I can’t seem to reproduce that. Can you make sure you are loading the Ray file as a side effect? import "@babylonjs/core/Culling/ray";? Could that be the issue?

1 Like

I call scene.onPointerObservable.add(...) in a number of places and noticed no changes. My pickedInfo.pickMesh contains values.

Am using UMD, so the import “thing” is probably a good lead.

Hi @RaananW. Importing import "@babylonjs/core/Culling/ray"; solved my issue, thank heaps! :slight_smile:

In the future, is there any way I could find that out by myself? Or is this case by case?

1 Like

In most cases you will be notified by the framework itself. Most of those side effects are documented here -

However, in this case, since it is a function that is constantly called (the pick function), we didn’t want to throw an error or pollute the console with warning messages. I’ll try thinking of a smart(er) solution so it will be clear in the future.

My rule of thumb is to try and import once from @babylonjs/core (without any file). If that helps to resolve the issue, it is a tree shaking / side effect problem . importing directly from @babylonjs/core will practically import the entire framework and will tree shake very poorly.

1 Like

Understand, I will keep that in mind, thanks for the clarification :wink:

1 Like

Suggesting a solution here - Warn about missing dependency, but only once by RaananW · Pull Request #14477 · BabylonJS/Babylon.js (github.com)

That seems like a very reasonable & useful solution. Thanks.

1 Like