worldmap-viewer

git clone https://git.godosa.eu/worldmap-viewer

master

raw ยท 910 bytes

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);
});