aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/viewer/tests/atmosphere.test.mjs
blob: 79f183a9b0353ae9b09d954e37aebac5da2a9bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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);
});