# Bounding sphere projected height on screen

**URL:** <https://discourse.threejs.org/t/bounding-sphere-projected-height-on-screen/43225>\
**Category:** Questions\
**Tags:** perspective-projection, bounding-box, camera\
**Created:** [October 4, 2022, 3:26pm UTC](https://discourse.threejs.org/t/bounding-sphere-projected-height-on-screen/43225 "2022-10-04T15:26:54Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![Yin\_Cognyto](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/yin_cognyto/32/28865_2.png) [@Yin\_Cognyto](https://discourse.threejs.org/u/Yin_Cognyto)\
**Post date:** [October 7, 2022, 2:35pm UTC](https://discourse.threejs.org/t/bounding-sphere-projected-height-on-screen/43225/27 "2022-10-07T14:35:07Z")

</div>

> [@abernier](#):
>
> BTW, I’m still having strange results (this the console.log values) when zooming a lot, event if the red sphere is correctly positionned… I don’t really know if this is correct/ok…

That might be because of your last two operations in the `h` and `h_apparent` computations. Performing such things on the vector3s instead of the plain `.y` component of the initial vector3 doesn’t seem like the right choice, and getting the `.length()` neither. In other words, you’re looking for scalar values here, and the only component of interest is the projected Y one… 🤔

> [@abernier](#):
>
> I guess we have no solution for this? except what you were initially suggesting: projecting all vertices to the screen and make a Box2 of it, to get its projected width/height…

There is always a solution. Projecting all vertices would probably work as well, but depending on their number (and the number of segments in the shape), it can be a bit intensive, and logically it’s overkill to do that when all you need are just 2 points. A slightly related approach (with a different objective than yours, mainly to center and fit an cube on the screen) is illustrated in the fiddle from [this](https://discourse.threejs.org/t/is-it-possible-to-know-at-what-distance-of-the-camera-from-the-cube-the-height-of-the-perspective-projection-of-the-cube-will-be-equal-to-the-height-of-the-screen/40449/17) post.

> [@abernier](#):
>
> I now see your point and in effective, when the sphere is not centered into the screen, it has a ellipse/potato shape […] and the red bottom sphere isn’t at the bottom of the sphere…

That indeed looks strange, not entirely sure what would be the cause. I’ll try to rewrite this in a fiddle and see what can be done about it. By the way, you want the little A and B spheres to be in the screen space or in 3D space?

---

_[View the full topic](https://discourse.threejs.org/t/bounding-sphere-projected-height-on-screen/43225)._
