mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge main through #1319 into the renderer seam
Brings in range ring visibility and sonar pulses (#1518, #1519), the drone airspace layer (#1086), the Houston CCTV pack (#1125), typed chat (#1507, #1545), in-view ground sampling for infrastructure (#1464) and the CCTV model specs refresh (#1319). What main added that reached Cesium or the viewer: - Drone airspace draws its zones as clamped fills and draped boundary lines in draw sets and takes clicks from the input dispatcher, as fire perimeters does. - Infrastructure ground sampling tests the view frustum and the horizon from the camera port's pose (geo/frustum, geo/horizon) and reads loaded terrain through the height queries. - The awareness lifecycle reads the canvas, frames and whether the camera controls take input through the ports. The sonar echo field measures with the geo helpers. - The range ring's pulses need a disc whose fill is computed per pixel from values set each frame, and an outlined line whose opacity changes without a rebuild. The draw port has neither, so that code keeps to one module, src/layers/awareness/rangeRingCesium.js, which is on the Cesium allow-list until the draw port can draw them. It draws only on a viewer with a Cesium primitive collection, and takes its primitives out of the collection it drew them in. On the stub the layer draws the ring without pulses as a haloed line through the draw port. Also from review of the previous merge: tests that the scene's viewer hooks install the zoom-out guard, and that an ambiguous area name is settled by the ground at mid-screen, else where the camera stands.
This commit is contained in:
commit
b9f8ac1ff0
141 files changed
+16192
-412
No files matched your search
@@ -2355,72 +2355,86 @@ test('the fires layer draws its heat cells as ground fills through the Cesium dr
|
||||
assert.equal(grounds().length, 0);
|
||||
});
|
||||
|
||||
test('the context layer draws its rim as an outlined ellipse on a viewer of its own', async () => {
|
||||
test('the context layer draws its static range ring as a haloed line on a viewer of its own', async () => {
|
||||
const { createRendering } =
|
||||
await import('../../layers/awareness/rendering.js');
|
||||
const { createState } = await import('../../layers/awareness/state.js');
|
||||
const { scene } = drawOver();
|
||||
const state = createState({ services: {} });
|
||||
state.viewer = { scene };
|
||||
const rendering = createRendering({
|
||||
state,
|
||||
services: {
|
||||
geometry: {},
|
||||
render: { governorRequestRender() {} },
|
||||
},
|
||||
parts: {},
|
||||
});
|
||||
const subject = (lon) => ({
|
||||
layerId: 'military',
|
||||
id: 'a',
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, 0, 9000),
|
||||
});
|
||||
rendering.renderVisual(subject(0));
|
||||
const outlineOf = () => {
|
||||
const [host] = scene.added;
|
||||
const primitives = [];
|
||||
for (let i = 0; i < host.length; i++) primitives.push(host.get(i));
|
||||
const outline = primitives.find(
|
||||
(p) =>
|
||||
p instanceof Cesium.Primitive &&
|
||||
p.geometryInstances.geometry instanceof Cesium.EllipseOutlineGeometry,
|
||||
);
|
||||
assert.ok(outline, 'an outline geometry, as the entity drew');
|
||||
withImageClasses(() => {
|
||||
// A viewer whose scene keeps no Cesium primitive collection of its own
|
||||
// (this double's `primitives`) gets the ring without its pulses.
|
||||
const { scene } = drawOver();
|
||||
const state = createState({ services: {} });
|
||||
state.viewer = { scene };
|
||||
const rendering = createRendering({
|
||||
state,
|
||||
services: {
|
||||
geometry: {},
|
||||
render: { governorRequestRender() {} },
|
||||
},
|
||||
parts: {},
|
||||
});
|
||||
const subject = (lon) => ({
|
||||
layerId: 'military',
|
||||
id: 'a',
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, 0, 9000),
|
||||
});
|
||||
rendering.renderVisual(subject(0));
|
||||
const linesOf = (from = scene) => {
|
||||
const [host] = from.added;
|
||||
const lines = [];
|
||||
for (let i = 0; i < host.length; i++) {
|
||||
const collection = host.get(i);
|
||||
if (!(collection instanceof Cesium.PolylineCollection)) continue;
|
||||
for (let j = 0; j < collection.length; j++)
|
||||
lines.push(collection.get(j));
|
||||
}
|
||||
return lines.sort((x, y) => y.width - x.width);
|
||||
};
|
||||
const [halo, core] = linesOf();
|
||||
assert.equal(linesOf().length, 2, 'a halo and a core, nothing else');
|
||||
assert.equal(halo.width, 4);
|
||||
assert.equal(core.width, 3);
|
||||
assert.equal(core.material.type, 'Color');
|
||||
assert.ok(
|
||||
!primitives.some(
|
||||
(p) =>
|
||||
p instanceof Cesium.Primitive &&
|
||||
p.geometryInstances.geometry instanceof Cesium.EllipseGeometry,
|
||||
core.material.uniforms.color.equalsEpsilon(
|
||||
Cesium.Color.fromCssColorString('rgba(98, 181, 255, 0.95)'),
|
||||
1e-9,
|
||||
),
|
||||
'and no fill',
|
||||
);
|
||||
return outline;
|
||||
};
|
||||
const outline = outlineOf();
|
||||
const { geometry, attributes } = outline.geometryInstances;
|
||||
assert.equal(geometry._semiMajorAxis, 250_000);
|
||||
assert.equal(geometry._height, 2_500);
|
||||
const center = Cesium.Cartographic.fromCartesian(geometry._center);
|
||||
assert.ok(Math.abs(center.longitude) < 1e-9);
|
||||
assert.deepEqual(
|
||||
[...attributes.color.value],
|
||||
[0x62, 0xb5, 0xff, Math.round(0.72 * 255)],
|
||||
);
|
||||
// Small moves keep the ring; one past 250 m moves it.
|
||||
rendering.renderVisual(subject(0.001));
|
||||
assert.equal(outlineOf(), outline);
|
||||
rendering.renderVisual(subject(0.01));
|
||||
assert.notEqual(outlineOf(), outline);
|
||||
// Re-initialized on another viewer, the same subject's rim moves there.
|
||||
const other = drawOver().scene;
|
||||
state.viewer = { scene: other };
|
||||
rendering.renderVisual(subject(0.01));
|
||||
assert.equal(scene.added.length, 0, 'gone from the old viewer');
|
||||
assert.equal(other.added.length, 1, 'drawn on the new one');
|
||||
rendering.clearVisual();
|
||||
assert.equal(other.added[0].length, 1, 'only the empty polyline collection');
|
||||
rendering.disposeVisual();
|
||||
assert.equal(other.added.length, 0);
|
||||
assert.ok(
|
||||
halo.material.uniforms.color.equalsEpsilon(
|
||||
Cesium.Color.fromCssColorString('rgba(4, 12, 16, 0.8)'),
|
||||
1e-9,
|
||||
),
|
||||
);
|
||||
// A closed ring 250 km from the subject's ground point, 2.5 km up.
|
||||
const ground = Cesium.Cartesian3.fromDegrees(0, 0, 2_500);
|
||||
assert.equal(core.positions.length, 129);
|
||||
for (const position of core.positions) {
|
||||
const away = Cesium.Cartesian3.distance(ground, position);
|
||||
assert.ok(Math.abs(away - 250_000) < 2_000, `${away}`);
|
||||
assert.ok(
|
||||
Math.abs(Cesium.Cartographic.fromCartesian(position).height - 2_500) <
|
||||
1,
|
||||
);
|
||||
}
|
||||
// Small moves keep the ring; one past 250 m moves it.
|
||||
const first = core.positions[0];
|
||||
rendering.renderVisual(subject(0.001));
|
||||
assert.ok(Cesium.Cartesian3.equals(linesOf()[1].positions[0], first));
|
||||
rendering.renderVisual(subject(0.01));
|
||||
assert.ok(!Cesium.Cartesian3.equals(linesOf()[1].positions[0], first));
|
||||
// Re-initialized on another viewer, the same subject's ring moves there.
|
||||
const other = drawOver().scene;
|
||||
state.viewer = { scene: other };
|
||||
rendering.renderVisual(subject(0.01));
|
||||
assert.equal(scene.added.length, 0, 'gone from the old viewer');
|
||||
assert.equal(linesOf(other).length, 2, 'drawn on the new one');
|
||||
rendering.clearVisual();
|
||||
assert.equal(linesOf(other).length, 0);
|
||||
rendering.disposeVisual();
|
||||
assert.equal(other.added.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('the installations layer draws its named markers as outlined point primitives on a viewer of its own', async () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
maxPitchForHeight,
|
||||
MAXIMUM_ZOOM_DISTANCE_M,
|
||||
} from './zoomOutGuard.js';
|
||||
import { applicationViewerHooks } from './application.js';
|
||||
|
||||
const deg = Cesium.Math.toDegrees;
|
||||
const { WHEEL, PINCH, RIGHT_DRAG, LEFT_DRAG, MIDDLE_DRAG } =
|
||||
@@ -762,3 +763,41 @@ test('a tracked camera cannot climb past the ceiling from its target', () => {
|
||||
s.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
test("the application scene's viewer hooks install the guard on the viewer and hand back its disposer", () => {
|
||||
const controller = { maximumZoomDistance: Infinity };
|
||||
const scene = {
|
||||
mode: Cesium.SceneMode.SCENE3D,
|
||||
screenSpaceCameraController: controller,
|
||||
preRender: new Cesium.Event(),
|
||||
postUpdate: new Cesium.Event(),
|
||||
};
|
||||
const camera = {
|
||||
position: Cesium.Cartesian3.fromDegrees(0, 0, 1_000_000),
|
||||
positionCartographic: { height: 1_000_000 },
|
||||
};
|
||||
const viewer = { scene, camera, canvas: new EventTarget() };
|
||||
const handoffs = new Set();
|
||||
const dispose = applicationViewerHooks(viewer).installZoomOutGuard({
|
||||
subscribeCameraHandoff(listener) {
|
||||
handoffs.add(listener);
|
||||
return () => handoffs.delete(listener);
|
||||
},
|
||||
createAggregator: () => ({
|
||||
isMoving: () => false,
|
||||
reset() {},
|
||||
destroy() {},
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(controller.maximumZoomDistance, MAXIMUM_ZOOM_DISTANCE_M);
|
||||
assert.equal(scene.preRender.numberOfListeners, 1);
|
||||
assert.equal(scene.postUpdate.numberOfListeners, 1);
|
||||
assert.equal(handoffs.size, 1);
|
||||
|
||||
dispose();
|
||||
assert.equal(controller.maximumZoomDistance, Infinity);
|
||||
assert.equal(scene.preRender.numberOfListeners, 0);
|
||||
assert.equal(scene.postUpdate.numberOfListeners, 0);
|
||||
assert.equal(handoffs.size, 0);
|
||||
});
|
||||
Reference in new issue
Block a user