mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
perf(cables): draw with batched primitives instead of entities
The layer loaded two GeoJsonDataSources and a CustomDataSource: 6,459 entities. Every enable rebuilt them (a 100-250 ms task or three and about 1 GB of heap that stayed until the next collection), every disable removed them in a 130-150 ms task, and each horizon sweep that showed a landing marker made Cesium create its billboard again and read the terrain height under it once more. The layer now makes the primitives Cesium built from those entities itself: one GroundPolylinePrimitive for every line, one BillboardCollection for the point markers, one PointPrimitiveCollection for the reference tips and one static polyline Primitive for the stems in view, rebuilt in a worker when a sweep moves a tip. A disable hides them and an enable shows them again, so only the first enable builds anything. A marker is clamped to the ground once, 48 per frame as before; after that Cesium follows the terrain within its own time budget and hiding or showing the marker reads nothing. A map-stack change re-classifies the lines in place. Lines keep the distance-display attribute the entity display gave them: with a float attribute present Cesium keeps the 2.5 px width, and without one it is stored as a byte and drawn 2 px. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
b6c241a68e
commit
1923547d43
13 files changed
+1280
-1330
No files matched your search
@@ -77,3 +77,58 @@ export function normalizeFeatures(json, kind) {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function partPosition(value) {
|
||||
if (!Array.isArray(value)) return null;
|
||||
const lon = Number(value[0]);
|
||||
const lat = Number(value[1]);
|
||||
if (!Number.isFinite(lon) || !Number.isFinite(lat)) return null;
|
||||
const height = Number(value[2]);
|
||||
return Number.isFinite(height) ? [lon, lat, height] : [lon, lat];
|
||||
}
|
||||
|
||||
function collectParts(geometry, out) {
|
||||
const coordinates = geometry?.coordinates;
|
||||
switch (geometry?.type) {
|
||||
case 'Point': {
|
||||
const point = partPosition(coordinates);
|
||||
if (point) out.points.push(point);
|
||||
break;
|
||||
}
|
||||
case 'MultiPoint':
|
||||
for (const value of coordinates || []) {
|
||||
const point = partPosition(value);
|
||||
if (point) out.points.push(point);
|
||||
}
|
||||
break;
|
||||
case 'LineString': {
|
||||
const line = (coordinates || []).map(partPosition).filter(Boolean);
|
||||
if (line.length >= 2) out.lines.push(line);
|
||||
break;
|
||||
}
|
||||
case 'MultiLineString':
|
||||
for (const part of coordinates || []) {
|
||||
const line = (part || []).map(partPosition).filter(Boolean);
|
||||
if (line.length >= 2) out.lines.push(line);
|
||||
}
|
||||
break;
|
||||
case 'GeometryCollection':
|
||||
for (const child of geometry.geometries || []) collectParts(child, out);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The parts of a feature the layer draws: every line of a LineString or
|
||||
* MultiLineString and every point of a Point or MultiPoint, also inside a
|
||||
* GeometryCollection. Each is [lon, lat] or [lon, lat, height] in degrees
|
||||
* and metres. Polygons are not drawn.
|
||||
* @returns {{lines:number[][][],points:number[][]}}
|
||||
*/
|
||||
export function featureParts(feature) {
|
||||
const out = { lines: [], points: [] };
|
||||
collectParts(feature?.geometry, out);
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user