mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
Move the installations layer's camera, geometry and colours onto renderer ports
The layer's view rectangle, wide-view pose, flights and camera events now go through the camera port, and its distance and position maths through the geo helpers: getNearby confirms candidates with the ported ellipsoidal geodesic, as before, and returns plain ECEF positions. Class colours are renderer colours; the entities convert them. The layer's camera `changed` listener has its own 0.01 threshold on the port, the sensitivity it already claimed while on; the claim stays for other raw camera listeners. Controls, lifecycle, model, state and viewport no longer import Cesium and leave the allow-list. Rendering and the named markers stay on Cesium: the site markers are entities because the camera follows them on double-click and the tracked card reads its title and position from them, and the entity data source moves from lifecycle into rendering. Rendering loads the unbound camera factory for the parts that reach the port. The test camera bound over a Cesium-shaped fake now answers its view rectangle from the fake's computeViewRectangle when it has one.
This commit is contained in:
1 parent
e74c7c1f44
commit
1d2b853576
18 files changed
+126
-90
No files matched your search
@@ -1,5 +1,8 @@
|
||||
import { installationClassLabel, installationTitle } from './classLabel.js';
|
||||
import * as Cesium from 'cesium';
|
||||
// Still Cesium for its entities, so this layer loads the unbound camera
|
||||
// factory its other parts reach the renderer through.
|
||||
import '../../render/cesium/camera.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { LAYER_ID, MAX_RENDERED, COLOR_BY_CLASS } from './policy.js';
|
||||
import { entityRecord } from '../../data/entityRecords.js';
|
||||
@@ -21,6 +24,29 @@ export function createRendering({
|
||||
const { governorRequestRender } = services.render;
|
||||
const { warmFireAnchorFloors } = services.anchors;
|
||||
|
||||
/** A record's class colour, for the entities. */
|
||||
function colorFor(record) {
|
||||
const [r, g, b, a] = parts.model.colorFor(record);
|
||||
return new Cesium.Color(r, g, b, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The layer's entities. They stay entities: the camera can follow a site
|
||||
* (double-click), and the tracked card reads what it shows from them.
|
||||
*/
|
||||
function attach(viewer) {
|
||||
layerState.dataSource = new Cesium.CustomDataSource(
|
||||
'military-installations',
|
||||
);
|
||||
viewer.dataSources.add(layerState.dataSource);
|
||||
}
|
||||
|
||||
function detach(viewer) {
|
||||
if (layerState.dataSource && viewer)
|
||||
viewer.dataSources.remove(layerState.dataSource, true);
|
||||
layerState.dataSource = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared rendered-surface height for an installation anchor or footprint.
|
||||
* @param {{latitude:number, longitude:number}} record Installation record.
|
||||
@@ -65,7 +91,7 @@ export function createRendering({
|
||||
const footprints =
|
||||
record.footprints || (record.footprint ? [[record.footprint]] : []);
|
||||
const material = new Cesium.ColorMaterialProperty(
|
||||
parts.model.colorFor(record).withAlpha(0.22),
|
||||
colorFor(record).withAlpha(0.22),
|
||||
);
|
||||
for (let i = 0; i < footprints.length; i++) {
|
||||
const rings = footprints[i];
|
||||
@@ -207,7 +233,7 @@ export function createRendering({
|
||||
for (const [id, rendered] of [...layerState.renderedKeys])
|
||||
if (keys.get(id) !== rendered.key) removeRecordEntities(id);
|
||||
for (const record of records) {
|
||||
const color = parts.model.colorFor(record);
|
||||
const color = colorFor(record);
|
||||
const surfaceHeightM = installationSurfaceHeightM(record);
|
||||
const displayPosition = Cesium.Cartesian3.fromDegrees(
|
||||
record.longitude,
|
||||
@@ -357,6 +383,8 @@ export function createRendering({
|
||||
});
|
||||
}
|
||||
return {
|
||||
attach,
|
||||
detach,
|
||||
installationSurfaceHeightM,
|
||||
clearSelectionFill,
|
||||
syncSelectionFill,
|
||||
|
||||
Reference in new issue
Block a user