Skip to content

Instantly share code, notes, and snippets.

@anthonypena97
Created January 6, 2022 07:27
Show Gist options
  • Save anthonypena97/3ab82bf1a51688bf782825f13a689f73 to your computer and use it in GitHub Desktop.
Save anthonypena97/3ab82bf1a51688bf782825f13a689f73 to your computer and use it in GitHub Desktop.
// from work with three.js project
// desktop pointer
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = - (event.clientY / window.innerHeight) * 2 + 1;
// mobile touch
pointer.x = +(event.targetTouches[0].pageX / window.innerWidth) * 2 + -1;
pointer.y = -(event.targetTouches[0].pageY / window.innerHeight) * 2 + 1;
//mobile click
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = - (event.clientY / window.innerHeight) * 2 + 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment