I am looking to convert the world space coordinates of a sphere into screen space coordinates in order to determine the screen space boundaries, which I then plan to use for overlaying a div element.
It would be great if this function could also provide the height and width of the object, along with its x & y positioning:
toScreenPosition : function (obj, camera) {
var vector = new THREE.Vector3();
var widthHalf = 0.5*world.renderer.context.canvas.width;
var heightHalf = 0.5*world.renderer.context.canvas.height;
obj.updateMatrixWorld();
vector.setFromMatrixPosition(obj.matrixWorld);
vector.project(camera);
vector.x = ( vector.x * widthHalf ) + widthHalf;
vector.y = - ( vector.y * heightHalf ) + heightHalf;
return {
x: vector.x,
y: vector.y
};
},