mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor(maps): separate source factories and scene coordination
This commit is contained in:
1 parent
561a781099
commit
e59282dc9c
22 files changed
+1807
-798
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
/** These factories are lazy: a hidden globe must not trigger terrain loading. */
|
||||
export async function createWorldTerrain(accessToken, { signal } = {}) {
|
||||
accessToken = String(accessToken || '').trim();
|
||||
if (!accessToken)
|
||||
throw new Error('World terrain requires an explicit ion token');
|
||||
signal?.throwIfAborted();
|
||||
const resource = await Cesium.IonResource.fromAssetId(1, { accessToken });
|
||||
signal?.throwIfAborted();
|
||||
return {
|
||||
provider: await Cesium.CesiumTerrainProvider.fromUrl(resource, {
|
||||
requestVertexNormals: true,
|
||||
requestWaterMask: false,
|
||||
ellipsoid: Cesium.Ellipsoid.WGS84,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export async function createKeylessTerrain() {
|
||||
try {
|
||||
// Re:Earth / Mapterhorn ellipsoidal quantized mesh, CC BY 4.0.
|
||||
return {
|
||||
provider: await Cesium.CesiumTerrainProvider.fromUrl(
|
||||
'https://terrain.reearth.land/cesium-mesh/ellipsoid',
|
||||
),
|
||||
};
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
'[MapStack] Re:Earth terrain unavailable, falling back to flat ellipsoid terrain:',
|
||||
error,
|
||||
);
|
||||
return { provider: new Cesium.EllipsoidTerrainProvider() };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user