mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Take the camera layer's policy, state, model and ground off Cesium
The layer's colours are renderer colours; the parts that still draw with Cesium (icons, coverage lines, the monitor plane) turn them into Cesium colours with the adapter's own conversion. The screen and matrix scratches are plain objects, which is all the projections that fill them write. The model part converts angles with geo/vector, reads where the eye is from the camera port's pose, and builds the monitor plane's orientation with geo/quaternion from the same axes; the projection part hands the entity a Cesium quaternion of it. The photoreal tileset readiness check, which looks through the scene's primitives, moves to the geometry part. The ground pass moves a camera icon by writing geo/ellipsoid's position into the record's own position object. The test plane's plain material comes from the projection part, and the selection part only lost an unused import. All give the same numbers as the Cesium calls they replace. Policy, state, selection, testing, model and ground leave the allow-list.
This commit is contained in:
1 parent
2592289612
commit
7d760d32fc
13 files changed
+147
-127
No files matched your search
+22
-63
@@ -1,4 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { cross, negate, toDegrees, toRadians } from '../../geo/vector.js';
|
||||
import { fromAxes } from '../../geo/quaternion.js';
|
||||
import { findCamera } from '../../render/rendererOf.js';
|
||||
import { greatCircleKm } from '../../geoDistance.js';
|
||||
import { staticFrameRefreshMs } from '../../data/cctvLod.js';
|
||||
import { frameFetchDue, cardFetchPolicy } from '../../data/cctvCards.js';
|
||||
@@ -14,7 +16,7 @@ export function createModel({ state: layerState, services, parts, source }) {
|
||||
*/
|
||||
|
||||
function toRad(deg) {
|
||||
return Cesium.Math.toRadians(deg);
|
||||
return toRadians(deg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,8 +297,8 @@ export function createModel({ state: layerState, services, parts, source }) {
|
||||
const lon2 = lon1 + Math.atan2(y, x);
|
||||
|
||||
return {
|
||||
lat: Cesium.Math.toDegrees(lat2),
|
||||
lon: Cesium.Math.toDegrees(lon2),
|
||||
lat: toDegrees(lat2),
|
||||
lon: toDegrees(lon2),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -333,11 +335,11 @@ export function createModel({ state: layerState, services, parts, source }) {
|
||||
*/
|
||||
|
||||
function currentViewContext() {
|
||||
const carto = layerState._viewer?.camera?.positionCartographic;
|
||||
if (!carto) return 'none';
|
||||
const lat = Cesium.Math.toDegrees(carto.latitude);
|
||||
const lon = Cesium.Math.toDegrees(carto.longitude);
|
||||
const alt = carto.height || 0;
|
||||
const pose = findCamera(layerState._viewer)?.pose();
|
||||
// An eye at the earth's centre has no geographic position.
|
||||
if (!pose || !Number.isFinite(pose.lat)) return 'none';
|
||||
const { lat, lon } = pose;
|
||||
const alt = pose.height || 0;
|
||||
const zoomBucket =
|
||||
alt < 1500
|
||||
? 'street'
|
||||
@@ -358,43 +360,13 @@ export function createModel({ state: layerState, services, parts, source }) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether the active Google Photorealistic 3D Tileset (if any) has
|
||||
* finished loading the tiles in view. Shared mesh-floor sampling is gated on
|
||||
* this so a one-shot cell never bakes in a miss from still-streaming tiles.
|
||||
* Discovers + caches the tileset lazily from scene
|
||||
* primitives (the CCTV module holds only a `_viewer` reference). When no
|
||||
* tileset is present (OSM fallback) this returns true so ground sampling is
|
||||
* not permanently blocked.
|
||||
*
|
||||
* Task 5 (review correction, spec §2): a HIDDEN tileset (`show === false`,
|
||||
* i.e. a globe stack is active) must NOT report ready — Cesium 1.138's
|
||||
* the shared sampler can only inspect *visible* 3D tilesets, so a sample taken
|
||||
* against the hidden Google tileset would silently miss.
|
||||
*
|
||||
* @returns {boolean} True when tiles are loaded AND visible (or no tileset
|
||||
* exists to wait on).
|
||||
* Whether the photoreal tiles in view have finished loading; the geometry
|
||||
* part, which reads the scene, answers.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
||||
function projectionTilesReady() {
|
||||
if (
|
||||
!layerState._activeTileset ||
|
||||
layerState._activeTileset.isDestroyed?.()
|
||||
) {
|
||||
layerState._activeTileset = null;
|
||||
const primitives = layerState._viewer?.scene?.primitives;
|
||||
if (primitives && typeof primitives.get === 'function') {
|
||||
for (let i = 0; i < primitives.length; i++) {
|
||||
const p = primitives.get(i);
|
||||
if (p instanceof Cesium.Cesium3DTileset && !p.isDestroyed?.()) {
|
||||
layerState._activeTileset = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!layerState._activeTileset) return true;
|
||||
if (layerState._activeTileset.show === false) return false;
|
||||
return layerState._activeTileset.tilesLoaded === true;
|
||||
return parts.geometry.projectionTilesReady();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,30 +377,17 @@ export function createModel({ state: layerState, services, parts, source }) {
|
||||
* frame-up, so the 16:9 texture maps upright and unmirrored. Static geometry —
|
||||
* computed only on slider/save/activation, never per frame (§2b).
|
||||
* @param {Object} camera - Camera pose.
|
||||
* @param {Cesium.Cartesian3} capCenterPos - Plane center in ECEF.
|
||||
* @returns {Cesium.Quaternion}
|
||||
* @param {{x: number, y: number, z: number}} capCenterPos - Plane center in ECEF.
|
||||
* @returns {{x: number, y: number, z: number, w: number}} The quaternion.
|
||||
*/
|
||||
|
||||
function planeOrientationFor(camera, capCenterPos) {
|
||||
const frame = parts.geometry.frustumFrameEcef(camera, capCenterPos);
|
||||
const right = Cesium.Cartesian3.cross(
|
||||
frame.dir,
|
||||
frame.up,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const normal = Cesium.Cartesian3.negate(frame.dir, new Cesium.Cartesian3());
|
||||
const m = new Cesium.Matrix3(
|
||||
right.x,
|
||||
frame.up.x,
|
||||
normal.x,
|
||||
right.y,
|
||||
frame.up.y,
|
||||
normal.y,
|
||||
right.z,
|
||||
frame.up.z,
|
||||
normal.z,
|
||||
);
|
||||
return Cesium.Quaternion.fromRotationMatrix(m);
|
||||
return fromAxes({
|
||||
x: cross(frame.dir, frame.up),
|
||||
y: frame.up,
|
||||
z: negate(frame.dir),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user