Skip to content

Instantly share code, notes, and snippets.

@floz
Created November 17, 2017 06:28
Show Gist options
  • Save floz/fb2686aab868643e2f1174f9bac1969f to your computer and use it in GitHub Desktop.
Save floz/fb2686aab868643e2f1174f9bac1969f to your computer and use it in GitHub Desktop.
Workshop WebGL Advanced - GROW - Github emails link
https://docs.google.com/spreadsheets/d/1H7ITmzPHGjQl_RUrZjJu-uDq37s12YfN3_T8iYo7keU/edit?usp=sharing
@Jeremboo
Copy link

Jeremboo commented Nov 17, 2017

const getNormalizedPosFromScreen = (x, y) => {
  return new THREE.Vector3(
    ((x / window.innerWidth) * 2) - 1,
    -((y / window.innerHeight) * 2) + 1,
    0.5,
  );
}

document.body.addEventListener('mousemove', (e) => {
  const normalizedMouse = getNormalizedPosFromScreen(e.clientX, e.clientY);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment