mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Merge origin/main into the renderer-contract branch: the procedural fleet models drawn through the renderer's model sets
Aircraft, military, local ADS-B, vessel, transit and rail models come from the fleet model set, loaded up front and drawn life size through the draw port's models sets; no layer touches the viewer or Cesium outside src/render/cesium/. The models capability gains glTF bytes (gltf), a per-axis stretch (axisScale), a colour for tinted parts (maskColor) and a cut below the origin (clip: 'belowOrigin'), with conformance checks. Main's rail layer and Data Library are ported to the ports; the CCTV footprint probe keeps the globe-terrain clamp through the query port.
This commit is contained in:
commit
e3865f462f
533 files changed
+55738
-2518
No files matched your search
@@ -48,6 +48,7 @@ export const LEGACY_SHARE_STATE_KEYS = Object.freeze([
|
||||
'layerState',
|
||||
'layerStateInvalid',
|
||||
'panelState',
|
||||
'library',
|
||||
'sharedAtMs',
|
||||
]);
|
||||
|
||||
|
||||
@@ -304,6 +304,13 @@ export const SHARE_VIEW_LAYER_OPTION_ABSENT = Object.freeze({
|
||||
sinceDays: 0,
|
||||
}),
|
||||
radio: Object.freeze({ filter: 'all', volume: 0.8 }),
|
||||
rail: Object.freeze({
|
||||
transit: true,
|
||||
local: true,
|
||||
regional: true,
|
||||
national: true,
|
||||
international: true,
|
||||
}),
|
||||
'wildlife-sightings': Object.freeze({ confirmed: false, taxa: 'all' }),
|
||||
});
|
||||
|
||||
@@ -383,6 +390,9 @@ export const SHARE_VIEW_FIELDS = freezeAll([
|
||||
{ number: 26, key: 'scopeTerminusPct', type: 'uint', default: null },
|
||||
{ number: 27, key: 'styleParams', type: 'bytes', default: BY_STYLE },
|
||||
{ number: 28, key: 'worldTime', type: 'epoch', default: null },
|
||||
// Data Library entries switched on, as their two-character ledger tokens
|
||||
// concatenated (src/library/ledger.json). Absent means none.
|
||||
{ number: 29, key: 'library', type: 'bytes', default: null },
|
||||
]);
|
||||
const FIELD_BY_KEY = new Map(SHARE_VIEW_FIELDS.map((f) => [f.key, f]));
|
||||
const fieldNumber = (key) => FIELD_BY_KEY.get(key).number;
|
||||
@@ -443,6 +453,33 @@ export function createDefaultShareViewState(requested = 'normal') {
|
||||
/* Normalization: the one canonical state both directions agree on. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/** The most Data Library tokens a share carries (the library's own cap). */
|
||||
export const SHARE_LIBRARY_MAX_TOKENS = 64;
|
||||
const LIBRARY_TOKEN = /^[0-9a-z]{2}$/;
|
||||
|
||||
/**
|
||||
* Data Library share tokens from a `lib=` value (`ab.cd`) or a token list:
|
||||
* unique, two base-36 characters each, at most SHARE_LIBRARY_MAX_TOKENS.
|
||||
* Malformed tokens are skipped. Null or undefined stays null (no field).
|
||||
* @param {string|string[]|null|undefined} value
|
||||
* @returns {string[]|null}
|
||||
*/
|
||||
export function normalizeLibraryTokens(value) {
|
||||
if (value === null || value === undefined) return null;
|
||||
const list = Array.isArray(value)
|
||||
? value
|
||||
: typeof value === 'string' && value.length <= 3 * SHARE_LIBRARY_MAX_TOKENS
|
||||
? value.split('.')
|
||||
: [];
|
||||
const tokens = [];
|
||||
for (const token of list) {
|
||||
if (typeof token !== 'string' || !LIBRARY_TOKEN.test(token)) continue;
|
||||
if (!tokens.includes(token)) tokens.push(token);
|
||||
if (tokens.length === SHARE_LIBRARY_MAX_TOKENS) break;
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
const finite = (value) =>
|
||||
typeof value === 'number'
|
||||
? Number.isFinite(value)
|
||||
@@ -754,6 +791,7 @@ export function normalizeShareViewState(input = {}) {
|
||||
? normalizeLayerState(source.layerState)
|
||||
: null;
|
||||
state.panelState = normalizePanelState(source.panelState);
|
||||
state.library = normalizeLibraryTokens(source.library);
|
||||
state.sharedAtMs = epochMsOr(source.sharedAtMs);
|
||||
state.worldTime = isWorldTime(source.worldTime)
|
||||
? Math.floor(source.worldTime / 1000) * 1000
|
||||
@@ -1023,6 +1061,10 @@ export function encodeShareView(input) {
|
||||
case 'panelState':
|
||||
if (state.panelState) encodePanels(writer, state.panelState);
|
||||
break;
|
||||
case 'library':
|
||||
if (state.library?.length)
|
||||
writer.textField(field.number, state.library.join(''));
|
||||
break;
|
||||
case 'thing':
|
||||
if (thing) encodeThing(writer, thing, state);
|
||||
break;
|
||||
@@ -1431,6 +1473,13 @@ export function decodeShareView(code, { nowMs = Date.now() } = {}) {
|
||||
unknown.code('layer-option', 'without-layers');
|
||||
if (get('panelState'))
|
||||
raw.panelState = decodePanels(get('panelState').len, unknown);
|
||||
if (get('library')) {
|
||||
const text = asciiText(get('library').len.rest());
|
||||
const tokens = text.match(/.{1,2}/g) || [];
|
||||
for (const token of tokens)
|
||||
if (!LIBRARY_TOKEN.test(token)) unknown.code('library', token);
|
||||
raw.library = normalizeLibraryTokens(tokens);
|
||||
}
|
||||
if (get('styleParams') && !retiredStyle)
|
||||
raw.styleParams = decodeStyleParams(
|
||||
get('styleParams').len,
|
||||
|
||||
@@ -58,6 +58,7 @@ import {
|
||||
followOffsetToEnu,
|
||||
layerTokenFromNumber,
|
||||
layerTokenNumber,
|
||||
normalizeLibraryTokens,
|
||||
normalizeShareViewState,
|
||||
} from './viewCodec.js';
|
||||
|
||||
@@ -507,6 +508,7 @@ test('the field registry is well formed and permanent', () => {
|
||||
[26, 'scopeTerminusPct', null],
|
||||
[27, 'styleParams', BY_STYLE],
|
||||
[28, 'worldTime', null],
|
||||
[29, 'library', null],
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
@@ -1571,3 +1573,16 @@ test('the follow offset for a camera is the inverse of followCameraFor', () => {
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('Data Library tokens round-trip and malformed ones are skipped', () => {
|
||||
const state = { lat: 1, lon: 2, library: ['00', '1z', '0a'] };
|
||||
const decoded = decodeShareView(encodeShareView(state));
|
||||
assert.equal(decoded.ok, true);
|
||||
assert.deepEqual(decoded.state.library, ['00', '1z', '0a']);
|
||||
// None on: no field, and the decoder reads no tokens.
|
||||
const none = decodeShareView(encodeShareView({ lat: 1, lon: 2 }));
|
||||
assert.equal(none.state.library, null);
|
||||
assert.deepEqual(normalizeLibraryTokens('01.!!.01.zz'), ['01', 'zz']);
|
||||
assert.equal(normalizeLibraryTokens(null), null);
|
||||
assert.deepEqual(normalizeLibraryTokens('x'.repeat(500)), []);
|
||||
});
|
||||
Reference in new issue
Block a user