The “horizontal” detour happens because the simple spherical interpolation I used (setFromSphericalCoords) always moves along the shortest great-circle path in spherical coordinates, which can look like it hugs the equator when the two points are far apart in longitude.
Instead we want a straight-looking chord that is simply lifted onto the surface – i.e. a geodesic arc that is visually direct, not necessarily the shortest great-circle in spherical space.
Below is a drop-in replacement for the interpolation routine that keeps the arc visually direct while still staying on the sphere.
Replace the old greatCircleInterpolation function with this one (and keep the rest of the file unchanged):
js
// ------------------------------------------------------------------
// Build a *visually direct* arc on the sphere between two points
// radius : sphere radius
// segments: how many intermediate points
// ------------------------------------------------------------------
function greatCircleInterpolation(from, to, radius, segments) {
const points = [];
// Work with unit vectors first
const a = from.clone().normalize();
const b = to.clone().normalize();
// Angle between the two vectors
const angle = a.angleTo(b);
// If the points are (almost) identical or antipodal, return a straight line
if (angle < 1e-4 || Math.abs(angle - Math.PI) < 1e-4) {
points.push(from.clone());
points.push(to.clone());
return points;
}
for (let i = 0; i <= segments; i++) {
const t = i / segments;
// Spherical linear interpolation (slerp) gives the *direct* arc
const point = a.clone().slerp(b, t).multiplyScalar(radius);
points.push(point);
}
return points;
}
What changed?
THREE.Vector3.slerp performs spherical linear interpolation, which keeps the arc visually straight while staying exactly on the sphere.
No more unwanted detours toward the equator; the edges now look like taut strings laid on the surface.
Refresh the page and the connections will appear much more direct.