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
@@ -2316,6 +2316,7 @@
|
|||||||
"src/render/cesium/common.js",
|
"src/render/cesium/common.js",
|
||||||
"src/render/cesium/internals.js",
|
"src/render/cesium/internals.js",
|
||||||
"src/layers/cctv/policy.js",
|
"src/layers/cctv/policy.js",
|
||||||
|
"src/render/color.js",
|
||||||
"src/layers/cctv/presentation.js",
|
"src/layers/cctv/presentation.js",
|
||||||
"src/layers/cctv/projection.js",
|
"src/layers/cctv/projection.js",
|
||||||
"src/layers/cctv/videoPlayback.js",
|
"src/layers/cctv/videoPlayback.js",
|
||||||
|
|||||||
@@ -365,9 +365,13 @@ test('camera icons are violet for video feeds, cyan for stills, amber when activ
|
|||||||
const color = (record) => icons.color(icons.row(record.camera.id));
|
const color = (record) => icons.color(icons.row(record.camera.id));
|
||||||
const bytes = (c) =>
|
const bytes = (c) =>
|
||||||
[c.red, c.green, c.blue, c.alpha].map(Cesium.Color.floatToByte);
|
[c.red, c.green, c.blue, c.alpha].map(Cesium.Color.floatToByte);
|
||||||
assert.deepEqual(bytes(color(idleVideo)), bytes(LIVE_CAMERA_COLOR));
|
const policyBytes = (rgba) => rgba.map(Cesium.Color.floatToByte);
|
||||||
assert.deepEqual(bytes(color(idleStill)), bytes(IDLE_CAMERA_COLOR));
|
assert.deepEqual(bytes(color(idleVideo)), policyBytes(LIVE_CAMERA_COLOR));
|
||||||
assert.deepEqual(bytes(color(activeVideo)), bytes(ACTIVE_CAMERA_COLOR));
|
assert.deepEqual(bytes(color(idleStill)), policyBytes(IDLE_CAMERA_COLOR));
|
||||||
|
assert.deepEqual(
|
||||||
|
bytes(color(activeVideo)),
|
||||||
|
policyBytes(ACTIVE_CAMERA_COLOR),
|
||||||
|
);
|
||||||
assert.equal(icons.scale(icons.row(activeVideo.camera.id)), 1.25);
|
assert.equal(icons.scale(icons.row(activeVideo.camera.id)), 1.25);
|
||||||
assert.equal(icons.scale(icons.row(idleVideo.camera.id)), 1);
|
assert.equal(icons.scale(icons.row(idleVideo.camera.id)), 1);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
PROBE_CLEARANCE_M,
|
PROBE_CLEARANCE_M,
|
||||||
COVERAGE_NEIGHBOR_RADIUS_KM,
|
COVERAGE_NEIGHBOR_RADIUS_KM,
|
||||||
COVERAGE_NEIGHBOR_LIMIT,
|
COVERAGE_NEIGHBOR_LIMIT,
|
||||||
IDLE_COVERAGE_COLOR,
|
IDLE_COVERAGE_COLOR as IDLE_COVERAGE_RGBA,
|
||||||
PLANE_FOOTPRINT_LIFT_CAP_M,
|
PLANE_FOOTPRINT_LIFT_CAP_M,
|
||||||
} from './policy.js';
|
} from './policy.js';
|
||||||
|
|
||||||
@@ -17,6 +17,9 @@ import {
|
|||||||
requiredPlaneLift,
|
requiredPlaneLift,
|
||||||
} from '../../data/cctvFootprint.js';
|
} from '../../data/cctvFootprint.js';
|
||||||
import { cctvPicks } from './pickState.js';
|
import { cctvPicks } from './pickState.js';
|
||||||
|
import { toColor } from '../../render/cesium/draw.js';
|
||||||
|
|
||||||
|
const IDLE_COVERAGE_COLOR = toColor(IDLE_COVERAGE_RGBA);
|
||||||
|
|
||||||
export function createGeometry({ state: layerState, services, parts, source }) {
|
export function createGeometry({ state: layerState, services, parts, source }) {
|
||||||
const { warmGroundFloor, cachedGroundFloor } = services.ground;
|
const { warmGroundFloor, cachedGroundFloor } = services.ground;
|
||||||
@@ -262,6 +265,46 @@ export function createGeometry({ state: layerState, services, parts, source }) {
|
|||||||
return Math.max(PROBE_MIN_RANGE_M, hitDistance - PROBE_CLEARANCE_M);
|
return Math.max(PROBE_MIN_RANGE_M, hitDistance - PROBE_CLEARANCE_M);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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).
|
||||||
|
*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a computeFrustumGeometry result into the Cartesian3 positions the
|
* Converts a computeFrustumGeometry result into the Cartesian3 positions the
|
||||||
* entities consume. Fresh objects per call (geometry updates are rare —
|
* entities consume. Fresh objects per call (geometry updates are rare —
|
||||||
@@ -836,6 +879,7 @@ export function createGeometry({ state: layerState, services, parts, source }) {
|
|||||||
activationProbeClampRange,
|
activationProbeClampRange,
|
||||||
frustumCartesians,
|
frustumCartesians,
|
||||||
frustumFrameEcef,
|
frustumFrameEcef,
|
||||||
|
projectionTilesReady,
|
||||||
applyFrustumGeometry,
|
applyFrustumGeometry,
|
||||||
updateRecordGeometry,
|
updateRecordGeometry,
|
||||||
buildCoverageVisibleSet,
|
buildCoverageVisibleSet,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as Cesium from 'cesium';
|
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||||
import {
|
import {
|
||||||
SUPPORT_KEYS,
|
SUPPORT_KEYS,
|
||||||
planeSupportPoints,
|
planeSupportPoints,
|
||||||
@@ -231,13 +231,15 @@ export function createGround({ state: layerState, services, parts, source }) {
|
|||||||
// stall a large one.
|
// stall a large one.
|
||||||
if (!record.frustumGeometry) {
|
if (!record.frustumGeometry) {
|
||||||
if (record.position) {
|
if (record.position) {
|
||||||
Cesium.Cartesian3.fromDegrees(
|
// In place: the record keeps its position object.
|
||||||
|
const { x, y, z } = fromDegrees(
|
||||||
record.camera.lon,
|
record.camera.lon,
|
||||||
record.camera.lat,
|
record.camera.lat,
|
||||||
record.camera.absoluteHeightM,
|
record.camera.absoluteHeightM,
|
||||||
undefined,
|
|
||||||
record.position,
|
|
||||||
);
|
);
|
||||||
|
record.position.x = x;
|
||||||
|
record.position.y = y;
|
||||||
|
record.position.z = z;
|
||||||
parts.rendering.moveCameraIcon(record);
|
parts.rendering.moveCameraIcon(record);
|
||||||
moved += 1;
|
moved += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+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 { greatCircleKm } from '../../geoDistance.js';
|
||||||
import { staticFrameRefreshMs } from '../../data/cctvLod.js';
|
import { staticFrameRefreshMs } from '../../data/cctvLod.js';
|
||||||
import { frameFetchDue, cardFetchPolicy } from '../../data/cctvCards.js';
|
import { frameFetchDue, cardFetchPolicy } from '../../data/cctvCards.js';
|
||||||
@@ -14,7 +16,7 @@ export function createModel({ state: layerState, services, parts, source }) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function toRad(deg) {
|
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);
|
const lon2 = lon1 + Math.atan2(y, x);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
lat: Cesium.Math.toDegrees(lat2),
|
lat: toDegrees(lat2),
|
||||||
lon: Cesium.Math.toDegrees(lon2),
|
lon: toDegrees(lon2),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,11 +335,11 @@ export function createModel({ state: layerState, services, parts, source }) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function currentViewContext() {
|
function currentViewContext() {
|
||||||
const carto = layerState._viewer?.camera?.positionCartographic;
|
const pose = findCamera(layerState._viewer)?.pose();
|
||||||
if (!carto) return 'none';
|
// An eye at the earth's centre has no geographic position.
|
||||||
const lat = Cesium.Math.toDegrees(carto.latitude);
|
if (!pose || !Number.isFinite(pose.lat)) return 'none';
|
||||||
const lon = Cesium.Math.toDegrees(carto.longitude);
|
const { lat, lon } = pose;
|
||||||
const alt = carto.height || 0;
|
const alt = pose.height || 0;
|
||||||
const zoomBucket =
|
const zoomBucket =
|
||||||
alt < 1500
|
alt < 1500
|
||||||
? 'street'
|
? 'street'
|
||||||
@@ -358,43 +360,13 @@ export function createModel({ state: layerState, services, parts, source }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports whether the active Google Photorealistic 3D Tileset (if any) has
|
* Whether the photoreal tiles in view have finished loading; the geometry
|
||||||
* finished loading the tiles in view. Shared mesh-floor sampling is gated on
|
* part, which reads the scene, answers.
|
||||||
* this so a one-shot cell never bakes in a miss from still-streaming tiles.
|
* @returns {boolean}
|
||||||
* 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).
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function projectionTilesReady() {
|
function projectionTilesReady() {
|
||||||
if (
|
return parts.geometry.projectionTilesReady();
|
||||||
!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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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 —
|
* frame-up, so the 16:9 texture maps upright and unmirrored. Static geometry —
|
||||||
* computed only on slider/save/activation, never per frame (§2b).
|
* computed only on slider/save/activation, never per frame (§2b).
|
||||||
* @param {Object} camera - Camera pose.
|
* @param {Object} camera - Camera pose.
|
||||||
* @param {Cesium.Cartesian3} capCenterPos - Plane center in ECEF.
|
* @param {{x: number, y: number, z: number}} capCenterPos - Plane center in ECEF.
|
||||||
* @returns {Cesium.Quaternion}
|
* @returns {{x: number, y: number, z: number, w: number}} The quaternion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function planeOrientationFor(camera, capCenterPos) {
|
function planeOrientationFor(camera, capCenterPos) {
|
||||||
const frame = parts.geometry.frustumFrameEcef(camera, capCenterPos);
|
const frame = parts.geometry.frustumFrameEcef(camera, capCenterPos);
|
||||||
const right = Cesium.Cartesian3.cross(
|
return fromAxes({
|
||||||
frame.dir,
|
x: cross(frame.dir, frame.up),
|
||||||
frame.up,
|
y: frame.up,
|
||||||
new Cesium.Cartesian3(),
|
z: negate(frame.dir),
|
||||||
);
|
});
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-24
@@ -1,7 +1,7 @@
|
|||||||
export { ACTIVE_FRAME_REFRESH_MS } from './sourcePolicy.js';
|
export { ACTIVE_FRAME_REFRESH_MS } from './sourcePolicy.js';
|
||||||
import * as Cesium from 'cesium';
|
|
||||||
import { CCTV_CARD_FETCH_BURST_SPACING_MS } from '../../data/cctvCards.js';
|
import { CCTV_CARD_FETCH_BURST_SPACING_MS } from '../../data/cctvCards.js';
|
||||||
import { CCTV_AMBIENT_CARD_MAX } from '../../data/cctvLod.js';
|
import { CCTV_AMBIENT_CARD_MAX } from '../../data/cctvLod.js';
|
||||||
|
import { hexColor } from '../../render/color.js';
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// API endpoints
|
// API endpoints
|
||||||
@@ -434,44 +434,33 @@ export const CAMERA_SEEDS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Visual style constants
|
// Visual style constants: renderer colours, [r, g, b, a] in 0..1
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export const IDLE_CAMERA_COLOR =
|
export const IDLE_CAMERA_COLOR = hexColor('#6be8ff', 0.88);
|
||||||
Cesium.Color.fromCssColorString('#6be8ff').withAlpha(0.88);
|
|
||||||
|
|
||||||
export const ACTIVE_CAMERA_COLOR =
|
export const ACTIVE_CAMERA_COLOR = hexColor('#ffd97a', 0.95);
|
||||||
Cesium.Color.fromCssColorString('#ffd97a').withAlpha(0.95);
|
|
||||||
|
|
||||||
export const LIVE_CAMERA_COLOR =
|
export const LIVE_CAMERA_COLOR = hexColor('#b48cff', 0.88);
|
||||||
Cesium.Color.fromCssColorString('#b48cff').withAlpha(0.88);
|
|
||||||
|
|
||||||
export const IDLE_COVERAGE_COLOR =
|
export const IDLE_COVERAGE_COLOR = hexColor('#2fe0ff', 0.24);
|
||||||
Cesium.Color.fromCssColorString('#2fe0ff').withAlpha(0.24);
|
|
||||||
|
|
||||||
export const IDLE_COVERAGE_CENTER_MUTED =
|
export const IDLE_COVERAGE_CENTER_MUTED = hexColor('#2fe0ff', 0.2);
|
||||||
Cesium.Color.fromCssColorString('#2fe0ff').withAlpha(0.2);
|
|
||||||
|
|
||||||
export const IDLE_COVERAGE_EDGE_MUTED =
|
export const IDLE_COVERAGE_EDGE_MUTED = hexColor('#2fe0ff', 0.18);
|
||||||
Cesium.Color.fromCssColorString('#2fe0ff').withAlpha(0.18);
|
|
||||||
|
|
||||||
export const ACTIVE_COVERAGE_EDGE =
|
export const ACTIVE_COVERAGE_EDGE = hexColor('#8dff87', 0.58);
|
||||||
Cesium.Color.fromCssColorString('#8dff87').withAlpha(0.58);
|
|
||||||
|
|
||||||
export const ACTIVE_COVERAGE_CENTER =
|
export const ACTIVE_COVERAGE_CENTER = hexColor('#d7ff8d', 0.82);
|
||||||
Cesium.Color.fromCssColorString('#d7ff8d').withAlpha(0.82);
|
|
||||||
|
|
||||||
// H6: dimmer depth-fail materials let the active frustum wireframe read
|
// H6: dimmer depth-fail materials let the active frustum wireframe read
|
||||||
// through buildings while in monitor fallback mode.
|
// through buildings while in monitor fallback mode.
|
||||||
|
|
||||||
export const ACTIVE_COVERAGE_EDGE_DEPTHFAIL =
|
export const ACTIVE_COVERAGE_EDGE_DEPTHFAIL = hexColor('#8dff87', 0.18);
|
||||||
Cesium.Color.fromCssColorString('#8dff87').withAlpha(0.18);
|
|
||||||
|
|
||||||
export const ACTIVE_COVERAGE_CENTER_DEPTHFAIL =
|
export const ACTIVE_COVERAGE_CENTER_DEPTHFAIL = hexColor('#d7ff8d', 0.26);
|
||||||
Cesium.Color.fromCssColorString('#d7ff8d').withAlpha(0.26);
|
|
||||||
|
|
||||||
export const PLANE_OUTLINE_COLOR =
|
export const PLANE_OUTLINE_COLOR = hexColor('#6be8ff', 0.55);
|
||||||
Cesium.Color.fromCssColorString('#6be8ff').withAlpha(0.55);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Card budget while the staggered geometry drain is running — the raised
|
* Card budget while the staggered geometry drain is running — the raised
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ import * as Cesium from 'cesium';
|
|||||||
import {
|
import {
|
||||||
CCTV_PROJECTION_OVERLAY_SOURCE_ID,
|
CCTV_PROJECTION_OVERLAY_SOURCE_ID,
|
||||||
CCTV_PROJECTION_OVERLAY_SOURCE_OPTIONS,
|
CCTV_PROJECTION_OVERLAY_SOURCE_OPTIONS,
|
||||||
PLANE_OUTLINE_COLOR,
|
PLANE_OUTLINE_COLOR as PLANE_OUTLINE_RGBA,
|
||||||
PROJECTION_CANVAS_WIDTH,
|
PROJECTION_CANVAS_WIDTH,
|
||||||
PROJECTION_CANVAS_HEIGHT,
|
PROJECTION_CANVAS_HEIGHT,
|
||||||
} from './policy.js';
|
} from './policy.js';
|
||||||
import { cctvPicks } from './pickState.js';
|
import { cctvPicks } from './pickState.js';
|
||||||
|
import { toColor } from '../../render/cesium/draw.js';
|
||||||
|
|
||||||
|
const PLANE_OUTLINE_COLOR = toColor(PLANE_OUTLINE_RGBA);
|
||||||
|
|
||||||
export function createProjection({
|
export function createProjection({
|
||||||
state: layerState,
|
state: layerState,
|
||||||
@@ -17,6 +20,12 @@ export function createProjection({
|
|||||||
}) {
|
}) {
|
||||||
const { holdContinuousRender, releaseContinuousRender } = services.render;
|
const { holdContinuousRender, releaseContinuousRender } = services.render;
|
||||||
|
|
||||||
|
/** The monitor plane's orientation, as the Cesium quaternion its entity takes. */
|
||||||
|
function planeOrientation(camera, capCenter) {
|
||||||
|
const q = parts.model.planeOrientationFor(camera, capCenter);
|
||||||
|
return new Cesium.Quaternion(q.x, q.y, q.z, q.w);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the protected label associated with one active monitor plane.
|
* Build the protected label associated with one active monitor plane.
|
||||||
* @param {{cameraId: string, name: string, position: Cesium.Cartesian3|Function}} input
|
* @param {{cameraId: string, name: string, position: Cesium.Cartesian3|Function}} input
|
||||||
@@ -67,7 +76,7 @@ export function createProjection({
|
|||||||
const positions =
|
const positions =
|
||||||
record.frustumPositions || parts.geometry.frustumCartesians(geometry);
|
record.frustumPositions || parts.geometry.frustumCartesians(geometry);
|
||||||
runtime.planeEntity.position = positions.capCenter;
|
runtime.planeEntity.position = positions.capCenter;
|
||||||
runtime.planeEntity.orientation = parts.model.planeOrientationFor(
|
runtime.planeEntity.orientation = planeOrientation(
|
||||||
record.camera,
|
record.camera,
|
||||||
positions.capCenter,
|
positions.capCenter,
|
||||||
);
|
);
|
||||||
@@ -122,6 +131,11 @@ export function createProjection({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A plain white plane material, for a plane with no media (tests). */
|
||||||
|
function plainPlaneMaterial() {
|
||||||
|
return new Cesium.ColorMaterialProperty(Cesium.Color.WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
/** Create the native monitor plane plus its cached host-label presentation. */
|
/** Create the native monitor plane plus its cached host-label presentation. */
|
||||||
|
|
||||||
function createProjectionPlane(record, runtime, geometry, positions) {
|
function createProjectionPlane(record, runtime, geometry, positions) {
|
||||||
@@ -137,10 +151,7 @@ export function createProjection({
|
|||||||
id: `cctv-${record.camera.id}-plane`,
|
id: `cctv-${record.camera.id}-plane`,
|
||||||
show: false,
|
show: false,
|
||||||
position: positions.capCenter,
|
position: positions.capCenter,
|
||||||
orientation: parts.model.planeOrientationFor(
|
orientation: planeOrientation(record.camera, positions.capCenter),
|
||||||
record.camera,
|
|
||||||
positions.capCenter,
|
|
||||||
),
|
|
||||||
plane: {
|
plane: {
|
||||||
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
|
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
|
||||||
dimensions: new Cesium.Cartesian2(
|
dimensions: new Cesium.Cartesian2(
|
||||||
@@ -428,6 +439,7 @@ export function createProjection({
|
|||||||
updatePlanePlacement,
|
updatePlanePlacement,
|
||||||
clearProjectionOverlay,
|
clearProjectionOverlay,
|
||||||
setPlaneVisible,
|
setPlaneVisible,
|
||||||
|
plainPlaneMaterial,
|
||||||
createProjectionPlane,
|
createProjectionPlane,
|
||||||
createProjectionRuntime,
|
createProjectionRuntime,
|
||||||
ensureProjectionRuntime,
|
ensureProjectionRuntime,
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import * as Cesium from 'cesium';
|
import * as Cesium from 'cesium';
|
||||||
import { isHeadingEstimated } from './headingConfidence.js';
|
import { isHeadingEstimated } from './headingConfidence.js';
|
||||||
import {
|
import {
|
||||||
ACTIVE_CAMERA_COLOR,
|
ACTIVE_CAMERA_COLOR as ACTIVE_CAMERA_RGBA,
|
||||||
CAMERA_ICON,
|
CAMERA_ICON,
|
||||||
IDLE_CAMERA_COLOR,
|
IDLE_CAMERA_COLOR as IDLE_CAMERA_RGBA,
|
||||||
LIVE_CAMERA_COLOR,
|
LIVE_CAMERA_COLOR as LIVE_CAMERA_RGBA,
|
||||||
ACTIVE_COVERAGE_CENTER,
|
ACTIVE_COVERAGE_CENTER as ACTIVE_COVERAGE_CENTER_RGBA,
|
||||||
IDLE_COVERAGE_CENTER_MUTED,
|
IDLE_COVERAGE_CENTER_MUTED as IDLE_COVERAGE_CENTER_MUTED_RGBA,
|
||||||
ACTIVE_COVERAGE_CENTER_DEPTHFAIL,
|
ACTIVE_COVERAGE_CENTER_DEPTHFAIL as ACTIVE_COVERAGE_CENTER_DEPTHFAIL_RGBA,
|
||||||
ACTIVE_COVERAGE_EDGE,
|
ACTIVE_COVERAGE_EDGE as ACTIVE_COVERAGE_EDGE_RGBA,
|
||||||
IDLE_COVERAGE_EDGE_MUTED,
|
IDLE_COVERAGE_EDGE_MUTED as IDLE_COVERAGE_EDGE_MUTED_RGBA,
|
||||||
ACTIVE_COVERAGE_EDGE_DEPTHFAIL,
|
ACTIVE_COVERAGE_EDGE_DEPTHFAIL as ACTIVE_COVERAGE_EDGE_DEPTHFAIL_RGBA,
|
||||||
VIEW_CELL_PX,
|
VIEW_CELL_PX,
|
||||||
VIEW_ICON_MARGIN,
|
VIEW_ICON_MARGIN,
|
||||||
VIEW_MIN_CELL_M,
|
VIEW_MIN_CELL_M,
|
||||||
@@ -19,6 +19,22 @@ import { createIconSet } from '../../data/iconSet.js';
|
|||||||
import { writeHoldSegment } from '../../data/iconSegment.js';
|
import { writeHoldSegment } from '../../data/iconSegment.js';
|
||||||
import { IconSetPrimitive } from '../../data/iconSetPrimitive.js';
|
import { IconSetPrimitive } from '../../data/iconSetPrimitive.js';
|
||||||
import { iconAtlas } from '../../data/iconAtlas.js';
|
import { iconAtlas } from '../../data/iconAtlas.js';
|
||||||
|
import { toColor } from '../../render/cesium/draw.js';
|
||||||
|
|
||||||
|
// The policy's renderer colours as the Cesium colours the icons and lines take.
|
||||||
|
const ACTIVE_CAMERA_COLOR = toColor(ACTIVE_CAMERA_RGBA);
|
||||||
|
const IDLE_CAMERA_COLOR = toColor(IDLE_CAMERA_RGBA);
|
||||||
|
const LIVE_CAMERA_COLOR = toColor(LIVE_CAMERA_RGBA);
|
||||||
|
const ACTIVE_COVERAGE_CENTER = toColor(ACTIVE_COVERAGE_CENTER_RGBA);
|
||||||
|
const IDLE_COVERAGE_CENTER_MUTED = toColor(IDLE_COVERAGE_CENTER_MUTED_RGBA);
|
||||||
|
const ACTIVE_COVERAGE_CENTER_DEPTHFAIL = toColor(
|
||||||
|
ACTIVE_COVERAGE_CENTER_DEPTHFAIL_RGBA,
|
||||||
|
);
|
||||||
|
const ACTIVE_COVERAGE_EDGE = toColor(ACTIVE_COVERAGE_EDGE_RGBA);
|
||||||
|
const IDLE_COVERAGE_EDGE_MUTED = toColor(IDLE_COVERAGE_EDGE_MUTED_RGBA);
|
||||||
|
const ACTIVE_COVERAGE_EDGE_DEPTHFAIL = toColor(
|
||||||
|
ACTIVE_COVERAGE_EDGE_DEPTHFAIL_RGBA,
|
||||||
|
);
|
||||||
|
|
||||||
/** The camera icon's drawn size (px). */
|
/** The camera icon's drawn size (px). */
|
||||||
const CAMERA_ICON_PX = 24;
|
const CAMERA_ICON_PX = 24;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function assertKeepsColor(icons, id, base, label) {
|
|||||||
[actual.red, actual.green, actual.blue, actual.alpha].map(
|
[actual.red, actual.green, actual.blue, actual.alpha].map(
|
||||||
Cesium.Color.floatToByte,
|
Cesium.Color.floatToByte,
|
||||||
),
|
),
|
||||||
[base.red, base.green, base.blue, base.alpha].map(Cesium.Color.floatToByte),
|
base.map(Cesium.Color.floatToByte),
|
||||||
`${label}: base color kept`,
|
`${label}: base color kept`,
|
||||||
);
|
);
|
||||||
assert.equal(icons.focus(row), FOCUS_FACTOR, `${label}: focus`);
|
assert.equal(icons.focus(row), FOCUS_FACTOR, `${label}: focus`);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
|
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
|
||||||
import * as Cesium from 'cesium';
|
|
||||||
import { cctvPicks } from './pickState.js';
|
import { cctvPicks } from './pickState.js';
|
||||||
|
|
||||||
export function createSelection({
|
export function createSelection({
|
||||||
@@ -199,7 +198,7 @@ export function createSelection({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts a camera ID from a Cesium pick result by checking icon row IDs,
|
* Extracts a camera ID from a scene pick result by checking icon row IDs,
|
||||||
* primitive IDs, and the camera ids the layer keeps for its coverage entities.
|
* primitive IDs, and the camera ids the layer keeps for its coverage entities.
|
||||||
* @param {Object|null} picked - Result from scene.pick().
|
* @param {Object|null} picked - Result from scene.pick().
|
||||||
* @returns {string|null} Camera ID, or null if the pick is not a CCTV entity.
|
* @returns {string|null} Camera ID, or null if the pick is not a CCTV entity.
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as Cesium from 'cesium';
|
|
||||||
|
|
||||||
export function createState({ services }) {
|
export function createState({ services }) {
|
||||||
const {
|
const {
|
||||||
clearOverlaySource,
|
clearOverlaySource,
|
||||||
@@ -76,11 +74,13 @@ export function createState({ services }) {
|
|||||||
|
|
||||||
layerState._activeFocusStyleCount = 0;
|
layerState._activeFocusStyleCount = 0;
|
||||||
|
|
||||||
layerState._scratchFocusScreen = new Cesium.Cartesian2();
|
// Screen-point scratches: the projections that fill them write only x and y.
|
||||||
|
layerState._scratchFocusScreen = { x: 0, y: 0 };
|
||||||
|
|
||||||
layerState._scratchViewScreen = new Cesium.Cartesian2();
|
layerState._scratchViewScreen = { x: 0, y: 0 };
|
||||||
|
|
||||||
layerState._scratchViewProjection = new Cesium.Matrix4();
|
/** The view pass's view-projection matrix, column-major. */
|
||||||
|
layerState._scratchViewProjection = new Float64Array(16);
|
||||||
|
|
||||||
// Counts view passes; a record shown by the latest pass carries its number.
|
// Counts view passes; a record shown by the latest pass carries its number.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as Cesium from 'cesium';
|
|
||||||
import { createIconSet } from '../../data/iconSet.js';
|
import { createIconSet } from '../../data/iconSet.js';
|
||||||
|
|
||||||
export function createTesting({ state: layerState, services, parts, source }) {
|
export function createTesting({ state: layerState, services, parts, source }) {
|
||||||
@@ -41,9 +40,10 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
|||||||
const runtime = {
|
const runtime = {
|
||||||
cameraId: String(record.camera.id),
|
cameraId: String(record.camera.id),
|
||||||
planeEntity: null,
|
planeEntity: null,
|
||||||
labelPosition: new Cesium.Cartesian3(),
|
// createProjectionPlane gives it its label position.
|
||||||
|
labelPosition: null,
|
||||||
overlayEntry: null,
|
overlayEntry: null,
|
||||||
planeMaterial: new Cesium.ColorMaterialProperty(Cesium.Color.WHITE),
|
planeMaterial: parts.projection.plainPlaneMaterial(),
|
||||||
};
|
};
|
||||||
parts.projection.createProjectionPlane(
|
parts.projection.createProjectionPlane(
|
||||||
record,
|
record,
|
||||||
|
|||||||
@@ -43,16 +43,10 @@
|
|||||||
"src/layers/cctv/cards.js",
|
"src/layers/cctv/cards.js",
|
||||||
"src/layers/cctv/geometry.js",
|
"src/layers/cctv/geometry.js",
|
||||||
"src/layers/cctv/geometryQueue.js",
|
"src/layers/cctv/geometryQueue.js",
|
||||||
"src/layers/cctv/ground.js",
|
|
||||||
"src/layers/cctv/lifecycle.js",
|
"src/layers/cctv/lifecycle.js",
|
||||||
"src/layers/cctv/model.js",
|
|
||||||
"src/layers/cctv/navigation.js",
|
"src/layers/cctv/navigation.js",
|
||||||
"src/layers/cctv/policy.js",
|
|
||||||
"src/layers/cctv/projection.js",
|
"src/layers/cctv/projection.js",
|
||||||
"src/layers/cctv/rendering.js",
|
"src/layers/cctv/rendering.js",
|
||||||
"src/layers/cctv/selection.js",
|
|
||||||
"src/layers/cctv/state.js",
|
|
||||||
"src/layers/cctv/testing.js",
|
|
||||||
"src/layers/directions/index.js",
|
"src/layers/directions/index.js",
|
||||||
"src/layers/firms/rendering.js",
|
"src/layers/firms/rendering.js",
|
||||||
"src/layers/flights/controller.js",
|
"src/layers/flights/controller.js",
|
||||||
|
|||||||
Reference in new issue
Block a user