Created
October 31, 2016 12:27
-
-
Save craftfortress/ebc39bada03f87d03961fca9276a8106 to your computer and use it in GitHub Desktop.
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
function screenXY(obj){ | |
var vector = obj.clone(); | |
var windowWidth = window.innerWidth; | |
var minWidth = 1280; | |
if(windowWidth < minWidth) { | |
windowWidth = minWidth; | |
} | |
var widthHalf = (windowWidth/2); | |
var heightHalf = (window.innerHeight/2); | |
vector.project(camera); | |
vector.x = ( vector.x * widthHalf ) + widthHalf; | |
vector.y = - ( vector.y * heightHalf ) + heightHalf; | |
vector.z = 0; | |
return vector; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment