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.
This commit is contained in:
Sameh Khamis committed 2026-11-07 07:02:41 -08:00
1 parent c145c63b4f
commit bddb890326
6 files changed
+567 -421

No files matched your search

+29 -6
View File
@@ -7,6 +7,17 @@
const span = (a, b) => Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);
/** Each segment's length, and their sum. */
function segmentLengths(positions) {
const lengths = [];
let total = 0;
for (let i = 0; i + 1 < positions.length; i++) {
lengths.push(span(positions[i], positions[i + 1]));
total += lengths[i];
}
return { lengths, total };
}
/**
* The segment a fraction of the polyline's length ends on, and how far
* along it (`t`, 0..1): fractions past 0 and up to 1 only. Null when there
@@ -17,12 +28,7 @@ const span = (a, b) => Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);
*/
export function alongLength(positions, fraction) {
if (!(fraction > 0) || fraction > 1 || positions.length < 2) return null;
const lengths = [];
let total = 0;
for (let i = 0; i + 1 < positions.length; i++) {
lengths.push(span(positions[i], positions[i + 1]));
total += lengths[i];
}
const { lengths, total } = segmentLengths(positions);
if (!(total > 0)) return null;
let left = fraction * total;
for (let i = 0; i < lengths.length; i++) {
@@ -32,3 +38,20 @@ export function alongLength(positions, fraction) {
}
return { index: lengths.length - 1, t: 1 };
}
/**
* The fraction of the polyline's length that ends `t` (0..1) along segment
* `index`: `alongLength` the other way round. Zero when there is no length.
* @param {ReadonlyArray<{x: number, y: number, z: number}>} positions
* @param {number} index
* @param {number} t
* @returns {number}
*/
export function lengthFraction(positions, index, t) {
const { lengths, total } = segmentLengths(positions);
if (!(total > 0)) return 0;
let drawn = 0;
for (let i = 0; i < lengths.length && i <= index; i++)
drawn += i < index ? lengths[i] : lengths[i] * t;
return drawn / total;
}
+10 -1
View File
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { alongLength } from './polyline.js';
import { alongLength, lengthFraction } from './polyline.js';
const p = (x) => ({ x, y: 0, z: 0 });
@@ -19,3 +19,12 @@ test('alongLength has nothing to say without a length or a fraction in (0, 1]',
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);
});