aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/viewer/tests/atmosphere.test.mjs
diff options
context:
space:
mode:
authorgodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
committergodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
commit3443c1c65e9f1753e1e656b35d08416c1fa298f2 (patch)
tree4e43236f460145a4d75d1b4616dcb7aa6ef08f51 /viewer/tests/atmosphere.test.mjs
downloadworldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.tar.gz
worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.zip
worldmap-viewer: initial public history
Diffstat (limited to 'viewer/tests/atmosphere.test.mjs')
-rw-r--r--viewer/tests/atmosphere.test.mjs24
1 files changed, 24 insertions, 0 deletions
diff --git a/viewer/tests/atmosphere.test.mjs b/viewer/tests/atmosphere.test.mjs
new file mode 100644
index 0000000..79f183a
--- /dev/null
+++ b/viewer/tests/atmosphere.test.mjs
@@ -0,0 +1,24 @@
+import './_planet.mjs';
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import './importmap.mjs';
+
+const { atmosphere, SKY_FULL_KM, SKY_NONE_KM } = await import('../js/atmosphere.js');
+const lum = c => c[0] + c[1] + c[2];
+
+test('full sky near the ground, none in space, a smooth fade between', () => {
+ assert.equal(atmosphere(5).amount, 1);
+ assert.equal(atmosphere(SKY_FULL_KM).amount, 1);
+ assert.equal(atmosphere(SKY_NONE_KM).amount, 0);
+ assert.equal(atmosphere(5000).amount, 0);
+ const m = atmosphere(60).amount;
+ assert.ok(m > 0.2 && m < 0.8);
+});
+
+test('day sky is blue, lighter at the horizon; night is dark; Sky off = day', () => {
+ const d = atmosphere(1, null);
+ assert.ok(d.zenith[2] > d.zenith[0] && lum(d.horizon) > lum(d.zenith));
+ const n = atmosphere(1, -1);
+ assert.ok(lum(n.horizon) < 0.3 * lum(d.horizon));
+ assert.deepEqual(atmosphere(1, 1), d);
+});