mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge main and switch Cesium and Navara in place through Vue
Preserve the camera, map source and layer selection across engine sessions. Restore the previous engine if startup fails and retain local history navigation.
This commit is contained in:
commit
b8f4d097c4
1691 files changed
+225876
-41594
No files matched your search
+118
-65
@@ -1,6 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { VisualEffects } from './visualEffects.js';
|
||||
import { MILKY_WAY_INTENSITY, StarrySky } from '../sky/starrySky.js';
|
||||
import {
|
||||
GLOBAL_POST_DEFAULTS,
|
||||
STYLE_PRESET_DEFAULTS,
|
||||
@@ -40,8 +41,10 @@ function fixture(engine = null) {
|
||||
},
|
||||
};
|
||||
const effects = new VisualEffects({
|
||||
viewer: { scene: { postProcessStages: pipeline } },
|
||||
engine,
|
||||
viewer: {
|
||||
scene: { postProcessStages: pipeline, skyBox: { milkyWayVisibility: 1 } },
|
||||
},
|
||||
requestRender: (reason) => requests.push(reason),
|
||||
holdRender: (reason) => holds.add(reason),
|
||||
releaseRender: (reason) => holds.delete(reason),
|
||||
@@ -79,7 +82,7 @@ test('construction is inert and initialization creates one owned pipeline', () =
|
||||
assert.equal(f.frames.size, 0);
|
||||
f.effects.initStyles();
|
||||
f.effects.initPostProcess();
|
||||
assert.equal(f.stages.size, 7);
|
||||
assert.equal(f.stages.size, 6);
|
||||
assert.ok(
|
||||
Object.values(f.effects.stages).every(
|
||||
(stage) => !stage.enabled && stage.uniforms.intensity === 0,
|
||||
@@ -87,7 +90,7 @@ test('construction is inert and initialization creates one owned pipeline', () =
|
||||
);
|
||||
f.effects.initStyles();
|
||||
f.effects.initPostProcess();
|
||||
assert.equal(f.stages.size, 7);
|
||||
assert.equal(f.stages.size, 6);
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
@@ -163,6 +166,38 @@ test('direct Cockpit intensity writes are reconciled before rendering', () => {
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
test('the anime stage fades the Milky Way out with its own intensity', () => {
|
||||
const f = fixture();
|
||||
const sky = new StarrySky({ requestRender: () => {} });
|
||||
const glow = () => sky._milkyWayUniforms.u_intensity();
|
||||
f.effects.viewer.scene.skyBox = sky;
|
||||
f.effects.initStyles();
|
||||
f.effects.setStageIntensity(f.effects.stages.thermal, 1);
|
||||
assert.equal(glow(), MILKY_WAY_INTENSITY, 'other styles keep the glow');
|
||||
f.effects.setStageIntensity(f.effects.stages.anime, 0.25);
|
||||
assert.equal(glow(), MILKY_WAY_INTENSITY * 0.75);
|
||||
f.effects.setStageIntensity(f.effects.stages.anime, 1);
|
||||
assert.equal(glow(), 0);
|
||||
f.effects.setStageIntensity(f.effects.stages.anime, 0);
|
||||
assert.equal(glow(), MILKY_WAY_INTENSITY);
|
||||
sky.destroy();
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
for (const skyBox of [undefined, null, {}]) {
|
||||
test(`anime works without StarrySky (${JSON.stringify(skyBox)})`, () => {
|
||||
const f = fixture();
|
||||
f.effects.viewer.scene.skyBox = skyBox;
|
||||
f.effects.initStyles();
|
||||
f.effects.setStageIntensity(f.effects.stages.anime, 1);
|
||||
assert.equal(f.effects.stages.anime.enabled, true);
|
||||
f.effects.setStageIntensity(f.effects.stages.anime, 0);
|
||||
assert.equal(f.effects.stages.anime.enabled, false);
|
||||
if (skyBox) assert.equal('milkyWayVisibility' in skyBox, false);
|
||||
f.effects.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
test('bloom retains its dead zone, normalized intensity and independent toggle', () => {
|
||||
const f = fixture();
|
||||
f.effects.initPostProcess();
|
||||
@@ -194,6 +229,86 @@ test('sharpen uses the existing uniform scale and keeps values while disabled',
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
test('sharpen at 0 runs no pass, and comes back with the slider', () => {
|
||||
const f = fixture();
|
||||
f.effects.initPostProcess(0.49);
|
||||
f.effects.setSharpenEnabled(true);
|
||||
assert.equal(f.effects.sharpenStage.enabled, true);
|
||||
f.effects.applySharpenIntensity(0);
|
||||
assert.equal(
|
||||
f.effects.sharpenStage.enabled,
|
||||
false,
|
||||
'no residual sharpen at 0',
|
||||
);
|
||||
f.effects.setSharpenEnabled(true);
|
||||
assert.equal(f.effects.sharpenStage.enabled, false, 'on at 0 is still off');
|
||||
f.effects.applySharpenIntensity(0.2);
|
||||
assert.equal(f.effects.sharpenStage.enabled, true);
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
test('stop revokes pending work immediately but retains stages until final destruction', () => {
|
||||
const f = fixture();
|
||||
f.effects.initStyles();
|
||||
f.effects.initPostProcess();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
const staleFrame = [...f.frames.values()][0];
|
||||
f.effects.stop();
|
||||
assert.equal(f.frames.size, 0);
|
||||
assert.equal(
|
||||
f.stages.size,
|
||||
6,
|
||||
'Context and Cockpit may still be releasing these stages',
|
||||
);
|
||||
const intensity = f.effects.stages.retro.uniforms.intensity;
|
||||
staleFrame();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
f.effects.setStageIntensity(f.effects.stages.retro, 1);
|
||||
assert.equal(f.frames.size, 0);
|
||||
assert.equal(f.effects.stages.retro.uniforms.intensity, intensity);
|
||||
f.effects.destroy();
|
||||
assert.equal(f.stages.size, 0);
|
||||
assert.deepEqual(
|
||||
f.bloom,
|
||||
f.originalBloom,
|
||||
'borrowed bloom configuration is restored',
|
||||
);
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
test('destroying one instance does not remove another pipeline or clock', () => {
|
||||
const a = fixture();
|
||||
const b = fixture();
|
||||
for (const f of [a, b]) {
|
||||
f.effects.initStyles();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
}
|
||||
a.effects.destroy();
|
||||
b.tick(250);
|
||||
assert.equal(a.stages.size, 0);
|
||||
assert.equal(b.stages.size, 5);
|
||||
assert.equal(b.effects.stages.retro.uniforms.intensity, 0.5);
|
||||
b.effects.destroy();
|
||||
});
|
||||
|
||||
test('existing baseline and military presets keep one detection default', () => {
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionMode, 'DENSE');
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionDensity, 75);
|
||||
assert.equal(
|
||||
presetSharpenIntensity(GLOBAL_POST_DEFAULTS.sharpen.intensity, 'cesium'),
|
||||
49,
|
||||
);
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionFadePct, 7);
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionOutsideOpacityPct, 1);
|
||||
for (const name of ['retro', 'surveillance', 'thermal']) {
|
||||
assert.equal(
|
||||
STYLE_PRESET_DEFAULTS[name].detection,
|
||||
MILITARY_DETECTION_PRESET,
|
||||
);
|
||||
}
|
||||
assert.equal(STYLE_PRESET_DEFAULTS.normal, undefined);
|
||||
});
|
||||
|
||||
test('without a viewer the engine sharpens with the same amount scale', () => {
|
||||
const sharpen = [];
|
||||
const requests = [];
|
||||
@@ -273,65 +388,3 @@ test('presets and the baseline take the engine default sharpen: Cesium 49 %, Nav
|
||||
assert.equal(presetSharpenIntensity(49, 'navara'), 49);
|
||||
assert.equal(presetSharpenIntensity(65, 'cesium'), 65);
|
||||
});
|
||||
|
||||
test('stop revokes pending work immediately but retains stages until final destruction', () => {
|
||||
const f = fixture();
|
||||
f.effects.initStyles();
|
||||
f.effects.initPostProcess();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
const staleFrame = [...f.frames.values()][0];
|
||||
f.effects.stop();
|
||||
assert.equal(f.frames.size, 0);
|
||||
assert.equal(
|
||||
f.stages.size,
|
||||
7,
|
||||
'Context and Cockpit may still be releasing these stages',
|
||||
);
|
||||
const intensity = f.effects.stages.retro.uniforms.intensity;
|
||||
staleFrame();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
f.effects.setStageIntensity(f.effects.stages.retro, 1);
|
||||
assert.equal(f.frames.size, 0);
|
||||
assert.equal(f.effects.stages.retro.uniforms.intensity, intensity);
|
||||
f.effects.destroy();
|
||||
assert.equal(f.stages.size, 0);
|
||||
assert.deepEqual(
|
||||
f.bloom,
|
||||
f.originalBloom,
|
||||
'borrowed bloom configuration is restored',
|
||||
);
|
||||
f.effects.destroy();
|
||||
});
|
||||
|
||||
test('destroying one instance does not remove another pipeline or clock', () => {
|
||||
const a = fixture();
|
||||
const b = fixture();
|
||||
for (const f of [a, b]) {
|
||||
f.effects.initStyles();
|
||||
f.effects.startTransition('retro', 0, 1);
|
||||
}
|
||||
a.effects.destroy();
|
||||
b.tick(250);
|
||||
assert.equal(a.stages.size, 0);
|
||||
assert.equal(b.stages.size, 6);
|
||||
assert.equal(b.effects.stages.retro.uniforms.intensity, 0.5);
|
||||
b.effects.destroy();
|
||||
});
|
||||
|
||||
test('existing baseline and military presets keep one detection default', () => {
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionMode, 'DENSE');
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionDensity, 75);
|
||||
assert.equal(
|
||||
presetSharpenIntensity(GLOBAL_POST_DEFAULTS.sharpen.intensity, 'cesium'),
|
||||
49,
|
||||
);
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionFadePct, 7);
|
||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionOutsideOpacityPct, 1);
|
||||
for (const name of ['retro', 'surveillance', 'thermal']) {
|
||||
assert.equal(
|
||||
STYLE_PRESET_DEFAULTS[name].detection,
|
||||
MILITARY_DETECTION_PRESET,
|
||||
);
|
||||
}
|
||||
assert.equal(STYLE_PRESET_DEFAULTS.normal, undefined);
|
||||
});
|
||||
Reference in new issue
Block a user