Created
March 4, 2019 16:35
-
-
Save dghez/2c9cd3b5d7e2cedc9069a176b9ed47cf to your computer and use it in GitHub Desktop.
Normalized mouse with center in center of the screen, for threejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mousePos = { x: 0, y: 0 } | |
| export default function (evt) { | |
| mousePos.x = (evt.clientX / window.innerWidth) * 2 - 1 | |
| mousePos.y = -(evt.clientY / window.innerHeight) * 2 + 1 | |
| return mousePos | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment