From fa2e8e85512e295cd5d7ffab64a9aba32ddbd349 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Tue, 10 Nov 2026 23:29:40 -0800 Subject: [PATCH] The sky background is exported: the star catalogue, the Milky Way's faces and the star vertex builder from gods-eye-view/sky --- package.json | 1 + scripts/package-boundaries.json | 13 +++++++++ src/data/local_data/sky/README.md | 3 +- src/render/cesium/starrySky.js | 40 +++++--------------------- src/sky/assets.js | 48 +++++++++++++++++++++++++++++++ src/sky/index.js | 19 ++++++++++++ 6 files changed, 90 insertions(+), 34 deletions(-) create mode 100644 src/sky/assets.js create mode 100644 src/sky/index.js diff --git a/package.json b/package.json index 33b6d486a..505f581f5 100644 --- a/package.json +++ b/package.json @@ -306,6 +306,7 @@ "./view": "./src/view/index.js", "./agent/world-packet": "./src/agent/worldPacket.js", "./geo": "./src/geo/index.js", + "./sky": "./src/sky/index.js", "./render/contract": "./src/render/contract/index.js", "./render/stub": "./src/render/stub/index.js", "./render/occlusion": "./src/render/occlusion/index.js", diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index c96416dc3..12efa3d23 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -232,6 +232,7 @@ "src/data/bundledJson.js", "src/renderGovernor.js", "src/sky/icrf.js", + "src/sky/assets.js", "src/globeInView.js", "src/render/cesium/imageryLookAhead.js", "src/cockpitOrbital.js" @@ -2148,6 +2149,7 @@ "src/renderGovernor.js", "src/sky/icrf.js", "src/sky/stars.js", + "src/sky/assets.js", "src/render/cesium/starrySky.js", "src/render/applicationHooks.js", "src/maps/globeEngine.js", @@ -4695,6 +4697,7 @@ "src/maps/attribution.js", "src/render/cesium/mapEngine.js", "src/sky/icrf.js", + "src/sky/assets.js", "src/app/panelRendering.js", "src/render/cesium/application.js", "src/sources/osmFeatures.js", @@ -7187,6 +7190,16 @@ ], "external": [] }, + "sky": { + "exports": ["./sky"], + "modules": [ + "src/sky/index.js", + "src/sky/assets.js", + "src/sky/stars.js", + "src/sky/icrf.js" + ], + "external": [] + }, "render": { "exports": [ "./render/contract", diff --git a/src/data/local_data/sky/README.md b/src/data/local_data/sky/README.md index 0f468ee62..09b8853ab 100644 --- a/src/data/local_data/sky/README.md +++ b/src/data/local_data/sky/README.md @@ -1,6 +1,7 @@ # Sky background -Catalogue stars over a soft Milky Way, drawn by `src/render/cesium/starrySky.js` in +Catalogue stars over a soft Milky Way, exported Cesium-free by `src/sky/index.js` +(`@gods-eye-view/core/sky`) and drawn on Cesium by `src/render/cesium/starrySky.js` in place of Cesium's blocky Tycho-2 sky box. | File | Content | Size | diff --git a/src/render/cesium/starrySky.js b/src/render/cesium/starrySky.js index 868139f85..260e75589 100644 --- a/src/render/cesium/starrySky.js +++ b/src/render/cesium/starrySky.js @@ -3,6 +3,11 @@ import { loadBundledJson } from '../../data/bundledJson.js'; import { governorRequestRender } from '../../renderGovernor.js'; import { buildStarVertices, STAR_VERTEX_FLOATS } from '../../sky/stars.js'; import { provideIcrfToFixed } from '../../sky/icrf.js'; +import { + MILKY_WAY_FACE_URLS, + MILKY_WAY_INTENSITY, + STAR_CATALOGUE_URL, +} from '../../sky/assets.js'; /** * Space background in the `Scene#skyBox` slot: catalogue stars as point @@ -14,41 +19,10 @@ import { provideIcrfToFixed } from '../../sky/icrf.js'; export const STARRY_SKY_CESIUM_VERSION = '1.138.0'; /** Brightness of the Milky Way glow; the stars carry the sky. */ -export const MILKY_WAY_INTENSITY = 0.4; +export { MILKY_WAY_INTENSITY }; /** Clock change, in seconds, below which the sky rotation is reused. */ export const SKY_ROTATION_EPSILON_SECONDS = 1; -const STAR_PACK_URL = new URL( - '../../data/local_data/sky/bright_stars.json', - import.meta.url, -); -const MILKY_WAY_FACE_URLS = Object.freeze({ - positiveX: new URL( - '../../data/local_data/sky/milkyway_px.webp', - import.meta.url, - ), - negativeX: new URL( - '../../data/local_data/sky/milkyway_nx.webp', - import.meta.url, - ), - positiveY: new URL( - '../../data/local_data/sky/milkyway_py.webp', - import.meta.url, - ), - negativeY: new URL( - '../../data/local_data/sky/milkyway_ny.webp', - import.meta.url, - ), - positiveZ: new URL( - '../../data/local_data/sky/milkyway_pz.webp', - import.meta.url, - ), - negativeZ: new URL( - '../../data/local_data/sky/milkyway_nz.webp', - import.meta.url, - ), -}); - // Directions, not points: w = 0 drops the camera translation, and z just // under w keeps every fragment at the far plane, inside any frustum. const SKY_DIRECTION_GLSL = ` @@ -222,7 +196,7 @@ export class StarrySky { _load() { if (this._loading) return; this._loading = true; - loadBundledJson(STAR_PACK_URL) + loadBundledJson(STAR_CATALOGUE_URL) .then((pack) => { if (this._destroyed) return; this._starData = buildStarVertices(pack); diff --git a/src/sky/assets.js b/src/sky/assets.js new file mode 100644 index 000000000..1c1824ad8 --- /dev/null +++ b/src/sky/assets.js @@ -0,0 +1,48 @@ +/** + * @module sky/assets + * @description The sky background's bundled data, Cesium-free: the + * bright-star catalogue (`buildStarVertices` in `./stars.js` decodes it) and + * the Milky Way glow's six cube faces, both in ICRF/J2000. See + * `src/data/local_data/sky/README.md` for their sources and licences. + */ + +/** The bright-star catalogue pack (`{ stars: [raDeg, decDeg, vmag, bv, …] }`). */ +export const STAR_CATALOGUE_URL = new URL( + '../data/local_data/sky/bright_stars.json', + import.meta.url, +); + +/** + * The Milky Way's cube faces in the WebGL face order and layout: +X toward + * the March equinox, +Z toward the north celestial pole, uploaded without + * flipping. + */ +export const MILKY_WAY_FACE_URLS = Object.freeze({ + positiveX: new URL( + '../data/local_data/sky/milkyway_px.webp', + import.meta.url, + ), + negativeX: new URL( + '../data/local_data/sky/milkyway_nx.webp', + import.meta.url, + ), + positiveY: new URL( + '../data/local_data/sky/milkyway_py.webp', + import.meta.url, + ), + negativeY: new URL( + '../data/local_data/sky/milkyway_ny.webp', + import.meta.url, + ), + positiveZ: new URL( + '../data/local_data/sky/milkyway_pz.webp', + import.meta.url, + ), + negativeZ: new URL( + '../data/local_data/sky/milkyway_nz.webp', + import.meta.url, + ), +}); + +/** The Milky Way glow's brightness at `SkySettings.milkyWay` 1: the stars carry the sky. */ +export const MILKY_WAY_INTENSITY = 0.4; diff --git a/src/sky/index.js b/src/sky/index.js new file mode 100644 index 000000000..e0bed5cc2 --- /dev/null +++ b/src/sky/index.js @@ -0,0 +1,19 @@ +/** + * @module sky + * @description The sky background, Cesium-free: catalogue stars over a + * soft Milky Way, both in ICRF/J2000, and the precise ICRF-to-fixed rotation + * a renderer may provide for the rest of the application. + */ + +export { + STAR_CATALOGUE_URL, + MILKY_WAY_FACE_URLS, + MILKY_WAY_INTENSITY, +} from './assets.js'; +export { + STAR_VERTEX_FLOATS, + STAR_LIMIT_MAGNITUDE, + buildStarVertices, + raDecToUnitVector, +} from './stars.js'; +export { provideIcrfToFixed, icrfToFixedAxes } from './icrf.js';