mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Keyless terrain reaches the renderer as quantized-mesh terrain
The contract's TerrainSpec gains quantizedMesh terrain: Cesium's tile format in the folder at its url, heights above the ellipsoid. Without an ion key the globe-port map engine asks for Re:Earth's keyless terrain as it, where it asked for the ellipsoid, so the renderer draws the same ground; without the terrain capability keeps the ellipsoid. Cesium's globe port draws it through CesiumTerrainProvider with the keyless terrain's retry policy.
This commit is contained in:
1 parent
c57e535275
commit
1f307e0735
9 files changed
+101
-17
No files matched your search
+13
-3
@@ -12,7 +12,8 @@
|
||||
* provider, a handle per imagery layer and photoreal base. A hidden
|
||||
* photoreal base is turned off through the port and on again when shown.
|
||||
*/
|
||||
import { findFrame, findGlobe } from '../render/rendererOf.js';
|
||||
import { findFrame, findGlobe, rendererOf } from '../render/rendererOf.js';
|
||||
import { KEYLESS_TERRAIN_URL } from './keylessTerrain.js';
|
||||
|
||||
const ESRI_TILES =
|
||||
'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';
|
||||
@@ -154,7 +155,11 @@ export const globeMapEngine = Object.freeze({
|
||||
spec: { kind: 'world', requestVertexNormals: true },
|
||||
};
|
||||
},
|
||||
keyless: async () => ({ provider: null, spec: { kind: 'ellipsoid' } }),
|
||||
// Re:Earth's keyless terrain, as the Cesium map engine draws it.
|
||||
keyless: async () => ({
|
||||
provider: null,
|
||||
spec: { kind: 'quantizedMesh', url: KEYLESS_TERRAIN_URL },
|
||||
}),
|
||||
}),
|
||||
createImageryLayer: (spec) => ({ spec, layer: null }),
|
||||
requestRender(host) {
|
||||
@@ -197,8 +202,13 @@ export const globeMapEngine = Object.freeze({
|
||||
handle.layer = null;
|
||||
},
|
||||
applyTerrain(host, result) {
|
||||
// Where the renderer draws no terrain, the ellipsoid stays.
|
||||
const spec = result.spec ?? null;
|
||||
const flat =
|
||||
spec?.kind !== 'ellipsoid' &&
|
||||
rendererOf(host)?.capabilities?.has('terrain') === false;
|
||||
findGlobe(host)
|
||||
?.setTerrain(result.spec ?? null)
|
||||
?.setTerrain(flat ? null : spec)
|
||||
.catch((error) => console.warn('[MapStack] terrain failed', error));
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { globeMapEngine as engine } from './globeEngine.js';
|
||||
import { KEYLESS_TERRAIN_URL } from './keylessTerrain.js';
|
||||
import { mapEngineFor, provideMapEngine } from './engine.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { provideApplicationHooks } from '../render/applicationHooks.js';
|
||||
@@ -69,8 +70,8 @@ test('the globe is shown and hidden through the port, read back without globe vi
|
||||
assert.equal(engine.globeShown(visible.host), false);
|
||||
});
|
||||
|
||||
test('terrain is the port’s world terrain, or the ellipsoid without a token', async () => {
|
||||
const { host, renderer } = scene();
|
||||
test('terrain is the port’s world terrain, or the keyless quantized mesh without a token', async () => {
|
||||
const { host, renderer } = scene(['terrain']);
|
||||
await assert.rejects(engine.terrain.world(''), /ion token/);
|
||||
const world = await engine.terrain.world('token');
|
||||
engine.applyTerrain(host, world);
|
||||
@@ -79,7 +80,7 @@ test('terrain is the port’s world terrain, or the ellipsoid without a token',
|
||||
]);
|
||||
engine.applyTerrain(host, await engine.terrain.keyless());
|
||||
assert.deepEqual(calls(renderer, 'setTerrain').at(-1).args, [
|
||||
{ kind: 'ellipsoid' },
|
||||
{ kind: 'quantizedMesh', url: KEYLESS_TERRAIN_URL },
|
||||
]);
|
||||
assert.throws(() => engine.imagery.ion(2, ''), /token/);
|
||||
assert.deepEqual(engine.imagery.ion(3, 'token'), {
|
||||
@@ -88,6 +89,12 @@ test('terrain is the port’s world terrain, or the ellipsoid without a token',
|
||||
});
|
||||
});
|
||||
|
||||
test('where the renderer draws no terrain the ellipsoid stays', async () => {
|
||||
const { host, renderer } = scene([]);
|
||||
engine.applyTerrain(host, await engine.terrain.keyless());
|
||||
assert.deepEqual(calls(renderer, 'setTerrain').at(-1).args, [null]);
|
||||
});
|
||||
|
||||
test('photoreal loads through the port, hides and shows, and is released', async () => {
|
||||
const { host, renderer } = scene(['photoreal']);
|
||||
const none = await engine.loadPhotoreal(host, {});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @module maps/keylessTerrain
|
||||
* @description The terrain the map stacks draw without an ion key:
|
||||
* Re:Earth's keyless quantized-mesh terrain, heights above the ellipsoid.
|
||||
*/
|
||||
|
||||
/** Its folder: `layer.json` and `{z}/{x}/{y}.terrain` under it. */
|
||||
export const KEYLESS_TERRAIN_URL =
|
||||
'https://terrain.reearth.land/cesium-mesh/ellipsoid';
|
||||
Reference in new issue
Block a user