mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the context rim through the renderer's draw port
The Contacts layer's 250 km rim is now an outline-only ellipse in a draw set of its own, taken from drawOf(viewer) when it is first drawn: the same colour, height and radius, moved only after the subject travels 250 m, cleared with the subject and disposed with the layer. A rim drawn on another viewer is redrawn on the current one. The Cesium draw port draws the outlines of ellipses it does not clamp as the entities did, with an outline geometry. The layer's positions are plain ECEF from src/geo rather than Cesium objects, the compass reads the camera through its port's pose, and its flights go through cameraOf from the renderer bridge. Its four files leave the Cesium allow-list; a caller handing the layer a viewer of its own loads ./render/cesium/unbound first, as for earthquakes.
This commit is contained in:
1 parent
6e23d2aac9
commit
df1143485a
14 files changed
+272
-154
No files matched your search
@@ -11,22 +11,24 @@ import { useAwarenessDirectionStore } from '../../ui/stores/awarenessDirection.j
|
||||
import AwarenessDirection from '../../ui/views/panels/AwarenessDirection.vue';
|
||||
import { createState } from './state.js';
|
||||
import { createRendering } from './rendering.js';
|
||||
import { bindRenderer } from '../../render/rendererOf.js';
|
||||
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
/** The rendering part over a subject with one military contact due east. */
|
||||
function overlay(screenAngle) {
|
||||
const state = createState({ services: {} });
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
const subject = Cesium.Cartesian3.fromDegrees(0, 0, 1000);
|
||||
const camera = fakeCameraPort({
|
||||
pose: { heading: 0, right: { x: 0, y: 1, z: 0 }, up: { x: 0, y: 0, z: 1 } },
|
||||
});
|
||||
const viewer = {
|
||||
container,
|
||||
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
|
||||
};
|
||||
bindRenderer(viewer, { camera: camera.port });
|
||||
Object.assign(state, {
|
||||
viewer: {
|
||||
container,
|
||||
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
|
||||
camera: {
|
||||
heading: 0,
|
||||
rightWC: new Cesium.Cartesian3(0, 1, 0),
|
||||
upWC: new Cesium.Cartesian3(0, 0, 1),
|
||||
},
|
||||
},
|
||||
viewer,
|
||||
enabled: true,
|
||||
subject: { position: subject, layerId: 'military' },
|
||||
results: {
|
||||
@@ -65,7 +67,7 @@ function overlay(screenAngle) {
|
||||
},
|
||||
parts: {},
|
||||
});
|
||||
return { state, container, rendering };
|
||||
return { state, container, rendering, camera };
|
||||
}
|
||||
|
||||
test('the overlay publishes the compass and the nearest contact bearings', () => {
|
||||
@@ -108,14 +110,14 @@ test('an unstable frame keeps the last stable bearing, until the overlay is remo
|
||||
{ angle: 2, opacity: 0.5, stable: false },
|
||||
];
|
||||
const previous = [];
|
||||
const { state, rendering } = overlay((x, y, last) => {
|
||||
const { state, rendering, camera } = overlay((x, y, last) => {
|
||||
previous.push(last);
|
||||
return answers.shift() ?? { angle: last ?? 0, opacity: 1, stable: true };
|
||||
});
|
||||
rendering.updateDirectionOverlay();
|
||||
assert.equal(state.directionAngles[0], 1);
|
||||
// The heading turns, so the next frame recomputes the contact.
|
||||
state.viewer.camera.heading = 0.1;
|
||||
camera.setPose({ heading: 0.1 });
|
||||
rendering.updateDirectionOverlay();
|
||||
assert.equal(previous[1], 1, 'the unstable frame is given the last angle');
|
||||
assert.equal(state.directionAngles[0], 1, 'and does not replace it');
|
||||
|
||||
Reference in new issue
Block a user