mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Starry sky and the application viewer move into the Cesium adapter
src/sky/starrySky.js and src/app/viewer.js are Cesium through and through, so they move into the adapter as src/render/cesium/starrySky.js and applicationViewer.js; the ./application/viewer export points there. The celestial ring's precise ICRF rotation reaches the shell through a Cesium-free registry (src/sky/icrf.js) that the sky provides as it loads; the application's renderer loads it, and so does ./render/cesium/unbound. Both files leave the Cesium allow-list.
This commit is contained in:
1 parent
a8a9cc73a4
commit
e6d9ec0636
17 files changed
+110
-38
No files matched your search
@@ -222,8 +222,9 @@ test('the separate viewer export imports without constructing a browser viewer',
|
||||
});
|
||||
|
||||
test('the viewer gets the starry sky as an option, which keeps the Sun and Moon', async () => {
|
||||
const { applicationViewerOptions } = await import('./viewer.js');
|
||||
const { StarrySky } = await import('../sky/starrySky.js');
|
||||
const { applicationViewerOptions } =
|
||||
await import('../render/cesium/applicationViewer.js');
|
||||
const { StarrySky } = await import('../render/cesium/starrySky.js');
|
||||
const creditContainer = {};
|
||||
const options = applicationViewerOptions(creditContainer);
|
||||
// CesiumWidget skips scene.sun and scene.moon when skyBox is false.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Sky background
|
||||
|
||||
Catalogue stars over a soft Milky Way, drawn by `src/sky/starrySky.js` in
|
||||
Catalogue stars over a soft Milky Way, drawn by `src/render/cesium/starrySky.js` in
|
||||
place of Cesium's blocky Tycho-2 sky box.
|
||||
|
||||
| File | Content | Size |
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* crosses the contract and each call marks code still to port. Ported code
|
||||
* that still holds the viewer reaches the renderer through `rendererOf`.
|
||||
*/
|
||||
import { createApplicationViewer } from '../../app/viewer.js';
|
||||
import { createApplicationViewer } from './applicationViewer.js';
|
||||
import { CONTRACT_VERSION } from '../contract/index.js';
|
||||
import { bindRenderer } from '../rendererOf.js';
|
||||
import { createCesiumInput } from './input.js';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { applyModelAtmosphereWorkaround } from './atmosphereCompat.js';
|
||||
import { StarrySky } from '../sky/starrySky.js';
|
||||
import { applyModelAtmosphereWorkaround } from '../../app/atmosphereCompat.js';
|
||||
import { StarrySky } from './starrySky.js';
|
||||
|
||||
// Dev convenience: expose the app's Cesium instance for console/preview probing
|
||||
// (single shared module instance — avoids dual-Cesium state bugs when testing).
|
||||
@@ -1,7 +1,8 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { loadBundledJson } from '../data/bundledJson.js';
|
||||
import { governorRequestRender } from '../renderGovernor.js';
|
||||
import { buildStarVertices, STAR_VERTEX_FLOATS } from './stars.js';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Space background in the `Scene#skyBox` slot: catalogue stars as point
|
||||
@@ -18,32 +19,32 @@ export const MILKY_WAY_INTENSITY = 0.4;
|
||||
export const SKY_ROTATION_EPSILON_SECONDS = 1;
|
||||
|
||||
const STAR_PACK_URL = new URL(
|
||||
'../data/local_data/sky/bright_stars.json',
|
||||
'../../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',
|
||||
'../../data/local_data/sky/milkyway_px.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
negativeX: new URL(
|
||||
'../data/local_data/sky/milkyway_nx.webp',
|
||||
'../../data/local_data/sky/milkyway_nx.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
positiveY: new URL(
|
||||
'../data/local_data/sky/milkyway_py.webp',
|
||||
'../../data/local_data/sky/milkyway_py.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
negativeY: new URL(
|
||||
'../data/local_data/sky/milkyway_ny.webp',
|
||||
'../../data/local_data/sky/milkyway_ny.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
positiveZ: new URL(
|
||||
'../data/local_data/sky/milkyway_pz.webp',
|
||||
'../../data/local_data/sky/milkyway_pz.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
negativeZ: new URL(
|
||||
'../data/local_data/sky/milkyway_nz.webp',
|
||||
'../../data/local_data/sky/milkyway_nz.webp',
|
||||
import.meta.url,
|
||||
),
|
||||
});
|
||||
@@ -151,6 +152,9 @@ export function icrfToFixedAxes(ms) {
|
||||
};
|
||||
}
|
||||
|
||||
// Cesium-free code asks for it through `src/sky/icrf.js`.
|
||||
provideIcrfToFixed(icrfToFixedAxes);
|
||||
|
||||
/** Whether a cached rotation at `cachedTime` still serves `time`. */
|
||||
export function isSkyRotationCurrent(cachedTime, time) {
|
||||
return (
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
icrfToFixedAxes,
|
||||
isSkyRotationCurrent,
|
||||
} from './starrySky.js';
|
||||
import * as neutral from '../../sky/icrf.js';
|
||||
|
||||
const close = (actual, expected, epsilon = 1e-9) =>
|
||||
assert.ok(Math.abs(actual - expected) <= epsilon, `${actual} vs ${expected}`);
|
||||
@@ -221,3 +222,26 @@ test('the precise frame is given as its axes once its tables answer', (t) => {
|
||||
);
|
||||
assert.equal(icrfToFixedAxes(ms), null);
|
||||
});
|
||||
|
||||
test('loading the sky provides its precise rotation to Cesium-free code', () => {
|
||||
const ms = Date.parse('2026-10-19T00:00:00Z');
|
||||
const original = Cesium.Transforms.computeIcrfToFixedMatrix;
|
||||
Cesium.Transforms.computeIcrfToFixedMatrix = (_time, result) =>
|
||||
Cesium.Matrix3.clone(Cesium.Matrix3.fromRotationZ(0.3), result);
|
||||
try {
|
||||
const axes = neutral.icrfToFixedAxes(ms);
|
||||
assert.notEqual(axes, null);
|
||||
assert.deepEqual(axes, icrfToFixedAxes(ms));
|
||||
} finally {
|
||||
Cesium.Transforms.computeIcrfToFixedMatrix = original;
|
||||
}
|
||||
});
|
||||
|
||||
test('the neutral rotation answers null with nothing provided', () => {
|
||||
neutral.provideIcrfToFixed(null);
|
||||
try {
|
||||
assert.equal(neutral.icrfToFixedAxes(0), null);
|
||||
} finally {
|
||||
neutral.provideIcrfToFixed(icrfToFixedAxes);
|
||||
}
|
||||
});
|
||||
@@ -4,8 +4,9 @@
|
||||
* layers a Cesium viewer with no renderer bound: the factories
|
||||
* that build a camera, credits, effects, draw, frame, globe, input and query
|
||||
* port over such a viewer when code first asks for one, a click's own
|
||||
* Cesium picks (`rendererOf.js`), and the map engine the map stacks switch
|
||||
* through (`src/maps/engine.js`).
|
||||
* Cesium picks (`rendererOf.js`), the map engine the map stacks switch
|
||||
* through (`src/maps/engine.js`), and the sky's precise ICRF rotation
|
||||
* (`src/sky/icrf.js`).
|
||||
*/
|
||||
import './camera.js';
|
||||
import './effects.js';
|
||||
@@ -15,3 +16,4 @@ import './input.js';
|
||||
import './mapEngine.js';
|
||||
import './nativeClick.js';
|
||||
import './query.js';
|
||||
import './starrySky.js';
|
||||
@@ -2,8 +2,6 @@
|
||||
"dev/conformance/main.js",
|
||||
"src/app/embed.js",
|
||||
"src/app/scene.js",
|
||||
"src/app/viewer.js",
|
||||
"src/data/geoImportPins.js",
|
||||
"src/sky/starrySky.js",
|
||||
"src/ui/applicationShell.js"
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @module sky/icrf
|
||||
* @description The precise ICRF-to-fixed rotation, from the renderer that
|
||||
* has the tables for it (the Cesium adapter's starry sky provides it as it
|
||||
* loads, `src/render/cesium/starrySky.js`). Cesium-free: with none
|
||||
* provided, or before its tables load, it answers null and callers fall
|
||||
* back to `temeToPseudoFixed` (`src/geo/frames.js`).
|
||||
*/
|
||||
|
||||
let provided = null;
|
||||
|
||||
/**
|
||||
* Provide the precise rotation; a later call replaces it.
|
||||
* @param {(ms: number) => ({x: object, y: object, z: object} | null)} axesAt
|
||||
*/
|
||||
export function provideIcrfToFixed(axesAt) {
|
||||
provided = axesAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* The precise ICRF-to-fixed rotation at `ms` (epoch milliseconds) as its
|
||||
* axes (the matrix's columns), or null while it is unknown.
|
||||
* @param {number} ms
|
||||
* @returns {{x: object, y: object, z: object} | null}
|
||||
*/
|
||||
export function icrfToFixedAxes(ms) {
|
||||
return provided ? provided(ms) : null;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ import { applicationPinia, createUiRuntime } from './vueRuntime.js';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useMissionReplayStore } from './stores/missionReplay.js';
|
||||
import { useCelestialRingStore } from './stores/celestialRing.js';
|
||||
import { icrfToFixedAxes } from '../sky/starrySky.js';
|
||||
import { icrfToFixedAxes } from '../sky/icrf.js';
|
||||
import { useWorldOverlayActionsStore } from './stores/worldOverlayActions.js';
|
||||
import { useAwarenessDirectionStore } from './stores/awarenessDirection.js';
|
||||
import { useHudStore } from './stores/hud.js';
|
||||
|
||||
@@ -4,7 +4,7 @@ import { VisualEffects } from './visualEffects.js';
|
||||
import { createCesiumEffects } from '../render/cesium/effects.js';
|
||||
import { styleStagesOf } from '../styles/styleStages.js';
|
||||
import { createCesiumGlobe } from '../render/cesium/globe.js';
|
||||
import { MILKY_WAY_INTENSITY, StarrySky } from '../sky/starrySky.js';
|
||||
import { MILKY_WAY_INTENSITY, StarrySky } from '../render/cesium/starrySky.js';
|
||||
import {
|
||||
GLOBAL_POST_DEFAULTS,
|
||||
STYLE_PRESET_DEFAULTS,
|
||||
|
||||
Reference in new issue
Block a user