Action manager hover cursor changing even through walls


I posted this one on the old forum but I guess it is better to post it here.

This is my first post on this forum, so let me thank all of you for the problems you helped me with, by having them before me !

Now the question :

I have a problem using the action manager. I use it to trigger an action by clicking on objects and it works.

However I want the mouse pointer to change when I hover the object, to show that a mouse interaction is possible. To do that I use the property “hoverCursor” of the actionManager. For the main usage it works (the cursor is changing when I hover my object) but it works also trough other objects occluding the interactive object. Note that the interaction is triggered only when I click on a visible part of the object, as exepected. It’s just the hover cusor that doesn’t seem to follow the same logic.

Here is a PG reproducing my problem :
When you click on the sphere, the cube visibility changes. If you set the camera below the ground plane and hover the sphere, you can see the pointer changing, but if you click, the cube is not changing (as expected).

So the question is, how can I do to prevent the cursor from changing when an object (here the sphere) is occluded ? I want to precise that in the real scene, I have about 500 objects in this case so I am looking for a light solution.

I hope the question is clear I’m not used to ask help on forums in English.

Thank in advance for your help !

No problem :slight_smile:

You have to turn on pointer move support:

ground2.enablePointerMoveEvents = true;

@Deltakosh Thanks for your reply !

Indeed it solves the problem. However as my scene has a lot of objects, I have to loop over all the objects (at least the walls) to set this property to true, what may slow the scene loading (which is already long because of other factors, so I would like to avoid it if possible).

Is there a way to have this property set to true by default ?
As my scene is entirely loaded from a blender model exported in .babylon, is there a way to do it during the export ?

Thanks for your time :slight_smile:

Well nothing faster than simply looping all the meshes I’m afraid… :slight_smile:

Actually, after giving it a second though, you can also define your own predicate (which is used to determine if a mesh is a candidate for hit testing):

scene.pointerMovePredicate = (mesh) => {
  return === "foo";

To test your first solution I selected only the meshes that were problematic and it appears that they are not as many as I thought. So i just selected them with scene.getMeshByName() and set enablePointerMoveEvents to true as you suggested. It doesn’t seem to slow the app so much, so I can say it works :slight_smile: .

However your second solution seems pretty elegant, I will try it to see if I can improve the first one.

I mark the topic as solved :slight_smile:

Thank you for taking the time to help me !

1 Like