Write a line that moves by as many points into the points it draws

An undraped line in the polyline collection that moved was given a new
array of Cartesians, one new object a point. One that moves by as many
points, not geodesic, now has its new positions written into the points
its polyline draws, which the polyline then takes again: the range ring's
fronts, stepping out every interval, make no new points.
This commit is contained in:
Sameh Khamis committed 2026-11-10 18:29:56 -08:00
1 parent 9743993f8e
commit 241c8dde64
2 files changed
+85 -2

No files matched your search

+29 -1
View File
@@ -2833,7 +2833,10 @@ export function createCesiumDraw({
// would have the collection rewrite its vertices.
const drawn = was.polyline.positions;
const unmoved = drawnAt(drawn, item.positions);
const positions = unmoved ? drawn : linePositions(item);
// One that moves by as many points (a front stepping out) is written
// into the points it has, which the polyline then takes again.
const positions =
unmoved || rewrite(drawn, item) ? drawn : linePositions(item);
if (!unmoved) was.polyline.positions = positions;
was.polyline.show = show;
if (recolour) paintLine(was.polyline.material, item.style);
@@ -2844,6 +2847,31 @@ export function createCesiumDraw({
);
}
/**
* Write a line's new positions into `drawn`, the Cartesians a polyline
* draws (made by `linePositions`), when they are as many and convert one
* for one (not geodesic): true if written, else false, writing nothing.
*/
function rewrite(drawn, item) {
if (item.mode === 'geodesic' || !Array.isArray(drawn)) return false;
const positions = item.positions;
if (positions instanceof Float64Array) {
if (positions.length !== drawn.length * 3) return false;
for (let i = 0; i < drawn.length; i++)
Cesium.Cartesian3.fromElements(
positions[i * 3],
positions[i * 3 + 1],
positions[i * 3 + 2],
drawn[i],
);
return true;
}
if (positions.length !== drawn.length) return false;
for (let i = 0; i < drawn.length; i++)
toCartesianInto(positions[i], drawn[i]);
return true;
}
/**
* Whether `positions` (an item's, ECEF points or packed triples) are the
* Cartesians a polyline already draws. False for any given by longitude