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
@@ -20,6 +20,7 @@ import { provideUnboundGlobe } from '../rendererOf.js';
|
||||
import { isBaseTileset, markBaseTileset } from '../baseTilesets.js';
|
||||
import { listenerList, uncaught } from './common.js';
|
||||
import { createCesiumImagery } from './imagery.js';
|
||||
import { createTerrainRetryPolicy } from '../../maps/terrainRetry.js';
|
||||
|
||||
// The base marks live outside the adapter, so code that is not Cesium's can
|
||||
// mark a base; they are re-exported here for the code that still is.
|
||||
@@ -51,6 +52,22 @@ async function terrainProvider(spec, { worldDataToken }) {
|
||||
requestWaterMask: false,
|
||||
});
|
||||
}
|
||||
if (spec.kind === 'quantizedMesh') {
|
||||
if (typeof spec.url !== 'string' || !spec.url)
|
||||
throw new TypeError('Quantized-mesh terrain needs its url');
|
||||
// Busy hosts are asked again as the keyless terrain is
|
||||
// (`terrainRetry.js`); every tile's resource inherits the policy.
|
||||
const policy = createTerrainRetryPolicy();
|
||||
const resource = new Cesium.Resource({
|
||||
url: spec.url,
|
||||
retryCallback: policy.retryCallback,
|
||||
retryAttempts: policy.retryAttempts,
|
||||
});
|
||||
return Cesium.CesiumTerrainProvider.fromUrl(resource, {
|
||||
requestVertexNormals: spec.requestVertexNormals ?? false,
|
||||
requestWaterMask: false,
|
||||
});
|
||||
}
|
||||
throw new TypeError(`Unknown terrain kind: ${spec.kind}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,6 +421,35 @@ test('terrain: the ellipsoid with exaggeration; the last call wins', async () =>
|
||||
await assert.rejects(flat.port.setTerrain({ kind: 'world' }), /no terrain/);
|
||||
});
|
||||
|
||||
test('terrain: quantized mesh at its url, asked again when its host is busy', async (t) => {
|
||||
const { scene, port } = setup();
|
||||
const made = new Cesium.EllipsoidTerrainProvider();
|
||||
const asked = [];
|
||||
t.mock.method(Cesium.CesiumTerrainProvider, 'fromUrl', async (...args) => {
|
||||
asked.push(args);
|
||||
return made;
|
||||
});
|
||||
await port.setTerrain({
|
||||
kind: 'quantizedMesh',
|
||||
url: 'https://terrain.example/mesh',
|
||||
exaggeration: 1.5,
|
||||
});
|
||||
assert.equal(scene.terrainProvider, made);
|
||||
assert.equal(scene.verticalExaggeration, 1.5);
|
||||
const [[resource, options]] = asked;
|
||||
assert.equal(resource.url, 'https://terrain.example/mesh');
|
||||
assert.ok(resource.retryAttempts > 0);
|
||||
assert.equal(typeof resource.retryCallback, 'function');
|
||||
assert.deepEqual(options, {
|
||||
requestVertexNormals: false,
|
||||
requestWaterMask: false,
|
||||
});
|
||||
await assert.rejects(
|
||||
port.setTerrain({ kind: 'quantizedMesh' }),
|
||||
/needs its url/,
|
||||
);
|
||||
});
|
||||
|
||||
test('setBase replaces the imagery and says what it drew', async () => {
|
||||
const { scene, port } = setup();
|
||||
const overlay = port.imagery.add({ kind: 'xyz', url: url('overlay') });
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { createTerrainRetryPolicy } from '../../maps/terrainRetry.js';
|
||||
import { KEYLESS_TERRAIN_URL } from '../../maps/keylessTerrain.js';
|
||||
|
||||
/** Re:Earth / Mapterhorn ellipsoidal quantized mesh, CC BY 4.0. */
|
||||
export const KEYLESS_TERRAIN_URL =
|
||||
'https://terrain.reearth.land/cesium-mesh/ellipsoid';
|
||||
export { KEYLESS_TERRAIN_URL };
|
||||
|
||||
/** These factories are lazy: a hidden globe must not trigger terrain loading. */
|
||||
export async function createWorldTerrain(accessToken, { signal } = {}) {
|
||||
|
||||
Reference in new issue
Block a user