Files
gods-eye-view/src/geo/polyline.test.mjs
T
Sameh Khamis bddb890326 Draw the Bhote Koshi locator through the renderer's ports and take it off the Cesium list
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.
2026-11-07 07:02:41 -08:00

31 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
});