mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Move the bikeshare layer onto the renderer's draw and camera ports
Station dots and the selected-station highlight are now two point draw sets, picked through the draw hit, and the layer follows the camera through the camera port at its own threshold instead of the shared percentageChanged ledger. Altitude and view centre come from the camera pose and view rectangle. All five bikeshare files leave the Cesium allow-list. The Cesium draw port now keeps a rebuilt host in its place in the scene instead of re-adding it on top, tags hosts with their set id so sprite order can raise a draw set (registerSpriteSet), and restyles unclamped points in place when they have not moved, so a status poll or selection no longer rebuilds every station. Other draw-port layers (cyclone markers, earthquake discs) now also keep their first-build slot rather than jumping above the sprite layers on each rebuild.
This commit is contained in:
1 parent
2b66c46a30
commit
8c6fa6258b
22 files changed
+732
-249
No files matched your search
+30
-1
@@ -25,6 +25,35 @@ export function registerSpriteCollection(layerId, collection) {
|
||||
_collections.set(layerId, collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a renderer draw set for a sprite layer, by its set id. The
|
||||
* default renderer names each set's host primitive with `drawSetId`; the
|
||||
* restorer raises the host it finds under that name, whichever host the
|
||||
* set draws with now.
|
||||
* @param {string} layerId - Stable sprite-order layer key.
|
||||
* @param {string} setId - The draw set's id.
|
||||
* @returns {object} The registration, for `unregisterSpriteCollection`'s guard.
|
||||
*/
|
||||
export function registerSpriteSet(layerId, setId) {
|
||||
const entry = Object.freeze({ drawSetId: setId });
|
||||
if (layerId && typeof setId === 'string') _collections.set(layerId, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* The primitive `entry` names: itself, or a draw set's host found by its id.
|
||||
* The topmost match wins, so a host still retiring below its replacement is
|
||||
* skipped.
|
||||
*/
|
||||
function resolveSprite(primitives, entry) {
|
||||
if (typeof entry?.drawSetId !== 'string') return entry;
|
||||
for (let i = (primitives.length ?? 0) - 1; i >= 0; i--) {
|
||||
const primitive = primitives.get(i);
|
||||
if (primitive?.drawSetId === entry.drawSetId) return primitive;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a registered collection (primarily useful to lifecycle tests).
|
||||
* @param {string} layerId - Stable sprite-order layer key.
|
||||
@@ -51,7 +80,7 @@ export function restoreSpriteOrder(viewer) {
|
||||
return;
|
||||
|
||||
for (const layerId of SPRITE_LAYER_ORDER) {
|
||||
const collection = _collections.get(layerId);
|
||||
const collection = resolveSprite(primitives, _collections.get(layerId));
|
||||
if (!collection || collection.isDestroyed?.()) continue;
|
||||
if (primitives.contains?.(collection) === false) continue;
|
||||
primitives.raiseToTop(collection);
|
||||
|
||||
Reference in new issue
Block a user