diff --git a/web/Dockerfile b/web/Dockerfile index c0dc03b95..21e29c284 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -41,7 +41,6 @@ ENV REEARTH_AUTH0_AUDIENCE=null ENV REEARTH_AUTH0_CLIENT_ID=null ENV REEARTH_AUTH0_DOMAIN=null ENV REEARTH_BRAND=null -ENV REEARTH_CESIUM_ION_ACCESS_TOKEN=null ENV REEARTH_CLOUD_API=null ENV REEARTH_CURRENT_TOS=null ENV REEARTH_CUSTOM_PROVIDERS=null diff --git a/web/docker/reearth_config.json.template b/web/docker/reearth_config.json.template index 2525ac751..f9213877b 100644 --- a/web/docker/reearth_config.json.template +++ b/web/docker/reearth_config.json.template @@ -4,7 +4,6 @@ "auth0ClientId": ${REEARTH_AUTH0_CLIENT_ID}, "auth0Domain": ${REEARTH_AUTH0_DOMAIN}, "brand": ${REEARTH_BRAND}, - "cesiumIonAccessToken": ${REEARTH_CESIUM_ION_ACCESS_TOKEN}, "cloudApi": ${REEARTH_CLOUD_API}, "currentTos": ${REEARTH_CURRENT_TOS}, "customProviders": ${REEARTH_CUSTOM_PROVIDERS}, diff --git a/web/src/classic/components/molecules/Visualizer/compatibility/BACKWARD_COMPATIBILITY.md b/web/src/classic/components/molecules/Visualizer/compatibility/BACKWARD_COMPATIBILITY.md index fba2b519d..8c4f827fc 100644 --- a/web/src/classic/components/molecules/Visualizer/compatibility/BACKWARD_COMPATIBILITY.md +++ b/web/src/classic/components/molecules/Visualizer/compatibility/BACKWARD_COMPATIBILITY.md @@ -54,6 +54,7 @@ const overriddenSceneProperty = useMemo( | Old Type | New Type | Asset ID | Notes | |-------------------|------------------|----------|--------------------------------| +| `undefined` / `null` | `google_satellite` | - | Default when no type specified | | `default` | `cesium_ion` | 2 | Cesium World Imagery | | `default_label` | `cesium_ion` | 3 | Cesium World Imagery + Labels | | `default_road` | `cesium_ion` | 4 | Cesium World Imagery + Roads | @@ -80,21 +81,31 @@ const overriddenSceneProperty = useMemo( "tiles": [ { "id": "tile-1", "tile_type": "cesium_ion", "cesium_ion_asset_id": 2 }, { "id": "tile-2", "tile_type": "open_street_map" }, - { "id": "tile-3", "tile_url": "https://..." } + { "id": "tile-3", "tile_url": "https://...", "tile_type": "google_satellite" } ] } ``` -Note: Tiles without a `tile_type` field are left unchanged. +Note: Tiles without a `tile_type` field are automatically assigned `"google_satellite"` as the default. ## Terrain Type Migrations ### Rules -1. **ArcGIS migration:** If `terrainType` is `"arcgis"`, change to `"reearth_terrain"` +1. **Default:** If `terrainType` is `undefined`, `null`, or empty AND terrain is enabled (`terrain: true`), set to `"reearth_terrain"` +2. **ArcGIS migration:** If `terrainType` is `"arcgis"`, change to `"reearth_terrain"` ### Examples +**Default terrain type:** +```json +// Before +{ "terrain": true } + +// After +{ "terrain": true, "terrainType": "reearth_terrain" } +``` + **ArcGIS migration:** ```json // Before diff --git a/web/src/classic/components/molecules/Visualizer/compatibility/README.md b/web/src/classic/components/molecules/Visualizer/compatibility/README.md index 32c830bc3..482279357 100644 --- a/web/src/classic/components/molecules/Visualizer/compatibility/README.md +++ b/web/src/classic/components/molecules/Visualizer/compatibility/README.md @@ -69,6 +69,7 @@ This directory contains a comprehensive system for handling backward compatibili ### Backward Compatibility Rules **Tiles:** +- `undefined` / `null` / empty → `"google_satellite"` (default) - `"default"` → `cesium_ion` (asset_id: 2) - `"default_label"` → `cesium_ion` (asset_id: 3) - `"default_road"` → `cesium_ion` (asset_id: 4) @@ -77,6 +78,7 @@ This directory contains a comprehensive system for handling backward compatibili - `"esri_world_topo"` → `open_street_map` **Terrain:** +- `undefined` / `null` / empty → `"reearth_terrain"` (default, only when terrain is enabled) - `"arcgis"` → `"reearth_terrain"` ### Fallback Rules (Only When No Cesium Ion Token) diff --git a/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.test.ts b/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.test.ts index ddb163f6b..b8ebfdaeb 100644 --- a/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.test.ts +++ b/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.test.ts @@ -121,7 +121,7 @@ describe("migrateTileType", () => { expect(result).toEqual(tile); }); - it("should not modify tile without tile_type", () => { + it("should default to google_satellite when tile_type is undefined", () => { const tile = { id: "test-tile", tile_url: "https://example.com", @@ -132,6 +132,7 @@ describe("migrateTileType", () => { expect(result).toEqual({ id: "test-tile", tile_url: "https://example.com", + tile_type: "google_satellite", }); }); }); @@ -190,6 +191,34 @@ describe("migrateTerrainType", () => { depthTestAgainstTerrain: true, }); }); + + it("should default to reearth_terrain when terrainType is undefined", () => { + const terrain = { + terrain: true, + }; + + const result = migrateTerrainType(terrain); + + expect(result).toEqual({ + terrain: true, + terrainType: "reearth_terrain", + }); + }); + + it("should default to reearth_terrain when terrainType is undefined with other properties", () => { + const terrain = { + terrain: true, + terrainExaggeration: 1.5, + }; + + const result = migrateTerrainType(terrain); + + expect(result).toEqual({ + terrain: true, + terrainType: "reearth_terrain", + terrainExaggeration: 1.5, + }); + }); }); describe("applyBackwardCompatibility", () => { diff --git a/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.ts b/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.ts index 5887c038c..7053662de 100644 --- a/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.ts +++ b/web/src/classic/components/molecules/Visualizer/compatibility/backwardCompatibility.ts @@ -29,6 +29,7 @@ export function applyBackwardCompatibility( /** * Migrate tile type from old format to new format * Backward compatibility rules: + * - undefined/null/empty → "google_satellite" (default) * - "default" → "cesium_ion" with cesiumIonAssetId: 2 * - "default_label" → "cesium_ion" with cesiumIonAssetId: 3 * - "default_road" → "cesium_ion" with cesiumIonAssetId: 4 @@ -41,6 +42,17 @@ export function migrateTileType( ): NonNullable[number] { const tileType = tile.tile_type; + // Default to google_satellite if no type specified + if (!tileType) { + console.warn( + `[Re:Earth] Tile type migrated: undefined → "google_satellite" - Backward compatibility (tile ID: ${tile.id})`, + ); + return { + ...tile, + tile_type: "google_satellite", + }; + } + // Backward compatibility: migrate old tile types to new ones switch (tileType) { case "default": { @@ -117,11 +129,23 @@ export function migrateTileType( /** * Migrate terrain type from old format to new format * Backward compatibility rules: + * - undefined/null/empty → "reearth_terrain" (default, only when terrain is enabled) * - If terrainType is "arcgis" (legacy) → change to "reearth_terrain" */ export function migrateTerrainType(terrain: TerrainProperty): TerrainProperty { const { terrainType } = terrain; + // Default to reearth_terrain if no type specified and terrain is enabled + if (!terrainType && terrain.terrain) { + console.warn( + `[Re:Earth] Terrain type migrated: undefined → "reearth_terrain" - Backward compatibility (default)`, + ); + return { + ...terrain, + terrainType: "reearth_terrain", + }; + } + // Migrate "arcgis" to "reearth_terrain" (handles legacy string type) if ((terrainType as string) === "arcgis") { console.warn( diff --git a/web/src/classic/components/molecules/Visualizer/compatibility/compatibility.integration.test.ts b/web/src/classic/components/molecules/Visualizer/compatibility/compatibility.integration.test.ts index 652f454f3..d9d54ecc9 100644 --- a/web/src/classic/components/molecules/Visualizer/compatibility/compatibility.integration.test.ts +++ b/web/src/classic/components/molecules/Visualizer/compatibility/compatibility.integration.test.ts @@ -30,7 +30,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => { ]); expect(afterBackwardCompat?.terrain).toEqual({ terrain: true, - // terrainType is NOT added when missing + terrainType: "reearth_terrain", // Default added when missing }); // Step 2: Apply fallbacks (no token, so fallbacks apply) @@ -43,7 +43,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => { ]); expect(final?.terrain).toEqual({ terrain: true, - // terrainType remains undefined (no fallback when missing) + terrainType: "reearth_terrain", // Default was added in backward compat step }); }); @@ -71,7 +71,7 @@ describe("Backward Compatibility + Fallbacks Integration", () => { ]); expect(afterBackwardCompat?.terrain).toEqual({ terrain: true, - // terrainType is NOT added when missing + terrainType: "reearth_terrain", // Default added when missing }); // Step 2: Apply fallbacks (has token, so NO fallbacks) @@ -84,31 +84,31 @@ describe("Backward Compatibility + Fallbacks Integration", () => { ]); expect(final?.terrain).toEqual({ terrain: true, - // terrainType remains undefined (token doesn't affect missing terrainType) + terrainType: "reearth_terrain", // Default was added in backward compat step }); }); - it("should handle tile without tile_type (no migration)", () => { + it("should handle tile without tile_type (adds google_satellite default)", () => { const input: SceneProperty = { tiles: [{ id: "tile-1", tile_url: "https://example.com" }], }; - // Step 1: Backward compatibility (does NOT add tile_type when missing) + // Step 1: Backward compatibility (adds google_satellite default) const afterBackwardCompat = applyBackwardCompatibility(input); expect(afterBackwardCompat?.tiles?.[0]).toEqual({ id: "tile-1", tile_url: "https://example.com", - // tile_type and cesium_ion_asset_id are NOT added + tile_type: "google_satellite", // Default added }); - // Step 2: Apply fallbacks (no tile_type, so no fallback applies) + // Step 2: Apply fallbacks (google_satellite doesn't need fallback) const final = applyFallbacks(afterBackwardCompat); expect(final?.tiles?.[0]).toEqual({ id: "tile-1", tile_url: "https://example.com", - // Remains unchanged + tile_type: "google_satellite", // Remains google_satellite }); }); diff --git a/web/src/published.tsx b/web/src/published.tsx index de47df16c..9289b3d4a 100644 --- a/web/src/published.tsx +++ b/web/src/published.tsx @@ -6,6 +6,7 @@ import { createRoot } from "react-dom/client"; import App from "./publishedapp"; import loadConfig from "./services/config"; +import { initializeSentinel } from "./services/sentinel"; import "./wdyr"; window.React = React; @@ -14,6 +15,10 @@ window.ReactDOM = ReactDOM; loadConfig().finally(() => { const element = document.getElementById("root"); if (!element) throw new Error("root element is not found"); + + // Initialize Sentinel for secure asset authentication (non-blocking) + initializeSentinel(); + const root = createRoot(element); root.render(); });