mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 11:24:00 +00:00
refactor(street-level): remove the remaining duplicated code and fakes
A duplicate scan of every module the PR adds (repeated 4-line blocks, normalised) after gekh's dedup round left these: - glyphs.js: the cone, ring and position glyphs share cachedGlyph(), wedge(), ring() and dot(). Checked with a recording canvas: all 20 draw calls keep the same path and fill/stroke state, so the glyphs are pixel-identical. - panelPositionControls.js: one placeAt() for the three places that pin a panel's top-left corner as a fixed window. - tiles.js: one warn() for the three background-failure logs. - Tests: src/testSupport/streetLevelFakes.mjs holds the provider snapshot (uiState + presentation tests), the stand-in provider (core + controls tests) and one real-ray pinhole camera (view + coverage tests, which had each written their own). The coverage line-of-sight test still fails when refresh() stops passing its focus. - qa-street-level.mjs: one waitForCoverage() for the five copies of the "on, drawn, settled, not key-gated" wait. No behaviour change: unit 5862 pass, fixture gate 16/16, panel gate 5/5. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d70f468781
commit
c2f1b54d00
12 files changed
+281
-345
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
viewFocus,
|
||||
visibleBbox,
|
||||
} from './view.js';
|
||||
import { rayCamera } from '../../testSupport/streetLevelFakes.mjs';
|
||||
|
||||
const RAD = Math.PI / 180;
|
||||
/** A viewer 300 m above a street 1,600 m up (Denver-like). */
|
||||
@@ -82,50 +83,21 @@ test('an ordinary view keeps west < east', () => {
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* A pinhole camera `agl` metres above ground `ground` m up, looking north at
|
||||
* `pitch` degrees, whose rays meet whatever ellipsoid they are given (real
|
||||
* Cesium ray maths, as `camera.pickEllipsoid` does it).
|
||||
*/
|
||||
/** A pinhole viewer `agl` m above ground `ground` m up, looking north. */
|
||||
function pinhole({ lon, lat, ground, agl, pitch, w = 1600, h = 900 }) {
|
||||
const position = Cesium.Cartesian3.fromDegrees(lon, lat, ground + agl);
|
||||
const frame = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||
const p = pitch * RAD;
|
||||
const forward = [0, Math.cos(p), Math.sin(p)];
|
||||
const up = [0, -Math.sin(p), Math.cos(p)];
|
||||
const half = Math.tan(30 * RAD);
|
||||
return {
|
||||
scene: {
|
||||
canvas: { clientWidth: w, clientHeight: h },
|
||||
globe: { show: false, ellipsoid: Cesium.Ellipsoid.WGS84 },
|
||||
},
|
||||
camera: {
|
||||
positionWC: position,
|
||||
positionCartographic: Cesium.Cartographic.fromDegrees(
|
||||
lon,
|
||||
lat,
|
||||
ground + agl,
|
||||
),
|
||||
pickEllipsoid(point, ellipsoid = Cesium.Ellipsoid.WGS84) {
|
||||
const sx = ((2 * point.x) / w - 1) * half * (w / h);
|
||||
const sy = (1 - (2 * point.y) / h) * half;
|
||||
const local = [0, 1, 2].map(
|
||||
(i) => forward[i] + sx * (i === 0 ? 1 : 0) + sy * up[i],
|
||||
);
|
||||
const direction = Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
frame,
|
||||
new Cesium.Cartesian3(...local),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const ray = new Cesium.Ray(position, direction);
|
||||
const hit = Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid);
|
||||
return hit ? Cesium.Ray.getPoint(ray, hit.start) : undefined;
|
||||
},
|
||||
computeViewRectangle: () => undefined,
|
||||
},
|
||||
camera: rayCamera({
|
||||
lon,
|
||||
lat,
|
||||
altitude: ground + agl,
|
||||
pitch,
|
||||
width: w,
|
||||
height: h,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user