From 8f63fda5fc88488a8180736cc99e8dae6d183a61 Mon Sep 17 00:00:00 2001 From: "Adam N. Morris" Date: Thu, 28 Sep 2023 14:37:32 -0500 Subject: [PATCH] Changes to support photorealistic 3D tiles in ion --- .../cesium/performance/app/extension.py | 7 ++--- docs/release-guide/README.md | 29 +++++++++---------- extern/cesium-native | 2 +- .../cesium/omniverse/ui/quick_add_widget.py | 9 ++++++ src/core/src/CesiumIonSession.cpp | 9 ++++-- src/core/src/OmniTileset.cpp | 11 +++++-- 6 files changed, 40 insertions(+), 27 deletions(-) diff --git a/apps/exts/cesium.performance.app/cesium/performance/app/extension.py b/apps/exts/cesium.performance.app/cesium/performance/app/extension.py index a375c4ad6..1dd223cca 100644 --- a/apps/exts/cesium.performance.app/cesium/performance/app/extension.py +++ b/apps/exts/cesium.performance.app/cesium/performance/app/extension.py @@ -23,8 +23,8 @@ Tokens as CesiumTokens, ) -ION_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlZjM4NjgzNC01Nzg5LTQyMjAtYmYxMC0yNGY2MGEzOGViMGUiLCJpZCI6MjU5LCJpYXQiOjE2OTM1Nzg5MTN9.-J367LOCiroxRBoH9eKhgssEd2Wk_IoqOxROfy-dPjs" # noqa: E501 -GOOGLE_3D_TILES_URL = "https://tile.googleapis.com/v1/3dtiles/root.json?key=AIzaSyBTr9BGnwtJmS0sL86iTb6QhdJlnkAFLoE" +ION_ACCESS_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4MTkxNmE1Ni03NzEyLTRmNzYtODcwYi1mOTZkM2RiNDFhYmUiLCJpZCI6MTI5LCJpYXQiOjE2OTU4NDQ0MTR9.r-ZnPKqCxRk9tXBDNYaY1rHHm6Fe4O-HMOJYVITe0do" # noqa: E501 +GOOGLE_3D_TILES_ION_ID = 823 CESIUM_DATA_PRIM_PATH = "/Cesium" CESIUM_GEOREFERENCE_PRIM_PATH = "/CesiumGeoreference" @@ -251,8 +251,7 @@ def _create_tileset_google() -> str: tileset_path = omni.usd.get_stage_next_free_path(stage, "/Google_3D_Tiles", False) tileset = CesiumTileset.Define(stage, tileset_path) - tileset.GetUrlAttr().Set(GOOGLE_3D_TILES_URL) - tileset.GetSourceTypeAttr().Set(CesiumTokens.url) + tileset.GetIonAssetIdAttr().Set(GOOGLE_3D_TILES_ION_ID) return tileset_path diff --git a/docs/release-guide/README.md b/docs/release-guide/README.md index 3502d4dfe..b19164dea 100644 --- a/docs/release-guide/README.md +++ b/docs/release-guide/README.md @@ -3,13 +3,14 @@ This is the process we follow when releasing a new version of Cesium for Omniverse on GitHub. 1. [Release a new version of Cesium for Omniverse Samples](#releasing-a-new-version-of-cesium-for-omniverse-samples). +2. Update [`extension.py`](../../apps/exts/cesium.performance.app/cesium/performance/app/extension.py) in the Performance App with the latest public `ION_ACCESS_TOKEN`. 3. Make sure the latest commit in `main` is passing CI. 4. Download the latest build from S3. In the AWS management console (InternalServices AWS account), go to the bucket [`cesium-builds/cesium-omniverse/main`](https://s3.console.aws.amazon.com/s3/buckets/cesium-builds?region=us-east-1&prefix=cesium-omniverse/main/&showversions=false), find the appropriate date and commit hash to download the CentOS and Windows zip files (e.g. `CesiumForOmniverse-Linux-xxxxxxx.zip` and `CesiumForOmniverse-Windows-xxxxxxx.zip`) 5. Verify that the Linux package loads in USD Composer (see instructions below). 6. Verify that the Windows package loads in USD Composer (see instructions below). 7. Update the project `VERSION` in [CMakeLists.txt](../../CMakeLists.txt). 8. Update the extension `version` in [extension.toml](../../exts/cesium.omniverse/config/extension.toml). This should be the same version as above. -9. Update [`CHANGES.md`](CHANGES.md). +9. Update [`CHANGES.md`](../../CHANGES.md). 10. Update `ION_ACCESS_TOKEN` and `GOOGLE_3D_TILES_URL` in `cesium.performance.app` using the newly generated keys. 11. Create a branch, e.g. `git checkout -b release-0.0.0`. 12. Commit the changes, e.g. `git commit -am "0.0.0 release"`. @@ -30,21 +31,17 @@ This is the process we follow when releasing a new version of Cesium for Omniver * The name of the token should match "Cesium for Omniverse Samples vX.X.X - Delete on April 1st, 2023" where the version is the same as the Cesium for Omniverse release and the expiry date is two months later than present. * The scope of the token should be "assets:read" for all assets. 2. Replace the `cesium:projectDefaultIonAccessToken` property in each `.usda` file with the new access token. -3. Create a new Google Maps API Key in the [Cesium account](https://console.cloud.google.com/google/maps-apis/credentials?project=threed-tiles-api-testing). - * The name of the key should match "Cesium for Omniverse Samples vX.X.X - Delete on April 1st, 2023" where the version is the same as the Cesium for Omniverse release and the expiry date is two months later than present. - * The key should be restricted to the Map Tiles API. -4. For each `.usda` file using the Google 3D Tiles API, replace the key in the `cesium:url` property with the new key. -5. Verify that all the USD files load in Cesium for Omniverse. -6. Update `CHANGES.md`. -7. Commit the changes, e.g. `git commit -am "0.0.0 release"`. -8. Push the commit, e.g. `git push origin main`. -9. Tag the release, e.g. `git tag -a v0.0.0 -m "0.0.0 release"`. -10. Push the tag, e.g. `git push origin v0.0.0`. -11. Download the repo as a zip file. -12. Extract the zip file. -13. Rename the extracted folder, e.g. rename `cesium-omniverse-samples-main` to `CesiumOmniverseSamples-v0.0.0`. -14. Create a zip file of the folder -15. Create a new release on GitHub: https://github.com/CesiumGS/cesium-omniverse-samples/releases/new. +3. Verify that all the USD files load in Cesium for Omniverse. +4. Update `CHANGES.md`. +5. Commit the changes, e.g. `git commit -am "0.0.0 release"`. +6. Push the commit, e.g. `git push origin main`. +7. Tag the release, e.g. `git tag -a v0.0.0 -m "0.0.0 release"`. +8. Push the tag, e.g. `git push origin v0.0.0`. +9. Download the repo as a zip file. +10. Extract the zip file. +11. Rename the extracted folder, e.g. rename `cesium-omniverse-samples-main` to `CesiumOmniverseSamples-v0.0.0`. +12. Create a zip file of the folder +13. Create a new release on GitHub: https://github.com/CesiumGS/cesium-omniverse-samples/releases/new. * Choose the new tag. * Copy the changelog into the description. Follow the format used in previous releases. * Upload the zip file. diff --git a/extern/cesium-native b/extern/cesium-native index da901d260..08f26ad4d 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit da901d260eae9b0a802a396d11185a9fc24a711e +Subproject commit 08f26ad4d8f88197a8c1d37dea2ffb76f5dcfd85 diff --git a/exts/cesium.omniverse/cesium/omniverse/ui/quick_add_widget.py b/exts/cesium.omniverse/cesium/omniverse/ui/quick_add_widget.py index 3d0961cb5..41d6220fd 100644 --- a/exts/cesium.omniverse/cesium/omniverse/ui/quick_add_widget.py +++ b/exts/cesium.omniverse/cesium/omniverse/ui/quick_add_widget.py @@ -49,6 +49,9 @@ def _add_blank_button_clicked(): add_blank_asset_event = carb.events.type_from_string("cesium.omniverse.ADD_BLANK_ASSET") app.get_app().get_message_bus_event_stream().push(add_blank_asset_event, payload=asset_to_add.to_dict()) + def _photorealistic_tiles_button_clicked(self): + self._add_ion_assets(AssetToAdd("Google Photorealistic 3D Tiles", 823)) + def _cwt_bing_maps_button_clicked(self): self._add_ion_assets(AssetToAdd("Cesium World Terrain", 1, "Bing Maps Aerial imagery", 2)) @@ -92,6 +95,12 @@ def _build_ui(self): style=CesiumOmniverseUiStyles.quick_add_section_label, height=LABEL_HEIGHT, ) + ui.Button( + "Google Photorealistic 3D Tiles", + style=CesiumOmniverseUiStyles.quick_add_button, + height=BUTTON_HEIGHT, + clicked_fn=self._photorealistic_tiles_button_clicked, + ) ui.Button( "Cesium World Terrain + Bing Maps Aerial imagery", style=CesiumOmniverseUiStyles.quick_add_button, diff --git a/src/core/src/CesiumIonSession.cpp b/src/core/src/CesiumIonSession.cpp index 1bb9b2bbc..dee8b2fb3 100644 --- a/src/core/src/CesiumIonSession.cpp +++ b/src/core/src/CesiumIonSession.cpp @@ -46,13 +46,15 @@ void CesiumIonSession::connect() { this->_asyncSystem, this->_pAssetAccessor, "Cesium for Omniverse", - 413, + 11, "/cesium-for-omniverse/oauth2/callback", {"assets:list", "assets:read", "profile:read", "tokens:read", "tokens:write", "geocode"}, [this](const std::string& url) { // NOTE: We open the browser in the Python code. Check in the sign in widget's on_update_frame function. this->_authorizeUrl = url; - }) + }, + "https://api.ion-development.cesium.com/", + "https://ion-development.cesium.com/oauth") .thenInMainThread([this](CesiumIonClient::Connection&& connection) { this->_isConnecting = false; this->_connection = std::move(connection); @@ -82,7 +84,8 @@ void CesiumIonSession::resume() { this->_isResuming = true; - this->_connection = Connection(this->_asyncSystem, this->_pAssetAccessor, userAccessToken); + this->_connection = Connection( + this->_asyncSystem, this->_pAssetAccessor, userAccessToken, "https://api.ion-development.cesium.com/"); // Verify that the connection actually works. this->_connection.value() diff --git a/src/core/src/OmniTileset.cpp b/src/core/src/OmniTileset.cpp index 83a0382ab..8f4315b49 100644 --- a/src/core/src/OmniTileset.cpp +++ b/src/core/src/OmniTileset.cpp @@ -337,10 +337,11 @@ void OmniTileset::reload() { _tileset = std::make_unique(externals, url, options); } else if (!ionAccessToken.has_value()) { // This happens when adding a blank tileset. - _tileset = std::make_unique(externals, 0, "", options); + _tileset = std::make_unique( + externals, 0, "", options, "https://api.ion-development.cesium.com/"); } else { _tileset = std::make_unique( - externals, ionAssetId, ionAccessToken.value().token, options); + externals, ionAssetId, ionAccessToken.value().token, options, "https://api.ion-development.cesium.com/"); } // Add imagery @@ -387,7 +388,11 @@ void OmniTileset::addImageryIon(const pxr::SdfPath& imageryPath) { // The name passed to IonRasterOverlay needs to uniquely identify this imagery otherwise texture caching may break const auto uniqueName = fmt::format("imagery_ion_{}", imageryIonAssetId); const auto ionRasterOverlay = new Cesium3DTilesSelection::IonRasterOverlay( - uniqueName, imageryIonAssetId, imageryIonAccessToken.value().token, options); + uniqueName, + imageryIonAssetId, + imageryIonAccessToken.value().token, + options, + "https://api.ion-development.cesium.com/"); _tileset->getOverlays().add(ionRasterOverlay); }