Actual pointer position

Hi there fabulous Babylon people on a Sunday where we all chill, or follow our passion in 3D!

I am using the solution of this thread: Bring reticule (crosshair) in front of GUI

Now I see that the actual clicking point is still where the mouse cursor was when entering the screen lock.

Is there a way to actually move the pointer to the crosshair?

Here’s the demo in it’s current version: Alex Furer - VirtueAlley™ - THE virtual gallery

I moved it out of the playground because I am now doing all this html stuff.

Thanks & cheers,

Could you make a smaller repro in the playground ? I am not sure to fully get the issue ?

Thanks @sebavan!

I can try to make it work again in a playground. But maybe following helps understanding my issue.

I have implemented a sphere at the figures feet that has a highlight shader attached when the mouse pointer is above it.

Here’s a video of what I mean.

Notice that when you click on the crosshair starting off, the pointer will be with the crosshair and the sphere highlights when you move the crosshair above the sphere.

But when you click besides the crosshair, starting off, the sphere will only highlight when the pointer is above the sphere, including the same distance you initially clicked.

It seems as if the pointer location is stored when I click at the location inside the canvas when clicked.

What I would like is that the pointer location snaps to the crosshair. 50% from top and 50% from left inside the canvas.

why using the mouse for that? If you want to pick from the center you can either use scene.pick manually or simulate a pointerdown, move or up with:
Babylon.js Playground (


Thanks for the input and the valuable demo. I will study it more in depth.

At the end of the day it will be the images the user will click to get a larger version in a modal. In fact that already works. And the choice from using the mouse is firstly, because I also intend a mode where the pointer is not locked and secondly because clicking the mouse is like shooting, also selecting and the user is already using the mouse to point/aim. I was thinking about using space to select, but that’s not that obvious.

Hello @alFrame just checking in, has your question been answered?

1 Like

Hey @carolhmj thanks for reaching out. It sort of has. I am not sure what answer to set as solution so I am posting my final result: Alex Furer - VirtueAlley™ - THE virtual gallery

This is as far as I got with my limited programming skills. I am now taking a look at the BJS Editor.

1 Like

That’s an amazing result! If you haven’t already, feel free to post it in the Demos and projects section! :smiley:

1 Like

Thank you @carolhmj I will!

1 Like