Delete dead render code and consolidate QA helpers

Remove code that nothing in the app, the runners or CI uses:
- the one-off migration compare, look and bench scripts and the vector
  ground prototype they measured, with the bench tables in the docs;
- the unused Navara-named shared render modules (polygons, ground picks,
  mover bank, ground ring);
- the Cesium-shaped aircraft and vessel test renderers, and the trail,
  engineFromViewer and horizon-occluder helpers only they kept alive.
  Their tests now run on the production displays over the fake engine;
- Navara's unread diagnostics, fallback ports, dead exports and
  parameters, stale effect-chain anchors and the unread capability flags.

The QA scripts share one keyless guard and readiness wait, the session
harness reuses the strict harness's browser flags and block list, and the
harness honours QA_ANGLE and QA_RESERVED_PORTS. The bikeshare fixture
keeps only what its scenario reads. The docs name the engine picker where
it is (VISUAL PRESETS) and drop dated run results.

No behaviour changes on either engine. Navara layer renderer lines fall
from 189 to 0 and viewer lines from 891 to 849.
This commit is contained in:
German Khokhlov committed 2026-11-08 17:05:38 +04:00
1 parent 18f69c2699
commit 371d848eec
130 files changed
+633 -4542

No files matched your search

+15 -64
View File
@@ -31,51 +31,10 @@ import { createGroundPicks } from '../ground.js';
import { navaraFollowGestures } from './followGestures.js';
import { createNavaraMaps } from './maps.js';
import { createNavaraSurface } from './surface.js';
import { createGroundFloor, GROUND_FLOOR } from './groundFloor.js';
import { createGroundFloor } from './groundFloor.js';
const { cartesian3, math } = geo;
// engine.movers without the view's three runtime (Node tests of the engine).
const NO_MOVERS = Object.freeze({
createSet() {
throw new Error("Navara movers need the view's three runtime (movers/)");
},
list: () => [],
});
const NO_LINES = Object.freeze({
createSegments() {
throw new Error("Navara lines need the view's three runtime (lines/)");
},
createLine() {
throw new Error("Navara lines need the view's three runtime (lines/)");
},
list: () => [],
});
const NO_MESHES = Object.freeze({
createMesh() {
throw new Error('Navara meshes need the view runtime');
},
list: () => [],
});
const NO_GROUND = Object.freeze({
createPulseField() {
throw new Error('Navara ground needs the view runtime');
},
createSet() {
throw new Error("Navara ground needs the view's three runtime (ground/)");
},
list: () => [],
});
const NO_IMAGERY = Object.freeze({
createLayer() {
throw new Error("Navara imagery needs the view's three runtime (imagery/)");
},
list: () => [],
setSplitPosition() {},
splitPosition: () => 0.5,
surface: () => 'globe',
});
// Navara's drawn camera (view.camera.raw, a three PerspectiveCamera in
// Earth-fixed metres): matrixWorld columns are right, up, back, position.
function readCamera(raw) {
@@ -94,7 +53,7 @@ function readCamera(raw) {
* @param {object} view An initialised Navara ThreeView.
* @param {{
* hooks: { tileRoots: Function, isIdle: Function, retainTileGeometry: Function, dropOrphanFeatureChanges?: Function },
* imagery?: (parts: { camera: object, size: Function, credits: object, photorealActive: () => boolean }) => { imagery: object, diagnostics: Function, destroy: Function },
* imagery: (parts: { camera: object, size: Function, credits: object, photorealActive: () => boolean }) => { imagery: object, destroy: Function },
* container?: HTMLElement,
* fetch?: typeof fetch,
* clock?: object,
@@ -117,11 +76,11 @@ function readCamera(raw) {
* capability), destroyed with the engine;
* `appClock` (the engine clock's time) defaults to the page's app clock;
* `movers` is engine.movers on the view's three runtime (movers/index.js;
* without it createSet throws), `lines` engine.lines (lines/index.js;
* likewise), `ground` engine.ground (ground/index.js; likewise), all
* required), `lines` engine.lines (lines/index.js), `ground` engine.ground
* (ground/index.js), all
* destroyed with the engine; `imagery` makes engine.imagery from the
* engine's camera, size, credits and photoreal state (imagery/index.js;
* without it createLayer throws), destroyed with the engine;
* required), destroyed with the engine;
* `fetch` and `clock` (the camera model's timers) are test seams.
* @returns {import('../contract.js').GlobeEngine}
*/
@@ -133,11 +92,11 @@ export function createNavaraEngine(
fetch,
clock,
appClock,
movers: moversPort = null,
lines: linesPort = null,
ground: groundPort = null,
imagery: imageryPort = null,
meshes: meshesPort = null,
movers: moversPort,
lines: linesPort,
ground: groundPort,
imagery: imageryPort,
meshes: meshesPort,
sharpen: sharpenPort = null,
styles: stylesPort = null,
bloom: bloomPort = null,
@@ -451,11 +410,11 @@ export function createNavaraEngine(
credits: credits.credits,
maps: maps.maps,
clock: engineClock.clock,
movers: moversPort?.movers ?? NO_MOVERS,
lines: linesPort?.lines ?? NO_LINES,
ground: groundPort?.ground ?? NO_GROUND,
meshes: meshes?.meshes ?? NO_MESHES,
imagery: imagery?.imagery ?? NO_IMAGERY,
movers: moversPort.movers,
lines: linesPort.lines,
ground: groundPort.ground,
meshes: meshes.meshes,
imagery: imagery.imagery,
destroy() {
if (destroyed) return;
destroyed = true;
@@ -494,13 +453,5 @@ export function createNavaraEngine(
},
// Navara only, not contract: what the ground pass holds (QA reads it).
groundDiagnostics: () => groundPort?.diagnostics?.() ?? null,
// Navara only, not contract: what each imagery layer holds.
imageryDiagnostics: () => imagery?.diagnostics?.() ?? null,
// Navara only, not contract: the ground the floor last sampled under
// the camera and the margin it keeps above it (QA measures against it).
groundFloor: {
ground: () => groundFloor.ground(),
margin: GROUND_FLOOR.MIN_ABOVE,
},
};
}
+56 -10
View File
@@ -100,9 +100,58 @@ const hooks = {
retainTileGeometry() {},
};
// Primitive ports for tests of engine orchestration.
const STUB_MOVERS = Object.freeze({
createSet() {
throw new Error("Navara movers need the view's three runtime (movers/)");
},
list: () => [],
});
const STUB_LINES = Object.freeze({
createSegments() {
throw new Error("Navara lines need the view's three runtime (lines/)");
},
createLine() {
throw new Error("Navara lines need the view's three runtime (lines/)");
},
list: () => [],
});
const STUB_MESHES = Object.freeze({
createMesh() {
throw new Error('Navara meshes need the view runtime');
},
list: () => [],
});
const STUB_GROUND = Object.freeze({
createPulseField() {
throw new Error('Navara ground needs the view runtime');
},
createSet() {
throw new Error("Navara ground needs the view's three runtime (ground/)");
},
list: () => [],
});
const STUB_IMAGERY = Object.freeze({
createLayer() {
throw new Error("Navara imagery needs the view's three runtime (imagery/)");
},
list: () => [],
setSplitPosition() {},
splitPosition: () => 0.5,
surface: () => 'globe',
});
const ports = {
movers: { movers: STUB_MOVERS, destroy() {} },
lines: { lines: STUB_LINES, destroy() {} },
ground: { ground: STUB_GROUND, destroy() {} },
imagery: () => ({ imagery: STUB_IMAGERY, destroy() {} }),
meshes: () => ({ meshes: STUB_MESHES, destroy() {} }),
};
const setup = () => {
const view = fakeView();
const engine = createNavaraEngine(view, { hooks });
const engine = createNavaraEngine(view, { ...ports, hooks });
return { view, engine };
};
@@ -135,7 +184,7 @@ test('the engine clock is the app clock, latched on the view preUpdate before fr
let wall = 2_000_000;
const appClock = createAppClock({ now: () => wall });
const view = fakeView();
const engine = createNavaraEngine(view, { hooks, appClock });
const engine = createNavaraEngine(view, { ...ports, hooks, appClock });
assert.equal(engine.clock.now(), 2_000_000);
const seen = [];
for (const name of ['preUpdate', 'preRender', 'postRender'])
@@ -177,6 +226,7 @@ test('setSharpen hands changed states to the sharpen port and draws a frame', ()
const shown = [];
let destroyed = 0;
const engine = createNavaraEngine(view, {
...ports,
hooks,
sharpen: {
set: (state) => shown.push(state),
@@ -225,7 +275,7 @@ function stylesPort() {
test('setStyle hands changed style states to the styles port and draws a frame', () => {
const view = fakeView();
const port = stylesPort();
const engine = createNavaraEngine(view, { hooks, styles: port });
const engine = createNavaraEngine(view, { ...ports, hooks, styles: port });
assertGlobeEngine(engine);
assert.equal(engineCapabilities(engine).visualStyles, true);
assert.deepEqual(engine.render.visualStyles, ['retro', 'noir']);
@@ -267,6 +317,7 @@ test('setBloom hands changed states to the bloom port and draws a frame', () =>
const shown = [];
let destroyed = 0;
const engine = createNavaraEngine(view, {
...ports,
hooks,
bloom: { set: (state) => shown.push(state), destroy: () => destroyed++ },
});
@@ -294,6 +345,7 @@ test('setCloudCover hands changed covers to the clouds port and draws a frame',
const shown = [];
let destroyed = 0;
const engine = createNavaraEngine(view, {
...ports,
hooks,
clouds: { set: (state) => shown.push(state), destroy: () => destroyed++ },
});
@@ -317,6 +369,7 @@ test('setContactSonar hands changes to the sonar port, asking a frame only outsi
const shown = [];
let destroyed = 0;
const engine = createNavaraEngine(view, {
...ports,
hooks,
sonar: { set: (state) => shown.push(state), destroy: () => destroyed++ },
});
@@ -591,10 +644,3 @@ test('the floor stands aside while the camera inputs are suspended (the cockpit
near(heightOf(engine), 130, 1e-6, 'lifted once the inputs are back');
engine.destroy();
});
test('the ground floor reports its own ground and margin (diagnostics, not contract)', () => {
const { engine } = setup();
assert.equal(typeof engine.groundFloor.ground, 'function');
assert.equal(engine.groundFloor.margin, 30);
assert.equal(engine.groundFloor.ground(), undefined, 'nothing sampled yet');
});
-9
View File
@@ -33,12 +33,3 @@ export function withPassDisposal(Base) {
}
};
}
// The base the layers' Navara effects extend (engine.LayerEffectDesc): per
// frame updates on their own callback, and the raw pass disposed when the
// effect is deleted. A layer re-creates its effect on every attach (an
// engine switch), so an undisposed pass kept its material, its shader
// program and the uniforms' data textures alive for the page's lifetime.
export function layerEffectDesc(EffectDesc) {
return withPassDisposal(withFrameUpdates(EffectDesc));
}
-44
View File
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
layerEffectDesc,
withFrameUpdates,
withPassDisposal,
} from './frameDescriptor.js';
@@ -81,46 +80,3 @@ test('a deleted effect disposes the pass the composer no longer holds', () => {
assert.throws(() => new (withPassDisposal(Failing))().onDestroy(), /removal/);
assert.deepEqual(events, ['dispose']);
});
test('a layer effect re-created on every attach leaves no pass, material or frame callback behind', () => {
const frames = new Set();
const view = {
on: (name, cb) => frames.add(cb),
off: (name, cb) => frames.delete(cb),
};
const live = new Set();
class EffectDesc {
view = view;
onCreate() {
const pass = {
material: {},
dispose: () => live.delete(pass),
};
live.add(pass);
this._instance = { rawPass: pass };
}
get raw() {
return this._instance;
}
onDestroy() {
// Navara's removePass: out of the composer, not disposed.
this._instance = undefined;
}
}
// As the earthquakes ground effect: disposes its own effect, then super.
class LayerEffect extends layerEffectDesc(EffectDesc) {
updateFrame() {}
onDestroy() {
this.effectDisposed = true;
super.onDestroy();
}
}
for (let attach = 0; attach < 50; attach++) {
const effect = new LayerEffect();
effect.onCreate();
effect.onDestroy();
assert.equal(effect.effectDisposed, true);
}
assert.equal(live.size, 0, 'every pass of a deleted effect is disposed');
assert.equal(frames.size, 0, 'no frame callback outlives its effect');
});
+1 -1
View File
@@ -378,7 +378,7 @@ export function tileCorridors(
* `reachOf(item)` is the item's [half width in pixels + 0.5, half width in
* metres]; `reference` the set's least pixel reach.
*/
export function packTile(tile, pieces, items, frame, reachOf, reference) {
export function packTile(tile, pieces, frame, reference) {
const { project } = frame;
// Its region in the plane, from its edges.
let x0 = Infinity;
+1 -1
View File
@@ -292,7 +292,7 @@ export function packSet(
(tile.west + tile.east) / 2,
(tile.south + tile.north) / 2,
);
const packed = packTile(tile, pieces, items, frame, reachOf, reference);
const packed = packTile(tile, pieces, frame, reference);
// Runs and bins relative to the tile's own: its style holds where
// they start in the set's.
const runStart = runs.length / 4;
+1 -8
View File
@@ -381,14 +381,7 @@ export const textureBytes = (state) =>
class GroundEffectDesc extends withPassDisposal(withFrameUpdates(EffectDesc)) {
static key = GROUND_EFFECT_KEY;
// Navara takes the first anchor that exists: the latest first.
static insertAfter = [
'gevFirmsGround',
'gevEarthquakeGround',
'gevObservedWeather',
'gevNepalEvent',
'gevImagery',
'toneMapping',
];
static insertAfter = ['gevImagery', 'toneMapping'];
static insertBefore = [
'gevPreSharpenOverlay',
'gevSharpen',
+1 -7
View File
@@ -85,13 +85,7 @@ const pulseEffect = defineGroundEffect({
key: KEY,
name: 'GevGroundPulses',
fragmentShader,
insertAfter: [
'gevGround',
'gevObservedWeather',
'gevNepalEvent',
'gevImagery',
'toneMapping',
],
insertAfter: ['gevGround', 'gevImagery', 'toneMapping'],
insertBefore: [
'gevPreSharpenOverlay',
'gevSharpen',
+1 -27
View File
@@ -1,31 +1,5 @@
// Public depth inputs shared by actual terrain/tiles classifiers.
import {
DataTexture,
FloatType,
RGBAFormat,
NearestFilter,
Matrix4,
Uniform,
RGBADepthPacking,
} from 'three';
export function createGroundTexture(data, width, height) {
const texture = new DataTexture(data, width, height, RGBAFormat, FloatType);
texture.minFilter = NearestFilter;
texture.magFilter = NearestFilter;
texture.needsUpdate = true;
return texture;
}
export function createGroundStorage(texels) {
const width = Math.min(1024, Math.max(1, texels));
const height = Math.max(1, Math.ceil(texels / width));
const data = new Float32Array(width * height * 4);
return {
data,
width,
height,
texture: createGroundTexture(data, width, height),
};
}
import { Matrix4, Uniform, RGBADepthPacking } from 'three';
export function groundSurfaceUniforms() {
return [
['tAllDepth', new Uniform(null)],
-147
View File
@@ -1,147 +0,0 @@
// A prototype of engine.ground on Navara's own vector layers, kept to
// measure against the screen pass (pass.js) and not used by the engine:
// each set's items grouped by style into one GeoJSON source and one
// clamped vector layer per group (discs and cells as polygons, pixel
// corridors as polylines; metre corridors are not drawn). `hide` picks how a
// hidden set goes: 'delete' (its layers deleted, rebuilt when shown) or
// 'update' (layer.update with show false).
import { areaRings, createGroundRegistry } from '../../ground.js';
const toHex = (rgba) =>
(Math.round(rgba[0] * 255) << 16) |
(Math.round(rgba[1] * 255) << 8) |
Math.round(rgba[2] * 255);
function ringCoordinates(flat) {
const ring = [];
for (let index = 0; index < flat.length; index += 2)
ring.push([flat[index], flat[index + 1]]);
ring.push(ring[0]);
return ring;
}
// Features grouped by their layer style: Map<key, { style, features }>.
export function vectorGroups(kind, items) {
const groups = new Map();
const add = (key, style, feature) => {
if (!groups.has(key)) groups.set(key, { style, features: [] });
groups.get(key).features.push(feature);
};
items.forEach((item, index) => {
if (kind === 'corridor') {
if (!item.widthPx) return;
const coordinates = [];
for (let at = 0; at < item.path.length; at += 2)
coordinates.push([item.path[at], item.path[at + 1]]);
add(
`line:${item.fill.join()}:${item.widthPx}`,
{
polyline: {
color: toHex(item.fill),
width: item.widthPx,
opacity: item.fill[3],
transparent: item.fill[3] < 1,
clampToGround: true,
},
},
{
type: 'Feature',
id: index,
properties: {},
geometry: { type: 'LineString', coordinates },
},
);
return;
}
const rings = areaRings(kind, item).map(ringCoordinates);
const fill = item.fill ?? [0, 0, 0, 0];
const outline = item.outline;
add(
`area:${fill.join()}:${outline ? `${outline.color.join()}:${outline.widthPx}` : ''}`,
{
polygon: {
color: toHex(fill),
opacity: fill[3],
transparent: true,
clampToGround: true,
...(outline
? {
outline: true,
outlineShow: true,
outlineColor: toHex(outline.color),
outlineWidth: outline.widthPx,
}
: {}),
},
},
{
type: 'Feature',
id: index,
properties: {},
geometry: { type: 'Polygon', coordinates: rings },
},
);
});
return groups;
}
/**
* @param {object} view an initialised Navara ThreeView
* @param {{ hide?: 'delete'|'update' }} [options]
*/
export function createNavaraVectorGround(view, { hide = 'delete' } = {}) {
const registry = createGroundRegistry((options) => {
let groups = new Map();
let batches = [];
let shown = true;
const release = () => {
for (const { layer, source } of batches) {
layer.delete();
source.delete();
}
batches = [];
};
const build = () => {
release();
for (const { style, features } of groups.values()) {
const source = view.addSource({
type: 'geojson',
data: { type: 'FeatureCollection', features },
});
const config = { type: 'vector', source, ...style };
batches.push({ source, config, layer: view.addLayer(config) });
}
};
return {
commit(items) {
groups = vectorGroups(options.kind, items);
if (shown || hide === 'update') build();
if (!shown && hide === 'update')
for (const batch of batches)
batch.layer.update({ ...batch.config, show: false });
view.forceUpdate();
},
show(visible) {
if (visible === shown) return;
shown = visible;
if (hide === 'delete') {
if (visible) build();
else release();
} else
for (const batch of batches)
batch.layer.update({ ...batch.config, show: visible });
view.forceUpdate();
},
destroy() {
release();
view.forceUpdate();
},
};
});
return {
ground: registry.ground,
pickables: () => [...registry.live.values()],
destroy: () => registry.destroyAll(),
};
}
+1 -33
View File
@@ -107,7 +107,7 @@ const unwrapped = ({ west, south, east, north }) => [
* replace); `load` (a tile or an image URL to a decoded image) and
* `createCanvas` are test seams.
* @returns {{ imagery: import('../../contract.js').GlobeImagery,
* diagnostics: () => object, destroy: () => void }}
* destroy: () => void }}
*/
export function createNavaraImagery(
view,
@@ -323,12 +323,6 @@ export function createNavaraImagery(
detail?.held.texture.dispose();
detail = null;
},
diagnostics: () => ({
kind: 'image',
loaded: drawn !== null,
staging: staging !== null,
detail: detail !== null,
}),
};
}
@@ -457,17 +451,6 @@ export function createNavaraImagery(
queue.destroy();
disposeAtlas();
},
diagnostics: () => ({
...queue.diagnostics(),
atlas: atlas
? {
level: atlas.plan.z,
tiles: atlas.plan.width * atlas.plan.height,
loaded: atlas.loaded,
failed: atlas.failed,
}
: null,
}),
};
}
@@ -551,11 +534,6 @@ export function createNavaraImagery(
tiler?.dispose();
tiler = null;
},
diagnostics: () => ({
kind: 'tiles',
...(tiler?.diagnostics() ?? {}),
staging: staged ? staged.tiler.diagnostics() : null,
}),
};
}
@@ -659,16 +637,6 @@ export function createNavaraImagery(
return {
imagery: registry.imagery,
/** Not contract: what each layer holds (QA reads it). */
diagnostics: () =>
Object.fromEntries(
registry
.ordered()
.map((state) => [
state.options.id,
entries.get(state)?.drawing.diagnostics(),
]),
),
destroy() {
offCamera();
registry.destroyAll();
+8 -12
View File
@@ -18,7 +18,7 @@ function fixture() {
const view = {
forceUpdate: () => frames++,
};
const { imagery, diagnostics, destroy } = createNavaraImagery(view, {
const { imagery, destroy } = createNavaraImagery(view, {
camera: {
changed,
pose: () => ({
@@ -53,7 +53,6 @@ function fixture() {
});
return {
imagery,
diagnostics,
destroy,
canvases,
draws,
@@ -80,10 +79,10 @@ test('a tiles layer mosaics the visible tiles into one atlas; a new source drops
const f = fixture();
const layer = f.imagery.createLayer({ id: 'a', source: tiles() });
await tick();
const first = f.diagnostics().a;
assert.equal(first.atlas.level, 12);
assert.ok(first.atlas.tiles >= 1 && first.atlas.tiles <= 64);
assert.equal(f.jobs.length, Math.min(6, first.atlas.tiles), 'six at a time');
const canvas = f.canvases[0];
const count = (canvas.width / 256) * (canvas.height / 256);
assert.ok(count >= 1 && count <= 64);
assert.equal(f.jobs.length, Math.min(6, count), 'six at a time');
assert.match(
f.jobs[0].url,
/^https:\/\/gibs-[abc]\.example\/12\/\d+\/\d+\.png$/,
@@ -189,13 +188,13 @@ test('a hidden tiles layer drops its atlas; shown again it builds one at the vie
const f = fixture();
const layer = f.imagery.createLayer({ id: 'a', source: tiles() });
layer.show(false);
assert.equal(f.diagnostics().a.atlas, null);
assert.equal(f.last().slots.length, 0);
assert.equal(f.credits.get('NASA GIBS'), 0, 'its credit goes too');
f.changed.raiseEvent();
assert.equal(f.diagnostics().a.atlas, null);
assert.equal(f.last().slots.length, 0);
layer.show(true);
await tick();
assert.ok(f.diagnostics().a.atlas);
assert.ok(f.last().slots[0].texture.image.width > 0);
assert.equal(f.last().slots.length, 1);
});
@@ -215,8 +214,6 @@ test('geographic tiles draw in degrees through the source’s transform', async
}),
});
await tick();
const { atlas } = f.diagnostics().radar;
assert.equal(atlas.level, 6, 'the source’s top level');
const [slot] = f.last().slots;
assert.equal(slot.look[2], 0, 'sampled in degrees');
const [west, south, east, north] = slot.bounds;
@@ -242,7 +239,6 @@ test('a staged tiles source builds its own atlas under the drawn one and takes i
);
await tick();
assert.equal(f.last().slots[0].texture, drawn, 'the drawn atlas stays');
assert.ok(f.diagnostics().a.staging, 'the staged atlas loads');
const next = f.jobs.slice(firstJobs);
assert.ok(next.length > 0 && next.every((job) => /next/.test(job.url)));
let done;
+1 -4
View File
@@ -21,7 +21,7 @@ import { DataTexture, Matrix4, RGBADepthPacking, Uniform } from 'three';
import { withFrameUpdates, withPassDisposal } from '../frameDescriptor.js';
import { MAX_IMAGERY_SLOTS } from './index.js';
export const IMAGERY_EFFECT_KEY = 'gevImagery';
const IMAGERY_EFFECT_KEY = 'gevImagery';
const SLOTS = Array.from({ length: MAX_IMAGERY_SLOTS }, (_, index) => index);
@@ -179,9 +179,6 @@ class ImageryEffectDesc extends withPassDisposal(withFrameUpdates(EffectDesc)) {
// Navara takes the first anchor that exists: right after tone mapping.
static insertAfter = ['toneMapping'];
static insertBefore = [
'gevNepalEvent',
'gevObservedWeather',
'gevEarthquakeGround',
'gevGroundPulses',
'gevGround',
'gevPreSharpenOverlay',
+1 -21
View File
@@ -2,14 +2,11 @@
// the product way (viewOptions.js) and the GlobeEngine on it. Load it with a
// dynamic import() so Navara stays out of the Cesium-mode bundle.
import { layerEffectDesc, withFrameUpdates } from './frameDescriptor.js';
import ThreeView, {
Color as NavaraColor,
MeshDesc,
EffectDesc,
Effect as NavaraEffect,
DrapedMesh,
setupMaterialForDrape,
} from '@navaramap/three';
import * as geo from '../../geo/index.js';
import { DefaultPlugin } from '@navaramap/three-default-plugin';
@@ -124,7 +121,7 @@ function groundInView(engine) {
* `?look=` (cinematic by default); `hd` draws at the device pixel ratio
* with MSAA (Navara HD), else at CSS pixels without it. The sun follows the engine clock (the
* page's app clock): the look reads its frame time.
* @returns {Promise<{ view: object, engine: import('../contract.js').GlobeEngine, destroy: () => void }>}
* @returns {Promise<{ setRenderLoop: (enabled: boolean) => void, engine: import('../contract.js').GlobeEngine, destroy: () => void }>}
*/
export async function createNavaraGlobe({ container, search, hd = false }) {
if (!container) throw new TypeError('createNavaraGlobe needs a container');
@@ -272,10 +269,6 @@ export async function createNavaraGlobe({ container, search, hd = false }) {
view,
MeshDesc,
NavaraColor,
EffectDesc: layerEffectDesc(EffectDesc),
NavaraEffect,
DrapedMesh,
setupMaterialForDrape,
alignDaylightToRestoredView() {
look.resetDaylight();
engine.render.request('restored-daylight');
@@ -283,20 +276,7 @@ export async function createNavaraGlobe({ container, search, hd = false }) {
}),
});
return {
view,
engine,
NavaraColor,
MeshDesc,
EffectDesc,
LayerEffectDesc: layerEffectDesc(EffectDesc),
NavaraEffect,
DrapedMesh,
setupMaterialForDrape,
// Startup can fly from the engine's placeholder camera into a shared view.
alignDaylightToRestoredView() {
look.resetDaylight();
engine.render.request('restored-daylight');
},
setRenderLoop: (enabled) => {
parked = !enabled;
setRenderLoopEnabled(view, enabled);
-2
View File
@@ -34,7 +34,5 @@ export function createBatchIdPool() {
released.add(wrapper);
for (const id of wrapper.batchIds) if (id > 0) free.push(id);
},
/** The ids waiting for a wrapper. */
size: () => free.length,
};
}
@@ -25,7 +25,6 @@ test('a rebuilt set takes the ids of the set it replaces', () => {
set = wrapper(pool.source(ctx), 1000);
}
assert.equal(ctx.issued(), 1000);
assert.equal(pool.size(), 0);
assert.equal(new Set(set.batchIds).size, 1000);
});
@@ -35,7 +34,6 @@ test('live sets never share an id, and a set gives its ids back once', () => {
const a = wrapper(pool.source(ctx), 3);
pool.release(a);
pool.release(a);
assert.equal(pool.size(), 3);
const b = wrapper(pool.source(ctx), 2);
const c = wrapper(pool.source(ctx), 2);
const ids = [...b.batchIds, ...c.batchIds];
@@ -47,7 +45,6 @@ test('ids Navara could not give (0) are not pooled', () => {
const pool = createBatchIdPool();
pool.release({ batchIds: [0, 0, 7] });
pool.release(null);
assert.equal(pool.size(), 1);
const none = { genGlobalBatchId: () => undefined };
assert.equal(pool.source(none).genGlobalBatchId(), 7);
assert.equal(pool.source(none).genGlobalBatchId(), undefined);
@@ -0,0 +1,70 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
// EffectDesc gives insertAfter priority, then tries insertBefore. Check the
// actual renderer declarations under every activation order, including the
// minimal look, whose pipeline has no toneMapping anchor.
const declarations = ['gevImagery', 'gevGround', 'gevPreSharpenOverlay'];
async function declared(key, path, className) {
let source = await fs.readFile(new URL(path, import.meta.url), 'utf8');
if (className) source = source.split(`class ${className}`)[1];
const anchors = (name) =>
[
...source
.match(new RegExp(`static ${name} = \\[([^\\]]*)\\]`))[1]
.matchAll(/'([^']+)'/g),
].map((m) => m[1]);
return {
key,
after: anchors('insertAfter'),
before: anchors('insertBefore'),
};
}
const specs = [
await declared('gevImagery', './imagery/pass.js', 'ImageryEffectDesc'),
await declared('gevGround', './ground/pass.js', 'GroundEffectDesc'),
await declared(
'gevPreSharpenOverlay',
'./overlay.js',
'GevPreSharpenOverlayEffectDesc',
),
];
const permutations = (items) =>
items.length
? items.flatMap((item, i) =>
permutations(items.filter((_, j) => i !== j)).map((rest) => [
item,
...rest,
]),
)
: [[]];
test('all ground/glyph activation orders preserve imagery, classification and marker stages', () => {
for (const toneMapping of [false, true])
for (const activation of permutations(specs)) {
const order = [
'mrt',
...(toneMapping ? ['toneMapping'] : []),
'gevSharpen',
'smaa',
'gevOverlay',
'final',
];
for (const spec of activation) {
const after = spec.after.find((key) => order.includes(key));
const before = spec.before.find((key) => order.includes(key));
const index = after
? order.indexOf(after) + 1
: before
? order.indexOf(before)
: order.length;
order.splice(index, 0, spec.key);
}
assert.deepEqual(
order.filter((key) => specs.some((s) => s.key === key)),
declarations,
`${toneMapping}: ${activation.map((s) => s.key)}`,
);
}
});
-2
View File
@@ -8,8 +8,6 @@
import { createCpuPicker } from '../cpuPicks.js';
export { distanceToSegment } from '../cpuPicks.js';
const CLICK_TIMEOUT_MS = 250;
// A GPU answer this recent belongs to the click being delivered.
const EARLY_ANSWER_MS = 100;
+2 -1
View File
@@ -2,7 +2,8 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import { createMoverStore, normalizeMoverSetOptions } from '../movers.js';
import { normalizeLineOptions } from '../lines.js';
import { createNavaraPicking, distanceToSegment } from './picking.js';
import { createNavaraPicking } from './picking.js';
import { distanceToSegment } from '../cpuPicks.js';
// A projector that maps x → screen x and y → screen y, z is the depth (the
// distance from the camera at the origin along +z).
+2 -2
View File
@@ -46,7 +46,7 @@ export function surfaceRay(place) {
}
/** Height above the ellipsoid of a hit `distance` metres down a surfaceRay. */
export const heightAlongRay = (ray, distance) =>
export const heightAlongRay = (distance) =>
Number.isFinite(distance) ? RAY_START_HEIGHT - distance : undefined;
const worldRay = new Ray();
@@ -279,7 +279,7 @@ export function createNavaraSurface(view, hooks) {
shownRoots.length = 0;
if (!Number.isFinite(hit.distance))
hit = finestHiddenHit(roots, excluded, ray);
const height = heightAlongRay(ray, hit.distance);
const height = heightAlongRay(hit.distance);
if (height === undefined) return terrainDetail(place);
return { height, source: 'tiles', tileSizeM: tileSizeOf(hit.root) };
};
+2 -2
View File
@@ -84,8 +84,8 @@ test('surfaceRay runs down the ellipsoid normal from 12 km', () => {
cartesian3.create(),
);
near(cartographic.fromCartesian(below, WGS84).height, 0, 1e-6, 'ground');
assert.equal(heightAlongRay(ray, 11950), 50);
assert.equal(heightAlongRay(ray, null), undefined);
assert.equal(heightAlongRay(11950), 50);
assert.equal(heightAlongRay(null), undefined);
});
test('sampleHeight hits the top of the loaded tiles and keeps tile geometry', () => {