diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index 7b7ae510c..ae89208fa 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -5274,6 +5274,7 @@ "src/data/transitProxy.js", "src/data/gtfsRealtime.js", "src/layers/transit/trails.js", + "src/geo/ellipsoid.js", "src/layers/transit/movement.js", "src/layers/transit/qaMetrics.js", "src/layers/transit/qaMetrics.test.mjs", @@ -5301,6 +5302,7 @@ "src/data/pickRegistry.js", "src/input/dispatcher.js", "src/render/cesium/drawHit.js", + "src/geo/vector.js", "src/render/cesium/follow.js", "src/render/cesium/cameraInput.js", "src/render/cesium/common.js", diff --git a/src/layers/transit/selection.js b/src/layers/transit/selection.js index e018bf3b6..c072ba1c9 100644 --- a/src/layers/transit/selection.js +++ b/src/layers/transit/selection.js @@ -1,5 +1,3 @@ -import * as Cesium from 'cesium'; -import { billboardCollectionOf } from '../../render/cesium/internals.js'; import { SELECTED_CARD_REFRESH_MS, TRANSIT_SELECTED_OVERLAY_SOURCE_ID, @@ -27,7 +25,7 @@ export function createSelection({ state, services, parts }) { * reset alike, with no per-frame work here. Null when there is nothing to * anchor to: a hidden or removed marker draws no card. * @param {object} entry - * @returns {() => Cesium.Cartesian3|null} + * @returns {() => {x: number, y: number, z: number}|null} ECEF */ function anchorFor(entry) { return () => { @@ -122,6 +120,13 @@ export function createSelection({ state, services, parts }) { state._clickSubscription = inputFor(viewer).onClick((event) => { const position = event.position; const picked = event.pick; + // The collection of the marker picked: the one its vehicle's marker is + // in, when the pick is one of this layer's markers. + const owner = state._vehicles.get(picked?.primitive?.id); + const collection = + owner && owner.marker === picked.primitive + ? owner.markerCollection + : null; state._lastPickForTest = { id: typeof picked?.id === 'string' ? picked.id : null, primitiveId: @@ -131,9 +136,9 @@ export function createSelection({ state, services, parts }) { x: position.x, y: position.y, collection: - billboardCollectionOf(picked?.primitive) === state._animatedMarkers + collection && collection === state._animatedMarkers ? 'animated' - : billboardCollectionOf(picked?.primitive) === state._markers + : collection && collection === state._markers ? 'stationary' : null, }; diff --git a/src/layers/transit/state.js b/src/layers/transit/state.js index a4379b77d..80486d79b 100644 --- a/src/layers/transit/state.js +++ b/src/layers/transit/state.js @@ -1,4 +1,3 @@ -import * as Cesium from 'cesium'; import { createHistoryBudget } from '../../data/contactPlayback.js'; /** @@ -22,9 +21,9 @@ export function createState({ services }) { }); state._overlayHost = state.DEFAULT_OVERLAY_HOST; - /** @type {Cesium.Viewer|null} */ + /** The viewer the layer draws on, or null. */ state._viewer = null; - /** @type {Cesium.BillboardCollection|null} */ + /** The stationary markers' billboard collection, or null. */ state._markers = null; state._animatedMarkers = null; state._visible = new Set(); @@ -120,7 +119,8 @@ export function createState({ services }) { state._error = null; state._limitWarned = false; - state._scratchCartesian = new Cesium.Cartesian3(); + // Where `samplePosition` writes a marker's position, each frame. + state._scratchCartesian = { x: 0, y: 0, z: 0 }; return state; } diff --git a/src/layers/transit/trails.js b/src/layers/transit/trails.js index 47973c1a2..9cffc278d 100644 --- a/src/layers/transit/trails.js +++ b/src/layers/transit/trails.js @@ -1,5 +1,5 @@ import { getRegisteredTransitFeed } from '../../data/transitFeeds.js'; -import * as Cesium from 'cesium'; +import { fromDegrees } from '../../geo/ellipsoid.js'; import { readFix, correctHeight, @@ -153,13 +153,8 @@ export function createTrails({ state, services, parts, source }) { valid = false; // Ground polylines consume longitude/latitude and drape themselves. // Unknown floors still disqualify the marker corridor. - positions.push( - draped ? Cesium.Cartesian3.fromDegrees(point.lon, point.lat) : null, - ); - } else - positions.push( - Cesium.Cartesian3.fromDegrees(point.lon, point.lat, h), - ); + positions.push(draped ? fromDegrees(point.lon, point.lat) : null); + } else positions.push(fromDegrees(point.lon, point.lat, h)); } signature += `${a.seq}/${b.seq}:${heights.join(',')};`; if (retainBody) vertices += n + 1; @@ -216,7 +211,12 @@ export function createTrails({ state, services, parts, source }) { } if (sample.fromSeq === sample.toSeq) { if (!Number.isFinite(entry.segment.from.h)) return null; - Cesium.Cartesian3.clone(entry.fromCart, out); + const from = entry.fromCart; + if (from) { + out.x = from.x; + out.y = from.y; + out.z = from.z; + } return out; } const path = entry.displayPaths?.get(sample.fromSeq); diff --git a/src/render/cesiumAllowList.json b/src/render/cesiumAllowList.json index 9207c830d..5e2ca787e 100644 --- a/src/render/cesiumAllowList.json +++ b/src/render/cesiumAllowList.json @@ -150,10 +150,7 @@ "src/layers/transit/height.js", "src/layers/transit/lifecycle.js", "src/layers/transit/rendering.js", - "src/layers/transit/selection.js", - "src/layers/transit/state.js", "src/layers/transit/testing.js", - "src/layers/transit/trails.js", "src/layers/transit/viewport.js", "src/layers/vessels/cameraArea.js", "src/layers/vessels/evidence.js",