mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Cut duplicated and dead code across the engines, the layers and the QA scripts
- src/geo drops the ported debug argument checks and the tests that bitExact already covers; package boundaries accept a directory entry, so src/geo/ is listed once per group. - Cesium no longer carries movers and lines nobody draws with: they are optional engine capabilities. The fake engine and the Cesium camera use the shared cameraMath; unused contract tables, clock.ticked, the 'finest' surface detail and Navara click statistics are gone. - ALPR keeps one overlay core and one presentation model for both engines, bikeshare one station bookkeeping, the Navara ground effects one definition helper; image atlases, view centres, mover banks and colours are shared. - The legacy switch route, the clock offset and rate controls and other unused exports are removed. - The acceptance runs the Navara draw, geo import and scope checks; scenarios use the harness switch and page helpers; the main chunk check keeps the size budget only and runs once in CI.
This commit is contained in:
1 parent
c502404e1d
commit
7abf74518f
272 files changed
+4828
-10213
No files matched your search
@@ -1,225 +0,0 @@
|
||||
// engine.lines on Cesium: each line is one Primitive of a PolylineGeometry
|
||||
// (built synchronously, rebuilt when its positions change) with a
|
||||
// PolylineMaterialAppearance, inside one engine-owned PrimitiveCollection
|
||||
// added to the scene with the first line. depthFailAlpha adds Cesium's
|
||||
// depthFailAppearance (the same material, its alpha scaled) for the part
|
||||
// the scene hides; dashes in pixels are PolylineDash; the tactical dash is
|
||||
// the launches' selected-orbit pattern along the whole line.
|
||||
|
||||
import * as Cesium from 'cesium';
|
||||
import { createLineRegistry } from '../lines.js';
|
||||
|
||||
const TACTICAL_TYPE = 'GevLineTactical';
|
||||
let tacticalRegistered = false;
|
||||
|
||||
// The launches' GevMissionOrbitTactical shader (layers/launches/
|
||||
// orbitRendering.js), under the engine's own type until Task 15a moves
|
||||
// launches onto engine.lines.
|
||||
function registerTactical() {
|
||||
if (tacticalRegistered) return;
|
||||
new Cesium.Material({
|
||||
fabric: {
|
||||
type: TACTICAL_TYPE,
|
||||
uniforms: { color: Cesium.Color.CYAN, groupCount: 4, dashCount: 100 },
|
||||
source: `
|
||||
czm_material czm_getMaterial(czm_materialInput materialInput) {
|
||||
czm_material material = czm_getDefaultMaterial(materialInput);
|
||||
float groupPosition = fract(materialInput.st.s * groupCount);
|
||||
float markPosition = groupPosition * (dashCount + 1.0);
|
||||
float markIndex = floor(markPosition);
|
||||
float localPosition = fract(markPosition);
|
||||
float centerDistance = abs(localPosition - 0.5);
|
||||
float edge = max(fwidth(localPosition) * 1.35, 0.012);
|
||||
float dashAlong = 1.0 - smoothstep(0.27 - edge, 0.27 + edge, centerDistance);
|
||||
float dashAcross = 1.0 - smoothstep(0.12, 0.24, abs(materialInput.st.t - 0.5));
|
||||
float dash = dashAlong * dashAcross;
|
||||
float dotAlong = (localPosition - 0.5) / 0.32;
|
||||
float dotAcross = (materialInput.st.t - 0.5) / 0.5;
|
||||
float dot = 1.0 - smoothstep(0.78, 1.0, length(vec2(dotAlong, dotAcross)));
|
||||
float isDot = 1.0 - step(0.5, markIndex);
|
||||
float visible = mix(dash, dot, isDot);
|
||||
material.diffuse = color.rgb;
|
||||
material.emission = color.rgb * mix(0.07, 0.65, isDot);
|
||||
material.alpha = color.a * visible * mix(0.58, 1.0, isDot);
|
||||
return material;
|
||||
}`,
|
||||
},
|
||||
});
|
||||
tacticalRegistered = true;
|
||||
}
|
||||
|
||||
/** PolylineDash's 16-bit pattern: the dash first, then the gap. */
|
||||
export function dashPattern(lengthPx, gapPx) {
|
||||
const on = Math.max(
|
||||
1,
|
||||
Math.min(16, Math.round((16 * lengthPx) / (lengthPx + gapPx))),
|
||||
);
|
||||
return (0xffff << (16 - on)) & 0xffff;
|
||||
}
|
||||
|
||||
const toColor = ([r, g, b, a], alphaScale = 1) =>
|
||||
new Cesium.Color(r, g, b, a * alphaScale);
|
||||
|
||||
/** The Cesium material type and uniforms of a line (pure, for tests). */
|
||||
export function materialSpec(options, color, alphaScale = 1) {
|
||||
if (options.arrow)
|
||||
return {
|
||||
type: 'PolylineArrow',
|
||||
uniforms: { color: toColor(color, alphaScale) },
|
||||
};
|
||||
const { dash } = options;
|
||||
if (dash?.kind === 'pixels')
|
||||
return {
|
||||
type: 'PolylineDash',
|
||||
uniforms: {
|
||||
color: toColor(color, alphaScale),
|
||||
gapColor: Cesium.Color.TRANSPARENT,
|
||||
dashLength: dash.lengthPx + dash.gapPx,
|
||||
dashPattern: dashPattern(dash.lengthPx, dash.gapPx),
|
||||
},
|
||||
};
|
||||
if (dash?.kind === 'tactical')
|
||||
return {
|
||||
type: TACTICAL_TYPE,
|
||||
uniforms: {
|
||||
color: toColor(color, alphaScale),
|
||||
groupCount: dash.groups,
|
||||
dashCount: dash.dashes,
|
||||
},
|
||||
};
|
||||
return { type: 'Color', uniforms: { color: toColor(color, alphaScale) } };
|
||||
}
|
||||
|
||||
function cesiumMaterial({ type, uniforms }) {
|
||||
if (type === TACTICAL_TYPE) registerTactical();
|
||||
return Cesium.Material.fromType(type, uniforms);
|
||||
}
|
||||
|
||||
const DEFAULT_FACTORIES = {
|
||||
primitive: (options) => new Cesium.Primitive(options),
|
||||
appearance: (spec) =>
|
||||
new Cesium.PolylineMaterialAppearance({ material: cesiumMaterial(spec) }),
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Cesium.Viewer} viewer
|
||||
* @param {{ requestRender?: (reason: string) => void, factories?: object }} [options]
|
||||
* @returns {{ lines: import('../contract.js').GlobeLines, destroy: () => void }}
|
||||
*/
|
||||
export function createCesiumLines(
|
||||
viewer,
|
||||
{ requestRender = () => viewer.scene.requestRender(), factories = {} } = {},
|
||||
) {
|
||||
const make = { ...DEFAULT_FACTORIES, ...factories };
|
||||
const { scene } = viewer;
|
||||
let root = null;
|
||||
const rootCollection = () => {
|
||||
if (!root) {
|
||||
root = new Cesium.PrimitiveCollection({ destroyPrimitives: true });
|
||||
scene.primitives.add(root);
|
||||
}
|
||||
return root;
|
||||
};
|
||||
const registry = createLineRegistry((options) => {
|
||||
rootCollection();
|
||||
let color = options.color;
|
||||
let modelMatrix = options.modelMatrix
|
||||
? Cesium.Matrix4.fromArray(options.modelMatrix)
|
||||
: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY);
|
||||
let shown = true;
|
||||
let primitive = null;
|
||||
let appearance = null;
|
||||
let depthFail = null;
|
||||
const drop = () => {
|
||||
if (primitive) root.remove(primitive);
|
||||
primitive = null;
|
||||
};
|
||||
return {
|
||||
setPositions(flat) {
|
||||
drop();
|
||||
if (flat.length < 6) {
|
||||
requestRender('lines');
|
||||
return;
|
||||
}
|
||||
const positions = [];
|
||||
for (let index = 0; index < flat.length; index += 3)
|
||||
positions.push(
|
||||
new Cesium.Cartesian3(
|
||||
flat[index],
|
||||
flat[index + 1],
|
||||
flat[index + 2],
|
||||
),
|
||||
);
|
||||
appearance = make.appearance(materialSpec(options, color));
|
||||
depthFail =
|
||||
options.depthFailAlpha > 0
|
||||
? make.appearance(
|
||||
materialSpec(options, color, options.depthFailAlpha),
|
||||
)
|
||||
: undefined;
|
||||
primitive = make.primitive({
|
||||
geometryInstances: new Cesium.GeometryInstance({
|
||||
geometry: new Cesium.PolylineGeometry({
|
||||
positions,
|
||||
width: options.widthPx,
|
||||
vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT,
|
||||
arcType:
|
||||
options.arc === 'geodesic'
|
||||
? Cesium.ArcType.GEODESIC
|
||||
: Cesium.ArcType.NONE,
|
||||
}),
|
||||
id: options.pickId,
|
||||
}),
|
||||
appearance,
|
||||
depthFailAppearance: depthFail,
|
||||
modelMatrix: Cesium.Matrix4.clone(modelMatrix),
|
||||
show: shown,
|
||||
asynchronous: false,
|
||||
});
|
||||
primitive.gevLine = options.id;
|
||||
root.add(primitive);
|
||||
requestRender('lines');
|
||||
},
|
||||
setColor(rgba) {
|
||||
color = rgba;
|
||||
if (appearance) appearance.material.uniforms.color = toColor(rgba);
|
||||
if (depthFail)
|
||||
depthFail.material.uniforms.color = toColor(
|
||||
rgba,
|
||||
options.depthFailAlpha,
|
||||
);
|
||||
requestRender('lines');
|
||||
},
|
||||
setModelMatrix(matrix) {
|
||||
modelMatrix = Cesium.Matrix4.fromArray(matrix);
|
||||
if (primitive)
|
||||
primitive.modelMatrix = Cesium.Matrix4.clone(modelMatrix);
|
||||
requestRender('lines');
|
||||
},
|
||||
show(visible) {
|
||||
shown = visible;
|
||||
if (primitive) primitive.show = visible;
|
||||
requestRender('lines');
|
||||
},
|
||||
destroy() {
|
||||
drop();
|
||||
requestRender('lines');
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
lines: registry.lines,
|
||||
/** The line a Cesium pick result belongs to, or null. */
|
||||
identify(picked) {
|
||||
const owner = picked?.primitive?.gevLine;
|
||||
return owner !== undefined && registry.live.has(owner) ? { owner } : null;
|
||||
},
|
||||
destroy() {
|
||||
registry.destroyAll();
|
||||
if (root) {
|
||||
scene.primitives.remove(root);
|
||||
root = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user