fix(globe): harden the Navara engine after review

- maps: photoreal hides the base imagery layer instead of deleting it,
  and a new base layer goes in before the old one goes: deleting the
  last raster layer stops Navara 0.2.1 loading terrain at the current
  view, which left terrainHeight undefined under the tiles
- Google 3D tiles open Navara's attribution card so the tiles'
  copyright lines are on screen, as Cesium shows them; onScreen
  credits do the same
- setCameraInputs merges into the camera options set through the
  engine (new setCameraOptions extension) instead of resetting them
- createNavaraGlobe disposes the view and canvas if the engine throws
- the pin test checks the installed Navara version and catches
  bracketed private access
- QA: draw-match checks at the nadir clamp, after a Navara flight and
  after a mouse drag; terrain under photoreal set right away; the
  copyright lines on screen; create/destroy/create leaves no canvas,
  frames, animation frames, workers or console errors (54/54)
This commit is contained in:
German Khokhlov committed 2026-10-15 19:04:07 +04:00
1 parent 90c8e7763a
commit a4ac0b9b0d
8 files changed
+148 -25

No files matched your search

+33 -1
View File
@@ -8,6 +8,8 @@ function fakeView() {
layers: [],
shown: [],
frames: 0,
opened: 0,
rasterCounts: [],
addSource(desc) {
const source = {
id: `source-${view.sources.length}`,
@@ -24,14 +26,21 @@ function fakeView() {
const layer = {
id: `layer-${view.layers.length}`,
desc,
update(next) {
layer.desc = next;
},
delete() {
view.layers = view.layers.filter((entry) => entry !== layer);
view.rasterCounts.push(layersOf(view, 'raster').length);
},
};
view.layers.push(layer);
return layer;
},
attribution: {
show() {
view.opened++;
},
add(items) {
view.shown.push(...items);
},
@@ -159,9 +168,14 @@ test('setPhotorealTiles shows Google 3D tiles with a browser key and the Google
'https://tile.googleapis.com/v1/3dtiles/root.json?key=browser%20key',
);
assert.deepEqual(tiles.desc.model, { maxSse: 16 });
assert.equal(layersOf(view, 'raster').length, 0, 'base imagery removed');
// Hidden, not deleted: Navara 0.2.1 stops loading terrain at the current
// view when the last raster layer is deleted.
const [base] = layersOf(view, 'raster');
assert.equal(base.desc.raster?.show, false, 'base imagery not hidden');
assert.deepEqual(view.rasterCounts, []);
const google = view.shown.find((item) => item.creditLayerId === tiles.id);
assert.ok(google?.logo, 'no Google logo');
assert.ok(view.opened > 0, 'the copyright lines are not opened on screen');
assert.equal(maps.photorealActive(), true);
await maps.setPhotorealTiles(null);
assert.equal(maps.photorealActive(), false);
@@ -169,6 +183,24 @@ test('setPhotorealTiles shows Google 3D tiles with a browser key and the Google
assert.ok(!view.shown.some((item) => item.creditLayerId));
});
test('base imagery hidden by photoreal comes back; a new one replaces it without a raster gap', async () => {
const view = fakeView();
const { maps } = createNavaraMaps(view);
await maps.setBaseImagery({ kind: 'osm' });
await maps.setPhotorealTiles({ googleApiKey: 'k' });
const [osm] = layersOf(view, 'raster');
await maps.setPhotorealTiles(null);
await maps.setBaseImagery({ kind: 'osm' });
assert.deepEqual(layersOf(view, 'raster'), [osm]);
assert.notEqual(osm.desc.raster?.show, false, 'OSM still hidden');
view.rasterCounts.length = 0;
await maps.setBaseImagery({ kind: 'esri-imagery' });
const rasters = layersOf(view, 'raster');
assert.equal(rasters.length, 1);
assert.match(rasters[0].desc.source.desc.url, /World_Imagery/);
assert.deepEqual(view.rasterCounts, [1], 'a raster gap while replacing');
});
test('photoreal without a browser key rejects and changes nothing', async () => {
const view = fakeView();
const { maps } = createNavaraMaps(view);