template.html 3.5 KB
Newer Older
JOE XMG's avatar
update  
JOE XMG committed
1
2
3
4
5
6
<html lang="en">
<head>
    <meta charset="utf-8">
    <script src="https://cesium.com/downloads/cesiumjs/releases/1.94/Build/Cesium/Cesium.js"></script>
    <link href="https://cesium.com/downloads/cesiumjs/releases/1.94/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
    <script src="https://3dps.gis.lrg.tum.de/viewerCesiumNavigationMixin.min.js"> </script>
JOE XMG's avatar
update    
JOE XMG committed
7
    <style>body {margin: 0;padding: 0;overflow: hidden;}</style>
JOE XMG's avatar
update  
JOE XMG committed
8
9
10
11
12
</head>
<body>
    <div id="cesiumContainer" style="width: 100%; height:100%"></div>
    <script>
        // input data
JOE XMG's avatar
update    
JOE XMG committed
13
14
15
16
17
        const data3D_tilesetURL = ''; // a link to a 3D Tileset
        const terrainURL = ''; // a link to a terrain
        const data2D_arcgisURL = ''; // a link to a 2D ArcGIS MapServer
        const basemapProvider = new Cesium.ArcGisMapServerImageryProvider({
             url : 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
JOE XMG's avatar
update  
JOE XMG committed
18
19
            // url : 'https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer'
            // url: 'https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer'
JOE XMG's avatar
update    
JOE XMG committed
20
            // url: 'https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer'
JOE XMG's avatar
update  
JOE XMG committed
21
22
23
            // url : 'https://services.arcgisonline.com/arcgis/rest/services/Specialty/DeLorme_World_Base_Map/MapServer'

        })
JOE XMG's avatar
update    
JOE XMG committed
24
        const osmProvider = new Cesium.OpenStreetMapImageryProvider({
JOE XMG's avatar
update  
JOE XMG committed
25
26
27
28
29
30
31
32
33
34
35
36
            url: 'https://a.tile.openstreetmap.org/'
        });
        var viewer = new Cesium.Viewer('cesiumContainer', {
            baseLayerPicker: false,
            baseLayer: false,
            vrButton: false,
            geocoder: false,
            navigationHelpButton: false,
            selectionIndicator: false,
            shadows: false,
            timeline: true,
            sceneModePicker: false,
JOE XMG's avatar
update    
JOE XMG committed
37
            imageryProvider: osmProvider
JOE XMG's avatar
update  
JOE XMG committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
        });

        if (terrainURL) {
            viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
                url: terrainURL
            });
        }
        // Component 2: 3D Tileset
        var tileset;
        if (data3D_tilesetURL) {
            tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
                url: data3D_tilesetURL
            }));
            // === Settting the style of the 3D Tileset ===
            var cityStyle = new Cesium.Cesium3DTileStyle({
                color: {
                    conditions: [
                        ["${surface} === 'wall'", "color('#f2f2f2')"],
                        ["${surface} === 'roof'", "color('#ff5c4d')"],
                        ["${surface} === 'bridge'", "color('#999999')"]
                    ]
                },
            });
JOE XMG's avatar
update    
JOE XMG committed
61
62
63
            tileset.readyPromise.then(function (tileset) {
                tileset.style = cityStyle
            });
JOE XMG's avatar
update  
JOE XMG committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
        }
        if (data2D_arcgisURL) {
            viewer.imageryLayers.addImageryProvider(new Cesium.ArcGisMapServerImageryProvider({
                url: data2D_arcgisURL
            }));
        }
        // === Settting the initial view of the 3D Viewer ===
        viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(9.6473353, 47.5728539, 3500.0),
            orientation: {
                heading: Cesium.Math.toRadians(0.0),
                pitch: Cesium.Math.toRadians(-40.0),
                roll: 0.0
            }
        });

        // === Adding the navigation controls ===
        viewer.extend(Cesium.viewerCesiumNavigationMixin, {});
    </script>
</body>

</html>