Skip to content

Commit cbedb6c

Browse files
authored
Merge pull request #11275 from CesiumGS/google-api
Updates for Google Photorealistic 3D Tiles
2 parents 3206a78 + 8e3861e commit cbedb6c

14 files changed

+368
-30
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
9+
/>
10+
<meta
11+
name="description"
12+
content="Use Viewer to start building new applications or easily embed Cesium into existing applications."
13+
/>
14+
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" />
15+
<title>Cesium Demo</title>
16+
<script type="text/javascript" src="../Sandcastle-header.js"></script>
17+
<script type="module" src="../load-cesium-es6.js"></script>
18+
</head>
19+
<body
20+
class="sandcastle-loading"
21+
data-sandcastle-bucket="bucket-requirejs.html"
22+
>
23+
<style>
24+
@import url(../templates/bucket.css);
25+
</style>
26+
<div id="cesiumContainer" class="fullSize"></div>
27+
<div id="loadingOverlay"><h1>Loading...</h1></div>
28+
<div id="toolbar"></div>
29+
<script id="cesium_sandcastle_script">
30+
window.startup = async function (Cesium) {
31+
"use strict";
32+
//Sandcastle_Begin
33+
const viewer = new Cesium.Viewer("cesiumContainer", {
34+
timeline: false,
35+
animation: false,
36+
sceneModePicker: false,
37+
baseLayerPicker: false,
38+
});
39+
40+
// The globe does not need to be displayed,
41+
// since the Photorealistic 3D Tiles include terrain
42+
viewer.scene.globe.show = false;
43+
44+
// Add Photorealistic 3D Tiles
45+
try {
46+
const googleTileset = await Cesium.createGooglePhotorealistic3DTileset();
47+
viewer.scene.primitives.add(googleTileset);
48+
} catch (error) {
49+
console.log(`Error loading Photorealistic 3D Tiles tileset.
50+
${error}`);
51+
}
52+
53+
// Add highlight of target lot for development
54+
const targetHighlight = new Cesium.Entity({
55+
polygon: {
56+
hierarchy: Cesium.Cartesian3.fromDegreesArray(
57+
[
58+
[-105.0077102972673, 39.75198671798765],
59+
[-105.0095858062031, 39.75049417970743],
60+
[-105.00969000114443, 39.75035082687128],
61+
[-105.00972838875393, 39.75013579705808],
62+
[-105.00971742086537, 39.74997136204101],
63+
[-105.00962967775735, 39.749768979944236],
64+
[-105.00932806082336, 39.74928832007956],
65+
[-105.00887837739427, 39.749444324087904],
66+
[-105.00854934073887, 39.749663572365904],
67+
[-105.00822578802776, 39.749967145754084],
68+
[-105.00715641889735, 39.751312128419926],
69+
[-105.00715641889735, 39.75135429046085],
70+
[-105.0077102972673, 39.75198671798765],
71+
].flat(2)
72+
),
73+
material: Cesium.Color.YELLOW.withAlpha(0.6),
74+
classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
75+
},
76+
});
77+
viewer.entities.add(targetHighlight);
78+
79+
// Add tileset of proposed new building
80+
let buildingTileset;
81+
try {
82+
buildingTileset = await Cesium.Cesium3DTileset.fromIonAssetId(
83+
1670818
84+
);
85+
viewer.scene.primitives.add(buildingTileset);
86+
} catch (error) {
87+
console.log(`Error loading building tileset.
88+
${error}`);
89+
}
90+
91+
// Zoom to the new building location
92+
const cameraOffset = new Cesium.HeadingPitchRange(
93+
Cesium.Math.toRadians(95.0),
94+
Cesium.Math.toRadians(-18.0),
95+
600.0
96+
);
97+
viewer.zoomTo(buildingTileset, cameraOffset);
98+
99+
// Enable toggling of new building visibility
100+
Sandcastle.addToggleButton("Show proposed building", true, function (
101+
checked
102+
) {
103+
buildingTileset.show = checked;
104+
});
105+
106+
// Enable toggling of target location highlight
107+
Sandcastle.addToggleButton("Highlight target location", true, function (
108+
checked
109+
) {
110+
if (checked) {
111+
viewer.entities.add(targetHighlight);
112+
} else {
113+
viewer.entities.remove(targetHighlight);
114+
}
115+
}); //Sandcastle_End
116+
Sandcastle.finishedLoading();
117+
};
118+
if (typeof Cesium !== "undefined") {
119+
window.startupCalled = true;
120+
window.startup(Cesium).catch((error) => {
121+
"use strict";
122+
console.error(error);
123+
});
124+
}
125+
</script>
126+
</body>
127+
</html>
79.7 KB
Loading
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
9+
/>
10+
<meta
11+
name="description"
12+
content="Use Viewer to start building new applications or easily embed Cesium into existing applications."
13+
/>
14+
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases" />
15+
<title>Cesium Demo</title>
16+
<script type="text/javascript" src="../Sandcastle-header.js"></script>
17+
<script type="module" src="../load-cesium-es6.js"></script>
18+
</head>
19+
<body
20+
class="sandcastle-loading"
21+
data-sandcastle-bucket="bucket-requirejs.html"
22+
>
23+
<style>
24+
@import url(../templates/bucket.css);
25+
</style>
26+
<div id="cesiumContainer" class="fullSize"></div>
27+
<div id="loadingOverlay"><h1>Loading...</h1></div>
28+
<div id="toolbar"></div>
29+
<script id="cesium_sandcastle_script">
30+
window.startup = async function (Cesium) {
31+
"use strict";
32+
//Sandcastle_Begin
33+
const viewer = new Cesium.Viewer("cesiumContainer", {
34+
timeline: false,
35+
animation: false,
36+
sceneModePicker: false,
37+
baseLayerPicker: false,
38+
});
39+
40+
// The globe does not need to be displayed,
41+
// since the Photorealistic 3D Tiles include terrain
42+
viewer.scene.globe.show = false;
43+
44+
// Add Photorealistic 3D Tiles
45+
try {
46+
const tileset = await Cesium.createGooglePhotorealistic3DTileset();
47+
viewer.scene.primitives.add(tileset);
48+
} catch (error) {
49+
console.log(`Error loading Photorealistic 3D Tiles tileset.
50+
${error}`);
51+
}
52+
53+
// Point the camera at the Googleplex
54+
viewer.scene.camera.setView({
55+
destination: new Cesium.Cartesian3(
56+
-2693797.551060477,
57+
-4297135.517094725,
58+
3854700.7470414364
59+
),
60+
orientation: new Cesium.HeadingPitchRoll(
61+
4.6550106925119925,
62+
-0.2863894863138836,
63+
1.3561760425773173e-7
64+
),
65+
}); //Sandcastle_End
66+
Sandcastle.finishedLoading();
67+
};
68+
if (typeof Cesium !== "undefined") {
69+
window.startupCalled = true;
70+
window.startup(Cesium).catch((error) => {
71+
"use strict";
72+
console.error(error);
73+
});
74+
}
75+
</script>
76+
</body>
77+
</html>
74.4 KB
Loading

CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Change Log
22

3-
### 1.106 - 2023-06-01
3+
### 1.105.1 - 2023-05-10
44

55
#### @cesium/engine
66

7+
##### Additions :tada:
8+
9+
- Added `createGooglePhotorealistic3DTileset` to create a 3D tileset streaming Google Photorealistic 3D Tiles.
10+
- Added `GoogleMaps` for managing credentials when loading data from the Google Map Tiles API.
11+
712
##### Fixes :wrench:
813

914
- Improved camera controls when globe is off. [#7171](https://github.com/CesiumGS/cesium/issues/7171)

Documentation/Contributors/ReleaseGuide/README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,44 @@ There is no release manager; instead, our community shares the responsibility. A
2222
4. Pull down the latest `main` branch and run `npm install`.
2323
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.
2424
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.
25-
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.
26-
8. Based on `CHANGES.md`, update each workspace version following the rules of [semantic versioning](https://semver.org/), e.g.,
25+
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.
26+
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.
27+
9. Based on `CHANGES.md`, update each workspace version following the rules of [semantic versioning](https://semver.org/), e.g.,
2728
- `npm version minor -w @cesium/engine --no-git-tag-version`
2829
- If there are no changes, skip updating the workspace version.
29-
9. Update the version in `package.json` to match, e.g. `1.14.0` -> `1.15.0`.
30-
10. Commit these changes.
31-
11. Make sure the repository is clean `git clean -d -x -f`. **This will delete all files not already in the repository.**
32-
12. Run `npm install`.
33-
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.
34-
14. Create the release zip `npm run make-zip`.
35-
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.
36-
16. Unpack the release zip to the directory of your choice and start the server by running `npm install` and then `npm start`
37-
17. Browse to http://localhost:8080 and confirm that the home page loads as expected and all links work.
38-
18. Verify that the [documentation](http://localhost:8080/Build/Documentation/index.html) built correctly
39-
19. Make sure [Hello World](http://localhost:8080/Apps/HelloWorld.html) loads.
40-
20. Make sure [Cesium Viewer](http://localhost:8080/Apps/CesiumViewer/index.html) loads.
41-
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.
42-
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.**
43-
23. Push your commits to main
30+
10. Update the version in `package.json` to match, e.g. `1.14.0` -> `1.15.0`.
31+
11. Commit these changes.
32+
12. Make sure the repository is clean `git clean -d -x -f`. **This will delete all files not already in the repository.**
33+
13. Run `npm install`.
34+
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.
35+
15. Create the release zip `npm run make-zip`.
36+
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.
37+
17. Unpack the release zip to the directory of your choice and start the server by running `npm install` and then `npm start`
38+
18. Browse to http://localhost:8080 and confirm that the home page loads as expected and all links work.
39+
19. Verify that the [documentation](http://localhost:8080/Build/Documentation/index.html) built correctly
40+
20. Make sure [Hello World](http://localhost:8080/Apps/HelloWorld.html) loads.
41+
21. Make sure [Cesium Viewer](http://localhost:8080/Apps/CesiumViewer/index.html) loads.
42+
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.
43+
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.**
44+
24. Push your commits to main
4445
- `git push`
45-
24. Create and push a [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging), e.g.,
46+
25. Create and push a [tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging), e.g.,
4647
- `git tag -a 1.1 -m "1.1 release"`
4748
- `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.)
48-
25. Publish the release zip file to GitHub
49+
26. Publish the release zip file to GitHub
4950
- https://github.com/CesiumGS/cesium/releases/new
5051
- Select the tag you use pushed
5152
- Enter 'CesiumJS 1.xx' for the title
5253
- Include date, list of highlights and link to CHANGES.md (https://github.com/CesiumGS/cesium/blob/1.xx/CHANGES.md) as the description
5354
- 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
5455
- Attach the `Cesium-1.xx` release zip file
5556
- Publish the release
56-
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`)
57-
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:
57+
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`)
58+
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:
5859
- `npm publish -w @cesium/engine`
5960
- `npm publish -w @cesium/widgets`
60-
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.
61-
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
61+
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.
62+
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
6263
- 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.
63-
30. Update the version of CesiumJS used in the Cesium Workshop: https://github.com/CesiumGS/cesium-workshop/blob/main/index.html#L13-L14
64-
31. Continue to the [Cesium Analytics release](https://github.com/CesiumGS/cesium-analytics/blob/main/Documentation/Contributors/AnalyticsReleaseGuide/README.md)
64+
31. Update the version of CesiumJS used in the Cesium Workshop: https://github.com/CesiumGS/cesium-workshop/blob/main/index.html#L13-L14
65+
32. Continue to the [Cesium Analytics release](https://github.com/CesiumGS/cesium-analytics/blob/main/Documentation/Contributors/AnalyticsReleaseGuide/README.md)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import Credit from "./Credit.js";
2+
import defined from "./defined.js";
3+
import Resource from "./Resource.js";
4+
5+
let defaultKeyCredit;
6+
const defaultKey = "AIzaSyBESBYnp1EcqtlAcjMTJ65GjUsJtaCWVXA";
7+
8+
/**
9+
* Default settings for accessing the Google Maps API.
10+
* <br/>
11+
* An API key is only required if you are using any Google Maps APIs, such as {@link createGooglePhotorealistic3DTileset}.
12+
* A default key is provided for evaluation purposes only.
13+
* Follow instructions for managing API keys for the Google Maps Platform at {@link https://developers.google.com/maps/documentation/embed/get-api-key}
14+
*
15+
* @see createGooglePhotorealistic3DTileset
16+
* @see https://developers.google.com/maps/documentation/embed/get-api-key
17+
*
18+
* @namespace GoogleMaps
19+
*/
20+
const GoogleMaps = {};
21+
22+
/**
23+
* Gets or sets the default Google Maps API key.
24+
*
25+
* @type {string}
26+
*/
27+
GoogleMaps.defaultApiKey = defaultKey;
28+
29+
/**
30+
* Gets or sets the default Google Map Tiles API endpoint.
31+
*
32+
* @type {string|Resource}
33+
* @default https://tile.googleapis.com/v1/
34+
*/
35+
GoogleMaps.mapTilesApiEndpoint = new Resource({
36+
url: "https://tile.googleapis.com/v1/",
37+
});
38+
39+
GoogleMaps.getDefaultApiKeyCredit = function (providedKey) {
40+
if (providedKey !== defaultKey) {
41+
return undefined;
42+
}
43+
44+
if (!defined(defaultKeyCredit)) {
45+
const defaultKeyMessage =
46+
'<b> \
47+
This application is using CesiumJS\'s default Google Maps API key. Please assign <i>Cesium.GoogleMaps.defaultApiKey</i> \
48+
with <a href="https://developers.google.com/maps/documentation/embed/get-api-key">your API key for the Google Maps Platform</a>.</b>';
49+
50+
defaultKeyCredit = new Credit(defaultKeyMessage, true);
51+
defaultKeyCredit._isDefaultToken = true;
52+
}
53+
54+
return defaultKeyCredit;
55+
};
56+
export default GoogleMaps;

packages/engine/Source/Core/Ion.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Ion.getDefaultTokenCredit = function (providedKey) {
4949
You can sign up for a free ion account at <a href="https://cesium.com">https://cesium.com</a>.</b>';
5050

5151
defaultTokenCredit = new Credit(defaultTokenMessage, true);
52+
defaultTokenCredit._isDefaultToken = true;
5253
}
5354

5455
return defaultTokenCredit;

packages/engine/Source/Core/RequestScheduler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ RequestScheduler.requestsByServer = {
8282
"api.cesium.com:443": 18,
8383
"assets.ion.cesium.com:443": 18,
8484
"ibasemaps-api.arcgis.com:443": 18,
85+
"tile.googleapis.com:443": 18,
8586
};
8687

8788
/**

packages/engine/Source/Core/Resource.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ function Resource(options) {
148148
} else {
149149
this._url = options.url;
150150
}
151+
152+
this._credits = options.credits;
151153
}
152154

153155
/**
@@ -372,6 +374,16 @@ Object.defineProperties(Resource.prototype, {
372374
return Object.keys(this.headers).length > 0;
373375
},
374376
},
377+
378+
/**
379+
* Gets the credits required for attribution of an asset.
380+
* @private
381+
*/
382+
credits: {
383+
get: function () {
384+
return this._credits;
385+
},
386+
},
375387
});
376388

377389
/**
@@ -732,6 +744,7 @@ Resource.prototype.clone = function (result) {
732744
retryAttempts: this.retryAttempts,
733745
request: this.request.clone(),
734746
parseUrl: false,
747+
credits: defined(this.credits) ? this.credits.slice() : undefined,
735748
});
736749
}
737750

0 commit comments

Comments
 (0)