Skip to content

Instantly share code, notes, and snippets.

@dghez
Created March 4, 2019 16:35
Show Gist options
  • Select an option

  • Save dghez/2c9cd3b5d7e2cedc9069a176b9ed47cf to your computer and use it in GitHub Desktop.

Select an option

Save dghez/2c9cd3b5d7e2cedc9069a176b9ed47cf to your computer and use it in GitHub Desktop.
Normalized mouse with center in center of the screen, for threejs
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