moon: real lunar map (CC BY 4.0) with correct near-side geometry - the old normal sign lit the far side, so the disc came out black; stars are now occluded by the disc, sun and moon discs drawn at 12x physical without changing surface brightness; build.py inlines the map as a data URI

This commit is contained in:
Richard Zink committed 2026-10-11 22:46:35 +02:00
1 parent afc779e27e
commit ee56f2a1c8
4 files changed
+215 -25

No files matched your search

+14 -5
View File
@@ -11,6 +11,7 @@ What gets inlined:
- vendor/suncalc.js, vendor/plane3d.js,
vendor/clouds3d.js (plain <script> swap)
- vendor/stars.json (window.__starsData)
- vendor/moon.jpg (window.__moonTex, data URI)
- every stylesheet referenced by window.THEMES
(window.__inlineThemeCss, so
theme switching works offline)
@@ -24,6 +25,7 @@ Overpass cache, which is the gentlest way to hit those upstreams.
The build fails loudly if any external script or stylesheet reference survives.
"""
import base64
import json
import os
import re
@@ -128,12 +130,18 @@ def main():
# embedded data preamble (must run before the scene scripts)
stars = json.loads(read('vendor/stars.json'))
theme_css = {name: read(fname) for name, fname in themes.items()}
moon_path = os.path.join(ROOT, 'vendor', 'moon.jpg')
moon_uri = ''
if os.path.exists(moon_path):
with open(moon_path, 'rb') as f:
moon_uri = 'data:image/jpeg;base64,' + base64.b64encode(f.read()).decode('ascii')
embed = (
'<script>\n'
'window.__starsData = %s;\n'
'window.__moonTex = "%s";\n'
'window.__inlineThemeCss = %s;\n'
'</script>\n'
% (json.dumps(stars, separators=(',', ':')), json.dumps(theme_css))
% (json.dumps(stars, separators=(',', ':')), moon_uri, json.dumps(theme_css))
)
# must come before config.js so the early theme loader sees the CSS
anchor = '<script src="config.js"></script>'
@@ -158,8 +166,8 @@ def main():
with tempfile.NamedTemporaryFile('w', suffix='.html', delete=False) as f:
f.write(html)
tmp = f.name
print('OK: self-contained (%d bytes, %d themes, %d stars)'
% (len(html), len(themes), len(stars)))
print('OK: self-contained (%d bytes, %d themes, %d stars, moon map %d KB)'
% (len(html), len(themes), len(stars), len(moon_uri) // 1024))
os.unlink(tmp)
return
@@ -167,8 +175,9 @@ def main():
f.write(html)
print('Wrote %s (%d bytes)' % (out, len(html)))
print('Inlined: %s, stars.json (%d entries), themes: %s'
% (', '.join(INLINED_SCRIPTS), len(stars), ', '.join(sorted(themes))))
print('Inlined: %s, stars.json (%d entries), moon.jpg (%d KB), themes: %s'
% (', '.join(INLINED_SCRIPTS), len(stars), len(moon_uri) // 1024,
', '.join(sorted(themes))))
if __name__ == '__main__':