mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
The locator's country fill, revealed border and flood path lines, and pulsing halos are now three draw sets per layer (fill under lines under halos), none of them pickable. The border and flood path are draped lines revealed with revealFraction: the old vertex-by-vertex head is turned into a fraction of the line's length (geo/polyline lengthFraction, the inverse of alongLength). The callout pulse brings what is drawn up to date each frame, upserting only the lines and halos that changed. Camera moves and flight cancels go through the camera port. The border's own frame loop only asked for renders the pulse already asks for, and is gone.
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
||
import test from 'node:test';
|
||
import { alongLength, lengthFraction } from './polyline.js';
|
||
|
||
const p = (x) => ({ x, y: 0, z: 0 });
|
||
|
||
test('alongLength finds where a fraction of a polyline’s length ends', () => {
|
||
assert.deepEqual(alongLength([p(0), p(1), p(4)], 0.5), {
|
||
index: 1,
|
||
t: 1 / 3,
|
||
});
|
||
assert.deepEqual(alongLength([p(0), p(1), p(4)], 1), { index: 1, t: 1 });
|
||
assert.deepEqual(alongLength([p(0), p(1), p(4)], 0.25), { index: 0, t: 1 });
|
||
});
|
||
|
||
test('alongLength has nothing to say without a length or a fraction in (0, 1]', () => {
|
||
assert.equal(alongLength([p(0), p(1)], 0), null);
|
||
assert.equal(alongLength([p(0), p(1)], 1.5), null);
|
||
assert.equal(alongLength([p(0), p(0)], 0.5), null);
|
||
assert.equal(alongLength([p(0)], 0.5), null);
|
||
});
|
||
|
||
test('lengthFraction is alongLength the other way round', () => {
|
||
const line = [p(0), p(1), p(4)];
|
||
assert.equal(lengthFraction(line, 1, 1 / 3), 0.5);
|
||
assert.equal(lengthFraction(line, 0, 1), 0.25);
|
||
assert.equal(lengthFraction(line, 1, 1), 1);
|
||
assert.equal(lengthFraction(line, 0, 0), 0);
|
||
assert.equal(lengthFraction([p(0), p(0)], 0, 0.5), 0);
|
||
});
|