mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Take transit's state, trails and selection off Cesium
The per-frame scratch position is a plain object, and trail vertices come from geo/ellipsoid's fromDegrees, which matches Cesium's to the bit; the billboards and trail geometry they feed copy them as before. The pick diagnostic names the picked marker's collection from its vehicle rather than from Cesium's private field. state, trails and selection leave the Cesium allow-list.
This commit is contained in:
1 parent
f6ed35a887
commit
56d56a4d6d
5 files changed
+25
-21
No files matched your search
@@ -5274,6 +5274,7 @@
|
|||||||
"src/data/transitProxy.js",
|
"src/data/transitProxy.js",
|
||||||
"src/data/gtfsRealtime.js",
|
"src/data/gtfsRealtime.js",
|
||||||
"src/layers/transit/trails.js",
|
"src/layers/transit/trails.js",
|
||||||
|
"src/geo/ellipsoid.js",
|
||||||
"src/layers/transit/movement.js",
|
"src/layers/transit/movement.js",
|
||||||
"src/layers/transit/qaMetrics.js",
|
"src/layers/transit/qaMetrics.js",
|
||||||
"src/layers/transit/qaMetrics.test.mjs",
|
"src/layers/transit/qaMetrics.test.mjs",
|
||||||
@@ -5301,6 +5302,7 @@
|
|||||||
"src/data/pickRegistry.js",
|
"src/data/pickRegistry.js",
|
||||||
"src/input/dispatcher.js",
|
"src/input/dispatcher.js",
|
||||||
"src/render/cesium/drawHit.js",
|
"src/render/cesium/drawHit.js",
|
||||||
|
"src/geo/vector.js",
|
||||||
"src/render/cesium/follow.js",
|
"src/render/cesium/follow.js",
|
||||||
"src/render/cesium/cameraInput.js",
|
"src/render/cesium/cameraInput.js",
|
||||||
"src/render/cesium/common.js",
|
"src/render/cesium/common.js",
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as Cesium from 'cesium';
|
|
||||||
import { billboardCollectionOf } from '../../render/cesium/internals.js';
|
|
||||||
import {
|
import {
|
||||||
SELECTED_CARD_REFRESH_MS,
|
SELECTED_CARD_REFRESH_MS,
|
||||||
TRANSIT_SELECTED_OVERLAY_SOURCE_ID,
|
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
|
* reset alike, with no per-frame work here. Null when there is nothing to
|
||||||
* anchor to: a hidden or removed marker draws no card.
|
* anchor to: a hidden or removed marker draws no card.
|
||||||
* @param {object} entry
|
* @param {object} entry
|
||||||
* @returns {() => Cesium.Cartesian3|null}
|
* @returns {() => {x: number, y: number, z: number}|null} ECEF
|
||||||
*/
|
*/
|
||||||
function anchorFor(entry) {
|
function anchorFor(entry) {
|
||||||
return () => {
|
return () => {
|
||||||
@@ -122,6 +120,13 @@ export function createSelection({ state, services, parts }) {
|
|||||||
state._clickSubscription = inputFor(viewer).onClick((event) => {
|
state._clickSubscription = inputFor(viewer).onClick((event) => {
|
||||||
const position = event.position;
|
const position = event.position;
|
||||||
const picked = event.pick;
|
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 = {
|
state._lastPickForTest = {
|
||||||
id: typeof picked?.id === 'string' ? picked.id : null,
|
id: typeof picked?.id === 'string' ? picked.id : null,
|
||||||
primitiveId:
|
primitiveId:
|
||||||
@@ -131,9 +136,9 @@ export function createSelection({ state, services, parts }) {
|
|||||||
x: position.x,
|
x: position.x,
|
||||||
y: position.y,
|
y: position.y,
|
||||||
collection:
|
collection:
|
||||||
billboardCollectionOf(picked?.primitive) === state._animatedMarkers
|
collection && collection === state._animatedMarkers
|
||||||
? 'animated'
|
? 'animated'
|
||||||
: billboardCollectionOf(picked?.primitive) === state._markers
|
: collection && collection === state._markers
|
||||||
? 'stationary'
|
? 'stationary'
|
||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as Cesium from 'cesium';
|
|
||||||
import { createHistoryBudget } from '../../data/contactPlayback.js';
|
import { createHistoryBudget } from '../../data/contactPlayback.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,9 +21,9 @@ export function createState({ services }) {
|
|||||||
});
|
});
|
||||||
state._overlayHost = state.DEFAULT_OVERLAY_HOST;
|
state._overlayHost = state.DEFAULT_OVERLAY_HOST;
|
||||||
|
|
||||||
/** @type {Cesium.Viewer|null} */
|
/** The viewer the layer draws on, or null. */
|
||||||
state._viewer = null;
|
state._viewer = null;
|
||||||
/** @type {Cesium.BillboardCollection|null} */
|
/** The stationary markers' billboard collection, or null. */
|
||||||
state._markers = null;
|
state._markers = null;
|
||||||
state._animatedMarkers = null;
|
state._animatedMarkers = null;
|
||||||
state._visible = new Set();
|
state._visible = new Set();
|
||||||
@@ -120,7 +119,8 @@ export function createState({ services }) {
|
|||||||
state._error = null;
|
state._error = null;
|
||||||
state._limitWarned = false;
|
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;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getRegisteredTransitFeed } from '../../data/transitFeeds.js';
|
import { getRegisteredTransitFeed } from '../../data/transitFeeds.js';
|
||||||
import * as Cesium from 'cesium';
|
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||||
import {
|
import {
|
||||||
readFix,
|
readFix,
|
||||||
correctHeight,
|
correctHeight,
|
||||||
@@ -153,13 +153,8 @@ export function createTrails({ state, services, parts, source }) {
|
|||||||
valid = false;
|
valid = false;
|
||||||
// Ground polylines consume longitude/latitude and drape themselves.
|
// Ground polylines consume longitude/latitude and drape themselves.
|
||||||
// Unknown floors still disqualify the marker corridor.
|
// Unknown floors still disqualify the marker corridor.
|
||||||
positions.push(
|
positions.push(draped ? fromDegrees(point.lon, point.lat) : null);
|
||||||
draped ? Cesium.Cartesian3.fromDegrees(point.lon, point.lat) : null,
|
} else positions.push(fromDegrees(point.lon, point.lat, h));
|
||||||
);
|
|
||||||
} else
|
|
||||||
positions.push(
|
|
||||||
Cesium.Cartesian3.fromDegrees(point.lon, point.lat, h),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
signature += `${a.seq}/${b.seq}:${heights.join(',')};`;
|
signature += `${a.seq}/${b.seq}:${heights.join(',')};`;
|
||||||
if (retainBody) vertices += n + 1;
|
if (retainBody) vertices += n + 1;
|
||||||
@@ -216,7 +211,12 @@ export function createTrails({ state, services, parts, source }) {
|
|||||||
}
|
}
|
||||||
if (sample.fromSeq === sample.toSeq) {
|
if (sample.fromSeq === sample.toSeq) {
|
||||||
if (!Number.isFinite(entry.segment.from.h)) return null;
|
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;
|
return out;
|
||||||
}
|
}
|
||||||
const path = entry.displayPaths?.get(sample.fromSeq);
|
const path = entry.displayPaths?.get(sample.fromSeq);
|
||||||
|
|||||||
@@ -150,10 +150,7 @@
|
|||||||
"src/layers/transit/height.js",
|
"src/layers/transit/height.js",
|
||||||
"src/layers/transit/lifecycle.js",
|
"src/layers/transit/lifecycle.js",
|
||||||
"src/layers/transit/rendering.js",
|
"src/layers/transit/rendering.js",
|
||||||
"src/layers/transit/selection.js",
|
|
||||||
"src/layers/transit/state.js",
|
|
||||||
"src/layers/transit/testing.js",
|
"src/layers/transit/testing.js",
|
||||||
"src/layers/transit/trails.js",
|
|
||||||
"src/layers/transit/viewport.js",
|
"src/layers/transit/viewport.js",
|
||||||
"src/layers/vessels/cameraArea.js",
|
"src/layers/vessels/cameraArea.js",
|
||||||
"src/layers/vessels/evidence.js",
|
"src/layers/vessels/evidence.js",
|
||||||
|
|||||||
Reference in new issue
Block a user