1

The problem

As the cursor locks, the cursor is set to the position of the screen where i clicked. But i would like to have my cursor centered to the screen. As that is not possible for security reasons, the only available option is to move the camera(maybe with lookAt) towards the cursor position.

In my example i would like that when the cursor is locked that the little gray square in the center of the screen provokes a hover. This meaning that the cursor is exactly in the center of my camera.

The reason i want to achieve this is because i would like my clicks to be performed from the center of the screen, if i for instance want to trigger the onclick of a 3D object in front of the camera.

I would like to know if it is possible to do so with the pointerlockcontrols and if yes, how could one proceed ?

What i have so far

At the time i've just tried the basic implementation of pointerlockcontrols but can't figure out the way to put the cursor in the desired position.

Unfortunately pointerlockcontrols does not work on my codesandbox example. The code sandbox that unfortunately does not work

Thanks in advance for your help.

codeanjero
  • 674
  • 1
  • 6
  • 14

1 Answers1

1

Found my answer here : Screen centered pointer lock controls

the trick is just to move the raycast to the center of the screen.

codeanjero
  • 674
  • 1
  • 6
  • 14