Say you want to display a few key locations on your globe—points you can interact with to display some sort of extra data such as population. Getting those points onto your sphere in the correct spots requires a bit of geometry and trigonometry magic.
In this tutorial, I'll show you how to perfectly place Three.js spheres on your globe using the world's accepted latitude and longitudinal coordinate system.
Equations for converting lat and lng to 3D coordinates:
const x = radius * Math.cos(latitude) * Math.sin(longitude) const y = radius * Math.sin(latitude) const z = radius * Math.cos(latitude) * Math.cos(longitude)