Skip to content

Instantly share code, notes, and snippets.

@dghez
Created January 21, 2019 11:43
Show Gist options
  • Select an option

  • Save dghez/5f72a4c5736a717a8883d2fb41ba9216 to your computer and use it in GitHub Desktop.

Select an option

Save dghez/5f72a4c5736a717a8883d2fb41ba9216 to your computer and use it in GitHub Desktop.
Unproject the vector and gives back screen coordinates x,y
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