mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Remove renderer contract members nothing in the application uses
Drops from the contract, the stub, the Cesium renderer and the conformance suite: agent paths, renderer-propagated orbits and celestial draws (orbits stay drawn as icons and inertial lines), scalar raster fields, lodGroup, volume classification, icon eye offsets, the dash gap colour, box shapes, courseBlendMs (courseGlide covers easing), relief surface shading, globe clouds and water, sky atmosphere tuning, heightmap and quantized-mesh terrain, WMTS and ArcGIS imagery, the batched cached height read, the quality benchmark and the animated-style and overlay pixel-ratio knobs. Capabilities clouds, water, celestial, agents, orbits and benchmark go with them. The lodGroup check becomes a displayRange check across two sets, the height-query check uses an extruded polygon in place of a box, the shape scenes draw extruded blocks where they drew boxes, and the fields scene draws a raster shell. The shape references are recorded again.
This commit is contained in:
1 parent
71f2f12f75
commit
46cdeba7fa
37 files changed
+370
-1165
No files matched your search
@@ -16,7 +16,6 @@ import { cssColor } from '../color.js';
|
||||
import { CAPABILITIES, CONTRACT_VERSION } from '../contract/index.js';
|
||||
import { createStubCamera } from './camera.js';
|
||||
import { motionPosition } from '../motion/iconMotion.js';
|
||||
import { orbitPosition } from './orbits.js';
|
||||
import { computeViewRectangle } from './viewRectangle.js';
|
||||
import {
|
||||
add,
|
||||
@@ -510,12 +509,6 @@ export function createStubRenderer(options = {}) {
|
||||
if (capabilities.has('quads')) draw.quads = (spec) => makeSet('quads', spec);
|
||||
if (capabilities.has('meshes'))
|
||||
draw.meshes = (spec) => makeSet('meshes', spec);
|
||||
if (capabilities.has('agents'))
|
||||
draw.agents = (spec) => makeSet('agents', spec);
|
||||
/** Parsed orbit elements, by line pair; cleared on destroy. */
|
||||
const satrecs = new Map();
|
||||
if (capabilities.has('orbits'))
|
||||
draw.orbits = (spec) => makeSet('orbits', spec);
|
||||
if (capabilities.has('fields'))
|
||||
draw.field = (spec) => {
|
||||
const handle = simpleHandle('field', spec);
|
||||
@@ -554,8 +547,6 @@ export function createStubRenderer(options = {}) {
|
||||
};
|
||||
return handle;
|
||||
};
|
||||
if (capabilities.has('celestial'))
|
||||
draw.celestial = (spec) => simpleHandle('celestial', spec);
|
||||
|
||||
// --- Query -----------------------------------------------------------------
|
||||
|
||||
@@ -618,10 +609,6 @@ export function createStubRenderer(options = {}) {
|
||||
}
|
||||
|
||||
function itemPosition(set, item, aheadMs = 0) {
|
||||
if (set.kind === 'orbits')
|
||||
return item.tle
|
||||
? orbitPosition(satrecs, item.tle, motionTime(set) + aheadMs)
|
||||
: null;
|
||||
if (!item.pos) return null;
|
||||
const base = toEcef(item.pos);
|
||||
if (
|
||||
@@ -755,25 +742,6 @@ export function createStubRenderer(options = {}) {
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether `lon`, `lat` (degrees) is inside a ring of positions. */
|
||||
function inRing(ring, lon, lat) {
|
||||
const points = ring.map((p) => {
|
||||
const c = toCartographicRadians(toEcef(p));
|
||||
return [toDegrees(c.lon), toDegrees(c.lat)];
|
||||
});
|
||||
let inside = false;
|
||||
for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
|
||||
const [xi, yi] = points[i];
|
||||
const [xj, yj] = points[j];
|
||||
if (
|
||||
yi > lat !== yj > lat &&
|
||||
lon < ((xj - xi) * (lat - yi)) / (yj - yi) + xi
|
||||
)
|
||||
inside = !inside;
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
/**
|
||||
* The pickable items under a pixel, nearest first. With a `depth`, only
|
||||
* the nearest `depth` things drawn there are looked through, unpickable
|
||||
@@ -809,10 +777,9 @@ export function createStubRenderer(options = {}) {
|
||||
continue;
|
||||
}
|
||||
if (set.kind === 'shapes') {
|
||||
// Draped rectangles and ellipses, and volumes that classify what
|
||||
// they cover, are picked where they cover the ellipsoid (rectangles
|
||||
// turned as the default renderer turns them); other shapes are not
|
||||
// picked.
|
||||
// Draped rectangles and ellipses are picked where they cover the
|
||||
// ellipsoid (rectangles turned as the default renderer turns them);
|
||||
// other shapes are not picked.
|
||||
const ground = rayEllipsoid(pickRay(x, y));
|
||||
const at = ground && toCartographicRadians(ground);
|
||||
if (!at) continue;
|
||||
@@ -823,14 +790,9 @@ export function createStubRenderer(options = {}) {
|
||||
if (!item.fill || item.outlineOnly) continue;
|
||||
const g = item.geometry;
|
||||
const covers =
|
||||
item.height === 'clampGround'
|
||||
? (g?.kind === 'rectangle' && inRectangle(g, lon, lat)) ||
|
||||
(g?.kind === 'ellipse' && inEllipse(g, lon, lat))
|
||||
: item.classifyVolume === true &&
|
||||
item.extrudeHeight !== undefined &&
|
||||
g?.kind === 'polygon' &&
|
||||
inRing(g.rings[0], lon, lat) &&
|
||||
!g.rings.slice(1).some((hole) => inRing(hole, lon, lat));
|
||||
item.height === 'clampGround' &&
|
||||
((g?.kind === 'rectangle' && inRectangle(g, lon, lat)) ||
|
||||
(g?.kind === 'ellipse' && inEllipse(g, lon, lat)));
|
||||
if (!covers) continue;
|
||||
hits.push({
|
||||
set: setId,
|
||||
@@ -847,8 +809,7 @@ export function createStubRenderer(options = {}) {
|
||||
if (
|
||||
set.kind !== 'icons' &&
|
||||
set.kind !== 'points' &&
|
||||
set.kind !== 'models' &&
|
||||
set.kind !== 'orbits'
|
||||
set.kind !== 'models'
|
||||
)
|
||||
continue;
|
||||
for (const item of set.items.values()) {
|
||||
@@ -868,10 +829,8 @@ export function createStubRenderer(options = {}) {
|
||||
continue;
|
||||
const s = project(p);
|
||||
if (!s) continue;
|
||||
const pixel = item.pixelSize ?? item.marker?.pixelSize ?? 10;
|
||||
const size = item.pickProxy?.size ??
|
||||
item.size ??
|
||||
item.marker?.size ?? [pixel, pixel];
|
||||
const pixel = item.pixelSize ?? 10;
|
||||
const size = item.pickProxy?.size ?? item.size ?? [pixel, pixel];
|
||||
const scale = item.scaleByDistance
|
||||
? nearFarValue(item.scaleByDistance, distance)
|
||||
: 1;
|
||||
@@ -885,7 +844,6 @@ export function createStubRenderer(options = {}) {
|
||||
set: setId,
|
||||
id: item.id,
|
||||
meta: item.meta,
|
||||
...(item.lodGroup !== undefined ? { lodGroup: item.lodGroup } : {}),
|
||||
surface: false,
|
||||
position: p,
|
||||
depth: distance,
|
||||
@@ -1034,15 +992,6 @@ export function createStubRenderer(options = {}) {
|
||||
const key = cacheKey(point, opts.against);
|
||||
return heightCache.has(key) ? heightCache.get(key) : null;
|
||||
},
|
||||
sampleHeightNowMany(points, out, opts = {}) {
|
||||
for (let i = 0; i < out.length; i++) {
|
||||
const height = query.sampleHeightNow(
|
||||
{ lon: points[i * 2], lat: points[i * 2 + 1] },
|
||||
opts,
|
||||
);
|
||||
out[i] = height ?? NaN;
|
||||
}
|
||||
},
|
||||
async sampleHeight(points, opts = {}) {
|
||||
if (!capabilities.has('sampleHeight')) return points.map(() => null);
|
||||
return points.map((point) => {
|
||||
@@ -1319,16 +1268,6 @@ export function createStubRenderer(options = {}) {
|
||||
log('globe', 'setSurfaceShading', [shading]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('clouds'))
|
||||
globe.setClouds = (clouds) => {
|
||||
log('globe', 'setClouds', [clouds]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('water'))
|
||||
globe.setWater = (water) => {
|
||||
log('globe', 'setWater', [water]);
|
||||
requestRender('base');
|
||||
};
|
||||
if (capabilities.has('splitSwipe')) {
|
||||
globe.imagery.getSplit = () => split;
|
||||
globe.imagery.setSplit = (x01) => {
|
||||
@@ -1534,11 +1473,6 @@ export function createStubRenderer(options = {}) {
|
||||
},
|
||||
},
|
||||
};
|
||||
if (capabilities.has('benchmark'))
|
||||
quality.benchmark = async ({ durationMs }) => ({
|
||||
frames: Math.round(durationMs / FRAME_MS),
|
||||
cpuMs: { median: 0, p95: 0 },
|
||||
});
|
||||
|
||||
// --- Renderer --------------------------------------------------------------
|
||||
|
||||
@@ -1625,7 +1559,6 @@ export function createStubRenderer(options = {}) {
|
||||
for (const clear of onceTimers) clear();
|
||||
onceTimers.clear();
|
||||
sets.clear();
|
||||
satrecs.clear();
|
||||
sceneFrameLayers.clear();
|
||||
frameFlushes.clear();
|
||||
},
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* @module render/stub/orbits
|
||||
* @description Where an orbit item is at a time: its two-line elements
|
||||
* propagated with SGP4 and turned into Earth-fixed metres.
|
||||
*/
|
||||
import { eciToEcf, gstime, propagate, twoline2satrec } from 'satellite.js';
|
||||
|
||||
/**
|
||||
* @param {Map<string, object>} satrecs Parsed elements by line pair, the caller's cache.
|
||||
* @param {[string, string]} tle
|
||||
* @param {number} t Epoch ms.
|
||||
* @returns {{x: number, y: number, z: number}|null} ECEF metres, or null when the elements cannot be propagated to `t`.
|
||||
*/
|
||||
export function orbitPosition(satrecs, tle, t) {
|
||||
const key = `${tle[0]}\n${tle[1]}`;
|
||||
let satrec = satrecs.get(key);
|
||||
if (!satrec) {
|
||||
satrec = twoline2satrec(tle[0], tle[1]);
|
||||
satrecs.set(key, satrec);
|
||||
}
|
||||
const date = new Date(t);
|
||||
const state = propagate(satrec, date);
|
||||
const eci = state?.position;
|
||||
if (!eci || typeof eci !== 'object') return null;
|
||||
const ecf = eciToEcf(eci, gstime(date));
|
||||
return { x: ecf.x * 1000, y: ecf.y * 1000, z: ecf.z * 1000 };
|
||||
}
|
||||
@@ -141,40 +141,6 @@ test('a draped rectangle across the antimeridian picks on both sides of it, turn
|
||||
r.destroy();
|
||||
});
|
||||
|
||||
test('an extruded volume that classifies picks inside its outer ring and not in its holes', () => {
|
||||
const r = createStubRenderer();
|
||||
r.camera.setView({
|
||||
destination: { lon: 0, lat: 0, height: 20_000 },
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
const shapes = r.draw.shapes({ id: 'volume' });
|
||||
const square = (d) =>
|
||||
[
|
||||
[-d, -d],
|
||||
[d, -d],
|
||||
[d, d],
|
||||
[-d, d],
|
||||
].map(([lon, lat]) => ({ lon, lat, height: -50 }));
|
||||
shapes.set([
|
||||
{
|
||||
id: 'v',
|
||||
geometry: { kind: 'polygon', rings: [square(0.02), square(0.005)] },
|
||||
fill: '#f80',
|
||||
extrudeHeight: 100,
|
||||
height: 'absolute',
|
||||
classifyVolume: true,
|
||||
},
|
||||
]);
|
||||
const picked = (lon, lat) => {
|
||||
const s = r.query.project(toEcef({ lon, lat, height: 0 }));
|
||||
return r.query.drillPick(s.x, s.y).some((hit) => hit.set === 'volume');
|
||||
};
|
||||
assert.ok(picked(0.012, 0), 'between its rings');
|
||||
assert.ok(!picked(0, 0), 'not in its hole');
|
||||
assert.ok(!picked(0.03, 0), 'not outside');
|
||||
r.destroy();
|
||||
});
|
||||
|
||||
test('the stub says where it draws an item, for a camera that is not its own', () => {
|
||||
const r = createStubRenderer();
|
||||
const t0 = r.frame.time();
|
||||
|
||||
Reference in new issue
Block a user