diff --git a/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.html b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.html new file mode 100644 index 000000000000..5cd69c623b28 --- /dev/null +++ b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.html @@ -0,0 +1,127 @@ + + + + + + + + + Cesium Demo + + + + + +
+

Loading...

+
+ + + diff --git a/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.jpg b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.jpg new file mode 100644 index 000000000000..c8e5a1de9d43 Binary files /dev/null and b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles with Building Insert.jpg differ diff --git a/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.html b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.html new file mode 100644 index 000000000000..df403ed08f70 --- /dev/null +++ b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.html @@ -0,0 +1,77 @@ + + + + + + + + + Cesium Demo + + + + + +
+

Loading...

+
+ + + diff --git a/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.jpg b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.jpg new file mode 100644 index 000000000000..f6887c2cc98e Binary files /dev/null and b/Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.jpg differ diff --git a/CHANGES.md b/CHANGES.md index 3510b99f7e61..1fac17600355 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,14 @@ # Change Log -### 1.106 - 2023-06-01 +### 1.105.1 - 2023-05-10 #### @cesium/engine +##### Additions :tada: + +- Added `createGooglePhotorealistic3DTileset` to create a 3D tileset streaming Google Photorealistic 3D Tiles. +- Added `GoogleMaps` for managing credentials when loading data from the Google Map Tiles API. + ##### Fixes :wrench: - Improved camera controls when globe is off. [#7171](https://github.com/CesiumGS/cesium/issues/7171) diff --git a/Documentation/Contributors/ReleaseGuide/README.md b/Documentation/Contributors/ReleaseGuide/README.md index 971e2b9f15e4..d7ad90411e8f 100644 --- a/Documentation/Contributors/ReleaseGuide/README.md +++ b/Documentation/Contributors/ReleaseGuide/README.md @@ -22,30 +22,31 @@ There is no release manager; instead, our community shares the responsibility. A 4. Pull down the latest `main` branch and run `npm install`. 5. Update the Cesium ion demo token in `Ion.js` with a new token from the CesiumJS ion team account with read and geocode permissions. These tokens are named like this: `1.85 Release - Delete on November 1st, 2021`. Delete the token from 2 releases ago. 6. Update the ArcGIS Developer API key in `ArcGisMapService.js` with a new API key from the CesiumJS ArcGIS Developer account. These API keys are named like this: `1.85 Release - Delete on November 1st, 2021`. Delete the API key from 2 releases ago. -7. Proofread [`CHANGES.md`](../../../CHANGES.md) with the date of the release. Adjust the order of changes so that prominent/popular changes come first. Ensure each change is in the section for the relevant workspace. -8. Based on `CHANGES.md`, update each workspace version following the rules of [semantic versioning](https://semver.org/), e.g., +7. Update the Google Maps Platform API key in `GoogleMaps.js` with a new API key from Cesium's Google Cloud Console. These API keys are named like this: `CesiumJS 1.85 Release - Delete on November 1st, 2021`. Ensure the new key is restricted to the Map Tiles API. Delete the API key from 2 releases ago. +8. Proofread [`CHANGES.md`](../../../CHANGES.md) with the date of the release. Adjust the order of changes so that prominent/popular changes come first. Ensure each change is in the section for the relevant workspace. +9. Based on `CHANGES.md`, update each workspace version following the rules of [semantic versioning](https://semver.org/), e.g., - `npm version minor -w @cesium/engine --no-git-tag-version` - If there are no changes, skip updating the workspace version. -9. Update the version in `package.json` to match, e.g. `1.14.0` -> `1.15.0`. -10. Commit these changes. -11. Make sure the repository is clean `git clean -d -x -f`. **This will delete all files not already in the repository.** -12. Run `npm install`. -13. Make sure `ThirdParty.json` is up to date by running `npm run build-third-party`. If there are any changes, verify and commit them. -14. Create the release zip `npm run make-zip`. -15. Run tests against the release `npm run test -- --failTaskOnError --release`. Test **in all browsers** with the `--browsers` flag (i.e. `--browsers Firefox,Chrome`). Alternatively, test with the browser Spec Runner by starting a local server (`npm start`) and browsing to http://localhost:8080/Specs/SpecRunner.html?built=true&release=true. -16. Unpack the release zip to the directory of your choice and start the server by running `npm install` and then `npm start` -17. Browse to http://localhost:8080 and confirm that the home page loads as expected and all links work. -18. Verify that the [documentation](http://localhost:8080/Build/Documentation/index.html) built correctly -19. Make sure [Hello World](http://localhost:8080/Apps/HelloWorld.html) loads. -20. Make sure [Cesium Viewer](http://localhost:8080/Apps/CesiumViewer/index.html) loads. -21. Run [Sandcastle](http://localhost:8080/Apps/Sandcastle/index.html) on the browser of your choice (or multiple browsers if you are up for it). Switch to the `All` tab and run through every demo to make sure they all work. Actually play with each of the buttons and sliders on each demo to ensure everything works as expected. -22. If any of the above steps fail, post a message to the `#cesiumjs` channel in Slack to figure out what needs to be fixed before we can release. **Do NOT proceed to the next step until issues are resolved.** -23. Push your commits to main +10. Update the version in `package.json` to match, e.g. `1.14.0` -> `1.15.0`. +11. Commit these changes. +12. Make sure the repository is clean `git clean -d -x -f`. **This will delete all files not already in the repository.** +13. Run `npm install`. +14. Make sure `ThirdParty.json` is up to date by running `npm run build-third-party`. If there are any changes, verify and commit them. +15. Create the release zip `npm run make-zip`. +16. Run tests against the release `npm run test -- --failTaskOnError --release`. Test **in all browsers** with the `--browsers` flag (i.e. `--browsers Firefox,Chrome`). Alternatively, test with the browser Spec Runner by starting a local server (`npm start`) and browsing to http://localhost:8080/Specs/SpecRunner.html?built=true&release=true. +17. Unpack the release zip to the directory of your choice and start the server by running `npm install` and then `npm start` +18. Browse to http://localhost:8080 and confirm that the home page loads as expected and all links work. +19. Verify that the [documentation](http://localhost:8080/Build/Documentation/index.html) built correctly +20. Make sure [Hello World](http://localhost:8080/Apps/HelloWorld.html) loads. +21. Make sure [Cesium Viewer](http://localhost:8080/Apps/CesiumViewer/index.html) loads. +22. Run [Sandcastle](http://localhost:8080/Apps/Sandcastle/index.html) on the browser of your choice (or multiple browsers if you are up for it). Switch to the `All` tab and run through every demo to make sure they all work. Actually play with each of the buttons and sliders on each demo to ensure everything works as expected. +23. If any of the above steps fail, post a message to the `#cesiumjs` channel in Slack to figure out what needs to be fixed before we can release. **Do NOT proceed to the next step until issues are resolved.** +24. Push your commits to main - `git push` -24. Create and push a [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging), e.g., +25. Create and push a [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging), e.g., - `git tag -a 1.1 -m "1.1 release"` - `git push origin 1.1` (this assumes origin is the primary cesium repository, do not use `git push --tags` as it pushes all tags from all remotes you have on your system.) -25. Publish the release zip file to GitHub +26. Publish the release zip file to GitHub - https://github.com/CesiumGS/cesium/releases/new - Select the tag you use pushed - Enter 'CesiumJS 1.xx' for the title @@ -53,12 +54,12 @@ There is no release manager; instead, our community shares the responsibility. A - Look at a [previous release](https://github.com/CesiumGS/cesium/releases/tag/1.79) for an example. Don't use emoji, headings, or other formatting - Attach the `Cesium-1.xx` release zip file - Publish the release -26. Publish to npm by running `npm publish` in the repository root (not the unzipped file directory) (the first time you do this, you will need to authorize the machine using `npm adduser`) -27. Use `npm publish -w ` in the repository root (not the unzipped file directory) to publish the workspace. Repeat this step for each **updated** workspace, in the following order: +27. Publish to npm by running `npm publish` in the repository root (not the unzipped file directory) (the first time you do this, you will need to authorize the machine using `npm adduser`) +28. Use `npm publish -w ` in the repository root (not the unzipped file directory) to publish the workspace. Repeat this step for each **updated** workspace, in the following order: - `npm publish -w @cesium/engine` - `npm publish -w @cesium/widgets` -28. Check out the `cesium.com` branch. Merge the new release tag into the `cesium.com` branch `git merge origin `. CI will deploy the hosted release, Sandcastle, and the updated doc when you push the branch up. -29. After the `cesium.com` branch is live on cesium.com, comment in the `#comms-chat` slack channel to notify comms that the release is done so they can add these highlights and publish the monthly blog post +29. Check out the `cesium.com` branch. Merge the new release tag into the `cesium.com` branch `git merge origin `. CI will deploy the hosted release, Sandcastle, and the updated doc when you push the branch up. +30. After the `cesium.com` branch is live on cesium.com, comment in the `#comms-chat` slack channel to notify comms that the release is done so they can add these highlights and publish the monthly blog post - Note, it may take a little while for the new version of CesiumJS to be live on cesium.com (~30 minutes after the branch builds). You can check the version of Cesium in [sandcastle](https://sandcastle.cesium.com/) by looking at the tab above the cesium pane. -30. Update the version of CesiumJS used in the Cesium Workshop: https://github.com/CesiumGS/cesium-workshop/blob/main/index.html#L13-L14 -31. Continue to the [Cesium Analytics release](https://github.com/CesiumGS/cesium-analytics/blob/main/Documentation/Contributors/AnalyticsReleaseGuide/README.md) +31. Update the version of CesiumJS used in the Cesium Workshop: https://github.com/CesiumGS/cesium-workshop/blob/main/index.html#L13-L14 +32. Continue to the [Cesium Analytics release](https://github.com/CesiumGS/cesium-analytics/blob/main/Documentation/Contributors/AnalyticsReleaseGuide/README.md) diff --git a/packages/engine/Source/Core/GoogleMaps.js b/packages/engine/Source/Core/GoogleMaps.js new file mode 100644 index 000000000000..e5ae75f2068d --- /dev/null +++ b/packages/engine/Source/Core/GoogleMaps.js @@ -0,0 +1,56 @@ +import Credit from "./Credit.js"; +import defined from "./defined.js"; +import Resource from "./Resource.js"; + +let defaultKeyCredit; +const defaultKey = "AIzaSyBESBYnp1EcqtlAcjMTJ65GjUsJtaCWVXA"; + +/** + * Default settings for accessing the Google Maps API. + *
+ * An API key is only required if you are using any Google Maps APIs, such as {@link createGooglePhotorealistic3DTileset}. + * A default key is provided for evaluation purposes only. + * Follow instructions for managing API keys for the Google Maps Platform at {@link https://developers.google.com/maps/documentation/embed/get-api-key} + * + * @see createGooglePhotorealistic3DTileset + * @see https://developers.google.com/maps/documentation/embed/get-api-key + * + * @namespace GoogleMaps + */ +const GoogleMaps = {}; + +/** + * Gets or sets the default Google Maps API key. + * + * @type {string} + */ +GoogleMaps.defaultApiKey = defaultKey; + +/** + * Gets or sets the default Google Map Tiles API endpoint. + * + * @type {string|Resource} + * @default https://tile.googleapis.com/v1/ + */ +GoogleMaps.mapTilesApiEndpoint = new Resource({ + url: "https://tile.googleapis.com/v1/", +}); + +GoogleMaps.getDefaultApiKeyCredit = function (providedKey) { + if (providedKey !== defaultKey) { + return undefined; + } + + if (!defined(defaultKeyCredit)) { + const defaultKeyMessage = + ' \ + This application is using CesiumJS\'s default Google Maps API key. Please assign Cesium.GoogleMaps.defaultApiKey \ + with your API key for the Google Maps Platform.'; + + defaultKeyCredit = new Credit(defaultKeyMessage, true); + defaultKeyCredit._isDefaultToken = true; + } + + return defaultKeyCredit; +}; +export default GoogleMaps; diff --git a/packages/engine/Source/Core/Ion.js b/packages/engine/Source/Core/Ion.js index 315362002513..db3e3ff4b967 100644 --- a/packages/engine/Source/Core/Ion.js +++ b/packages/engine/Source/Core/Ion.js @@ -49,6 +49,7 @@ Ion.getDefaultTokenCredit = function (providedKey) { You can sign up for a free ion account at https://cesium.com.'; defaultTokenCredit = new Credit(defaultTokenMessage, true); + defaultTokenCredit._isDefaultToken = true; } return defaultTokenCredit; diff --git a/packages/engine/Source/Core/RequestScheduler.js b/packages/engine/Source/Core/RequestScheduler.js index 1b185a3a7e38..46fa4e3d1305 100644 --- a/packages/engine/Source/Core/RequestScheduler.js +++ b/packages/engine/Source/Core/RequestScheduler.js @@ -82,6 +82,7 @@ RequestScheduler.requestsByServer = { "api.cesium.com:443": 18, "assets.ion.cesium.com:443": 18, "ibasemaps-api.arcgis.com:443": 18, + "tile.googleapis.com:443": 18, }; /** diff --git a/packages/engine/Source/Core/Resource.js b/packages/engine/Source/Core/Resource.js index cf4c0dfce01a..276ed0a4c49b 100644 --- a/packages/engine/Source/Core/Resource.js +++ b/packages/engine/Source/Core/Resource.js @@ -148,6 +148,8 @@ function Resource(options) { } else { this._url = options.url; } + + this._credits = options.credits; } /** @@ -372,6 +374,16 @@ Object.defineProperties(Resource.prototype, { return Object.keys(this.headers).length > 0; }, }, + + /** + * Gets the credits required for attribution of an asset. + * @private + */ + credits: { + get: function () { + return this._credits; + }, + }, }); /** @@ -732,6 +744,7 @@ Resource.prototype.clone = function (result) { retryAttempts: this.retryAttempts, request: this.request.clone(), parseUrl: false, + credits: defined(this.credits) ? this.credits.slice() : undefined, }); } diff --git a/packages/engine/Source/Scene/ArcGisMapService.js b/packages/engine/Source/Scene/ArcGisMapService.js index 4656f58cb241..8beb63a0a6c7 100644 --- a/packages/engine/Source/Scene/ArcGisMapService.js +++ b/packages/engine/Source/Scene/ArcGisMapService.js @@ -76,6 +76,7 @@ ArcGisMapService.getDefaultTokenCredit = function (providedKey) { You can sign up for a free ArcGIS Developer account at https://developers.arcgis.com/.'; defaultTokenCredit = new Credit(defaultTokenMessage, true); + defaultTokenCredit._isDefaultToken = true; } return defaultTokenCredit; diff --git a/packages/engine/Source/Scene/Cesium3DTileset.js b/packages/engine/Source/Scene/Cesium3DTileset.js index ac8486686233..7d7466bf4b6f 100644 --- a/packages/engine/Source/Scene/Cesium3DTileset.js +++ b/packages/engine/Source/Scene/Cesium3DTileset.js @@ -3211,7 +3211,8 @@ function update(tileset, frameState, passStatistics, passOptions) { if (defined(credits) && statistics.selected !== 0) { for (let i = 0; i < credits.length; ++i) { const credit = credits[i]; - credit.showOnScreen = tileset._showCreditsOnScreen; + credit.showOnScreen = + tileset._showCreditsOnScreen || credit._isDefaultToken; frameState.creditDisplay.addCreditToNextFrame(credit); } } diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index e2755e6c461f..3b64dd296bc2 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -2384,19 +2384,21 @@ function updateShowCreditsOnScreen(model) { const showOnScreen = model._showCreditsOnScreen; if (defined(model._credit)) { - model._credit.showOnScreen = showOnScreen; + model._credit.showOnScreen = showOnScreen || model._credit._isDefaultToken; } const resourceCredits = model._resourceCredits; const resourceCreditsLength = resourceCredits.length; for (let i = 0; i < resourceCreditsLength; i++) { - resourceCredits[i].showOnScreen = showOnScreen; + resourceCredits[i].showOnScreen = + showOnScreen || resourceCredits[i]._isDefaultToken; } const gltfCredits = model._gltfCredits; const gltfCreditsLength = gltfCredits.length; for (let i = 0; i < gltfCreditsLength; i++) { - gltfCredits[i].showOnScreen = showOnScreen; + gltfCredits[i].showOnScreen = + showOnScreen || gltfCredits[i]._isDefaultToken; } } diff --git a/packages/engine/Source/Scene/createGooglePhotorealistic3DTileset.js b/packages/engine/Source/Scene/createGooglePhotorealistic3DTileset.js new file mode 100644 index 000000000000..d644f3988eff --- /dev/null +++ b/packages/engine/Source/Scene/createGooglePhotorealistic3DTileset.js @@ -0,0 +1,53 @@ +import Cesium3DTileset from "./Cesium3DTileset.js"; +import defaultValue from "../Core/defaultValue.js"; +import defined from "../Core/defined.js"; +import GoogleMaps from "../Core/GoogleMaps.js"; +import Resource from "../Core/Resource.js"; + +/** + * Creates a {@link Cesium3DTileset} instance for the Google Photorealistic 3D Tiles tileset. + * + * @function + * + * @param {string} [key=GoogleMaps.defaultApiKey] Your API key to access Google Photorealistic 3D Tiles. See {@link https://developers.google.com/maps/documentation/javascript/get-api-key} for instructions on how to create your own key. + * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options. + * @returns {Promise} + * + * @see GoogleMaps + * + * @example + * Cesium.GoogleMaps.defaultApiKey = "your-api-key"; + * + * const viewer = new Cesium.Viewer("cesiumContainer"); + * + * try { + * const tileset = await Cesium.createGooglePhotorealistic3DTileset(); + * viewer.scene.primitives.add(tileset)); + * } catch (error) { + * console.log(`Error creating tileset: ${error}`); + * } + */ +async function createGooglePhotorealistic3DTileset(key, options) { + key = defaultValue(key, GoogleMaps.defaultApiKey); + + let credits; + const credit = GoogleMaps.getDefaultApiKeyCredit(key); + if (defined(credit)) { + credits = [credit]; + } + + options = defaultValue(options, {}); + options.showCreditsOnScreen = true; + + const resource = new Resource({ + url: `${GoogleMaps.mapTilesApiEndpoint}3dtiles/root.json`, + queryParameters: { + key: key, + }, + credits: credits, + }); + + return Cesium3DTileset.fromUrl(resource, options); +} + +export default createGooglePhotorealistic3DTileset;