Created
January 21, 2019 11:43
-
-
Save dghez/5f72a4c5736a717a8883d2fb41ba9216 to your computer and use it in GitHub Desktop.
Unproject the vector and gives back screen coordinates x,y
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
| import { Vector3 } from 'three' | |
| const v = new Vector3() | |
| export default (v3, camera) => { | |
| v.copy(v3) | |
| v.project(camera) | |
| return { | |
| x: v.x * window.innerWidth * 0.5 + window.innerWidth * 0.5, | |
| y: -v.y * window.innerHeight * 0.5 + window.innerHeight * 0.5 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment