From 80916471e7f69eb2f0d03fc769214a0ae1d0b9ff Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Tue, 7 Apr 2026 22:21:56 +0200 Subject: [PATCH] fix(assets): correct globe renderer east-west mirroring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arctan2(hz, hx) wrapped longitude counter-clockwise, mirroring east and west on the globe. Changed to arctan2(hx, hz) which increases eastward (right on screen). Added +0.5 offset to center the view on 0° longitude, keeping the dateline seam on the back. Co-Authored-By: Claude Opus 4.6 --- tooling/planet-gen/planet_renderer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tooling/planet-gen/planet_renderer.py b/tooling/planet-gen/planet_renderer.py index 6a20c8504..95f46548b 100644 --- a/tooling/planet-gen/planet_renderer.py +++ b/tooling/planet-gen/planet_renderer.py @@ -189,7 +189,10 @@ def _raytrace(size: int, r: float = 1.0, oblateness: float = 0.0): nx /= nm; ny /= nm; nz /= nm # UV from undistorted hit point - u = (np.arctan2(hz, hx) / (2.0 * math.pi)) % 1.0 + # arctan2(hx, hz) so longitude increases eastward (right on screen). + # +0.5 offset centers the view on 0° longitude (Greenwich) instead of + # 180° (dateline), keeping the seam on the back of the sphere. + u = (np.arctan2(hx, hz) / (2.0 * math.pi) + 0.5) % 1.0 v = np.arcsin(np.clip(hy / np.where(hit, np.sqrt(hx**2 + hy**2 + hz**2), 1.0), -1.0, 1.0)) / math.pi + 0.5 return hit, nx.astype(np.float32), ny.astype(np.float32), nz.astype(np.float32), u.astype(np.float32), v.astype(np.float32)