mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The satellite dots, the tracked satellite's dot and the orbit rings now go through the draw port instead of a raw point collection, an entity and primitives, so the layer's rendering no longer drives Cesium and leaves the Cesium allow-list. - Dots are one points set, patched in place and sent once per frame. - The tracked dot is its own set, drawn at the sample the follow camera framed (or after the frame's own sample when no camera read it). - Rings are geodesic lines with a behind-the-globe colour, turned about the pole by the sidereal angle in the layer each second, since the port has no inertial frame. The orbit frame matrix is a plain 16-number array, and the launches layer now receives plain ECEF orbit positions. - Clicks match the draw hit against the layer's own sets. - The focus pass projects every dot in one batched call. - Depth-fail lines in the Cesium draw port honour pickable: false.
138 lines
3.8 KiB
JavaScript
138 lines
3.8 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { applyVesselFocusDeemphasis } from './aisLiveVessels.js';
|
|
import { applyCctvFocusDeemphasis } from './cctv.js';
|
|
import { applySatellitePointFocusDeemphasis } from './satellites.js';
|
|
import { DEFAULT_FOCUS_DEEMPHASIS_PARAMS } from './focusDeemphasis.js';
|
|
import { createIconBook } from '../render/motion/iconBook.js';
|
|
import { createVesselIconBook } from '../layers/vessels/iconBook.js';
|
|
|
|
const params = { ...DEFAULT_FOCUS_DEEMPHASIS_PARAMS, paddingPx: 0 };
|
|
const target = {
|
|
screenRect: { left: 40, top: 40, right: 60, bottom: 60 },
|
|
paddingPx: 0,
|
|
cameraDistance: 1000,
|
|
};
|
|
|
|
function color(alpha = 1, rgb = 'base') {
|
|
return {
|
|
alpha,
|
|
rgb,
|
|
withAlpha(nextAlpha) {
|
|
return color(nextAlpha, rgb);
|
|
},
|
|
};
|
|
}
|
|
|
|
function assertResumeGate(name, makePass) {
|
|
test(`${name} gate restores a settled dim contact after untrack`, () => {
|
|
const { pass, readAlpha } = makePass();
|
|
let activeCount = 0;
|
|
const tick = (nowMs, focusTarget) => {
|
|
const result = pass({
|
|
nowMs,
|
|
target: focusTarget,
|
|
previousActiveCount: activeCount,
|
|
});
|
|
activeCount = result.activeCount;
|
|
return result;
|
|
};
|
|
|
|
assert.equal(tick(0, target).ran, true);
|
|
const settled = tick(params.attackMs + 1, target);
|
|
assert.equal(settled.activeCount, 1);
|
|
assert.equal(readAlpha(), params.dimFloor);
|
|
|
|
const releaseStart = tick(params.attackMs + 1, null);
|
|
assert.equal(
|
|
releaseStart.ran,
|
|
true,
|
|
'active count keeps the no-target release pass alive',
|
|
);
|
|
assert.equal(releaseStart.activeCount, 1);
|
|
|
|
const restored = tick(params.attackMs + params.releaseMs + 2, null);
|
|
assert.equal(restored.ran, true);
|
|
assert.equal(restored.activeCount, 0);
|
|
assert.equal(readAlpha(), 1);
|
|
|
|
assert.equal(
|
|
tick(params.attackMs + params.releaseMs + 82, null).ran,
|
|
false,
|
|
);
|
|
});
|
|
}
|
|
|
|
assertResumeGate('vessel', () => {
|
|
const icons = createVesselIconBook();
|
|
icons.put({ id: '353136000', size: [32, 32], meta: { id: '353136000' } });
|
|
const record = {
|
|
iconId: '353136000',
|
|
position: { x: 1, y: 2, z: 3 },
|
|
visible: true,
|
|
};
|
|
return {
|
|
pass: ({ nowMs, target: focusTarget, previousActiveCount }) =>
|
|
applyVesselFocusDeemphasis({
|
|
records: [record],
|
|
icons,
|
|
target: focusTarget,
|
|
previousActiveCount,
|
|
nowMs,
|
|
screenPositionFor: () => ({ x: 50, y: 50 }),
|
|
cameraDistanceFor: () => 1200,
|
|
params,
|
|
}),
|
|
readAlpha: () => icons.focus('353136000'),
|
|
};
|
|
});
|
|
|
|
assertResumeGate('CCTV', () => {
|
|
const icons = createIconBook();
|
|
icons.put({
|
|
id: 'cam-1',
|
|
pos: { x: 1, y: 2, z: 3 },
|
|
size: [24, 24],
|
|
meta: { id: 'cam-1' },
|
|
});
|
|
const record = { camera: { id: 'cam-1' }, position: { x: 1, y: 2, z: 3 } };
|
|
return {
|
|
pass: ({ nowMs, target: focusTarget, previousActiveCount }) =>
|
|
applyCctvFocusDeemphasis({
|
|
records: [record],
|
|
icons,
|
|
target: focusTarget,
|
|
previousActiveCount,
|
|
nowMs,
|
|
screenPositionFor: () => ({ x: 50, y: 50 }),
|
|
cameraDistanceFor: () => 1200,
|
|
params,
|
|
}),
|
|
readAlpha: () => icons.focus('cam-1'),
|
|
};
|
|
});
|
|
|
|
assertResumeGate('satellite', () => {
|
|
const point = {
|
|
pos: { x: 1, y: 2, z: 3 },
|
|
show: true,
|
|
pixelSize: 6,
|
|
color: [1, 1, 1, 1],
|
|
};
|
|
return {
|
|
pass: ({ nowMs, target: focusTarget, previousActiveCount }) =>
|
|
applySatellitePointFocusDeemphasis({
|
|
points: new Map([[42, point]]),
|
|
trackedId: null,
|
|
target: focusTarget,
|
|
previousActiveCount,
|
|
nowMs,
|
|
screenPositionFor: () => ({ x: 50, y: 50 }),
|
|
cameraDistanceFor: () => 1200,
|
|
baseColorFor: () => [1, 1, 1, 1],
|
|
params,
|
|
}),
|
|
readAlpha: () => point.color[3],
|
|
};
|
|
});
|