1

I have a lot of small points to draw on the surface of a sphere. They are located by two angles lat ∈ [-PI/2,PI/2] and long ∈ [-PI,PI] and the same radius R.

My camera is pointing directly at the center of the sphere, and is also located with angles lat and long. Its distance from the center can vary though, but is always greater than R, let's call it d.

For each visible points, I have to make other calculations in addition to the actual rendering, so to make the animation loop faster I would like to know which ones are visible and which ones are not.

What I have tried :

Don't render them if this condition is true : Math.abs(point.position.long - camera.position.long) > Math.PI/4 && Math.abs(point.position.lat - camera.position.lat) > Math.PI/4

Which only work when the camera's latitude is 0, because if you are at a pole the range of longitudes you want to see is actually 2*PI, but you want a reduced latitude range.

I then tried taking latitude into account when calculating the longitude range, by using Math.PI/4 + 3/2*Math.abs(this.rotation.lat) instead of just Math.PI/4 and it is better but still not perfect.

I would like to know how I could achieve this, and in the best case scenario take into account the camera's settings, maybe with its projection or model view matrices (I use THREE.js so they are readily available) to really reduce the number of points rendered.

Thanks a lot,

Paul
  • 89
  • 8
  • 1
    Related: https://stackoverflow.com/a/29321766/1461008 – WestLangley Apr 27 '22 at 21:33
  • Nice answer, better than what I did ! But I hope we can reduce the visible points a bit more when the camera is close to the surface of the sphere ! – Paul Apr 27 '22 at 21:40
  • 1
    @Paul Have a look at this forum thread: https://discourse.threejs.org/t/globe-with-markers-and-label-thoughts-ideas-approaches-solutions/34995 – prisoner849 Apr 28 '22 at 06:24
  • Thanks @prisoner849 I think I understand the code, I will try and adapt it to my project soon ! – Paul Apr 28 '22 at 10:16

0 Answers0