Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for Google Photorealistic 3D Tiles #11275

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<meta
name="description"
content="Use Viewer to start building new applications or easily embed Cesium into existing applications."
/>
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" />
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="module" src="../load-cesium-es6.js"></script>
</head>
<body
class="sandcastle-loading"
data-sandcastle-bucket="bucket-requirejs.html"
>
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
const viewer = new Cesium.Viewer("cesiumContainer", {
timeline: false,
animation: false,
sceneModePicker: false,
baseLayerPicker: false,
});

// The globe does not need to be displayed,
// since the Photorealistic 3D Tiles include terrain
viewer.scene.globe.show = false;

// Add Photorealistic 3D Tiles
try {
const googleTileset = await Cesium.createGooglePhotorealistic3DTileset();
viewer.scene.primitives.add(googleTileset);
} catch (error) {
console.log(`Error loading Photorealistic 3D Tiles tileset.
${error}`);
}

// Add highlight of target lot for development
const targetHighlight = new Cesium.Entity({
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray(
[
[-105.0077102972673, 39.75198671798765],
[-105.0095858062031, 39.75049417970743],
[-105.00969000114443, 39.75035082687128],
[-105.00972838875393, 39.75013579705808],
[-105.00971742086537, 39.74997136204101],
[-105.00962967775735, 39.749768979944236],
[-105.00932806082336, 39.74928832007956],
[-105.00887837739427, 39.749444324087904],
[-105.00854934073887, 39.749663572365904],
[-105.00822578802776, 39.749967145754084],
[-105.00715641889735, 39.751312128419926],
[-105.00715641889735, 39.75135429046085],
[-105.0077102972673, 39.75198671798765],
].flat(2)
),
material: Cesium.Color.YELLOW.withAlpha(0.6),
classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
},
});
viewer.entities.add(targetHighlight);

// Add tileset of proposed new building
let buildingTileset;
try {
buildingTileset = await Cesium.Cesium3DTileset.fromIonAssetId(
1670818
);
viewer.scene.primitives.add(buildingTileset);
} catch (error) {
console.log(`Error loading building tileset.
${error}`);
}

// Zoom to the new building location
const cameraOffset = new Cesium.HeadingPitchRange(
Cesium.Math.toRadians(95.0),
Cesium.Math.toRadians(-18.0),
600.0
);
viewer.zoomTo(buildingTileset, cameraOffset);

// Enable toggling of new building visibility
Sandcastle.addToggleButton("Show proposed building", true, function (
checked
) {
buildingTileset.show = checked;
});

// Enable toggling of target location highlight
Sandcastle.addToggleButton("Highlight target location", true, function (
checked
) {
if (checked) {
viewer.entities.add(targetHighlight);
} else {
viewer.entities.remove(targetHighlight);
}
}); //Sandcastle_End
Sandcastle.finishedLoading();
};
if (typeof Cesium !== "undefined") {
window.startupCalled = true;
window.startup(Cesium).catch((error) => {
"use strict";
console.error(error);
});
}
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions Apps/Sandcastle/gallery/Google Photorealistic 3D Tiles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<meta
name="description"
content="Use Viewer to start building new applications or easily embed Cesium into existing applications."
/>
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" />
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="module" src="../load-cesium-es6.js"></script>
</head>
<body
class="sandcastle-loading"
data-sandcastle-bucket="bucket-requirejs.html"
>
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
const viewer = new Cesium.Viewer("cesiumContainer", {
timeline: false,
animation: false,
sceneModePicker: false,
baseLayerPicker: false,
});

// The globe does not need to be displayed,
// since the Photorealistic 3D Tiles include terrain
viewer.scene.globe.show = false;

// Add Photorealistic 3D Tiles
try {
const tileset = await Cesium.createGooglePhotorealistic3DTileset();
viewer.scene.primitives.add(tileset);
} catch (error) {
console.log(`Error loading Photorealistic 3D Tiles tileset.
${error}`);
}

// Point the camera at the Googleplex
viewer.scene.camera.setView({
destination: new Cesium.Cartesian3(
-2693797.551060477,
-4297135.517094725,
3854700.7470414364
),
orientation: new Cesium.HeadingPitchRoll(
4.6550106925119925,
-0.2863894863138836,
1.3561760425773173e-7
),
}); //Sandcastle_End
Sandcastle.finishedLoading();
};
if (typeof Cesium !== "undefined") {
window.startupCalled = true;
window.startup(Cesium).catch((error) => {
"use strict";
console.error(error);
});
}
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
51 changes: 26 additions & 25 deletions Documentation/Contributors/ReleaseGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,44 @@ 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
- Include date, list of highlights and link to CHANGES.md (https://github.com/CesiumGS/cesium/blob/1.xx/CHANGES.md) as the description
- 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 <WORKSPACE>` 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 <WORKSPACE>` 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 <tag-name>`. 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 <tag-name>`. 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)
56 changes: 56 additions & 0 deletions packages/engine/Source/Core/GoogleMaps.js
Original file line number Diff line number Diff line change
@@ -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.
* <br/>
* 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 =
'<b> \
This application is using CesiumJS\'s default Google Maps API key. Please assign <i>Cesium.GoogleMaps.defaultApiKey</i> \
with <a href="https://developers.google.com/maps/documentation/embed/get-api-key">your API key for the Google Maps Platform</a>.</b>';

defaultKeyCredit = new Credit(defaultKeyMessage, true);
defaultKeyCredit._isDefaultToken = true;
}

return defaultKeyCredit;
};
export default GoogleMaps;
1 change: 1 addition & 0 deletions packages/engine/Source/Core/Ion.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Ion.getDefaultTokenCredit = function (providedKey) {
You can sign up for a free ion account at <a href="https://cesium.com">https://cesium.com</a>.</b>';

defaultTokenCredit = new Credit(defaultTokenMessage, true);
defaultTokenCredit._isDefaultToken = true;
}

return defaultTokenCredit;
Expand Down
1 change: 1 addition & 0 deletions packages/engine/Source/Core/RequestScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down
13 changes: 13 additions & 0 deletions packages/engine/Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ function Resource(options) {
} else {
this._url = options.url;
}

this._credits = options.credits;
}

/**
Expand Down Expand Up @@ -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;
},
},
});

/**
Expand Down Expand Up @@ -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,
});
}

Expand Down
Loading