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
/* | |
Translates normalised device coordinates (NCD) to world coordinates. | |
Calculate NCD using mouseMove/pointerMove event listeners: | |
mouseX = (e.clientX / window.innerWidth) * 2 - 1; | |
mouseY = -(e.clientY / window.innerHeight) * 2 + 1; | |
You can then test if it works by setting up a camera and a cursor mesh object in the scene, | |
copying its position from the return value every animation frame: | |
cursorMesh.position.copy(getCursorWorldCoordinates()); |
OlderNewer