原文链接及内容

效果如下所示:

示例代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const viewer = new Cesium.Viewer("cesiumContainer", {
sceneModePicker: false,
homeButton: false,
navigationHelpButton: false,
baseLayerPicker: false,
navigationInstructionsInitiallyVisible: false,
fullscreenButton: false,
selectionIndicator: false,
skyBox: false,
timeline: false,
animation: false,
shouldAnimate: true,
infoBox: false,
geocoder: Cesium.IonGeocodeProviderType.GOOGLE,
/**
* globe属性设置为false,无需显示地球,因为 Photorealistic 3D Tiles 已包含地形数据
*/
globe: false,
});
viewer.cesiumWidget.creditContainer.style.display = "none";

// 启用渲染天空
viewer.scene.skyAtmosphere.show = true;

// 添加谷歌的 Photorealistic 3D Tiles
try {
const tileset = await Cesium.createGooglePhotorealistic3DTileset({
/**
* 只有 Google Geocoder 可与 Google Photorealistic 3D Tiles 配合使用。
* 将查看器构造函数选项的`geocode`属性设置为 IonGeocodeProviderType.GOOGLE。
*/
onlyUsingWithGoogleGeocoder: true,
});
viewer.scene.primitives.add(tileset);
} catch (error) {
console.log(`Error loading Photorealistic 3D Tiles tileset.
${error}`);
}

/**
* Googleplex是Google及其母公司Alphabet的总部所在地,
* 位于美国加州圣克拉拉县的山景城圆形剧场园道(Amphitheatre Parkway)1600号。
*/
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,
),
});