Cesium clients can load both 2D (elevation layers) and 3D (mesh layers) from SkylineGlobe Server. SGS exposes 3DML data as 3D Tiles for access by Cesium clients, while storing only the original data format on the server.
On this page:
- Loading Elevation Layers in Cesium Clients
- Loading 3DML Exposed as 3D Tiles in Cesium Clients
Loading Elevation Layers in Cesium Clients
- Copy the SGSTerrainProvider directory (located in ".\SG\TerraExplorerWeb\cesium\SGSTerrainProvider") into the Cesium folder.
- In the .\Apps\HelloWorld.html file, in the head section, after Cesium.js include, add the following lines: <script src="../SGSTerrainProvider/SGSTerrainProvider.js"></script>
- Access the TE4W instantiated Cesium viewer object (of type Cesium.Viewer). See: https://cesiumjs.org/Cesium/Build/Documentation/Viewer.html for more information.
- Set the terrainProvider to “SGSTerrainProvider” with the requested SG URL and layer name, see below: var viewer = new Cesium.Viewer ('cesiumContainer',{ baseLayerPicker:false, imageryProvider: new Cesium.WebMapServiceImageryProvider({ url: 'http://www.skylineglobe.com/SG/Imagery', layers: 'skylineglobe.tbp' }), terrainProvider: new SGSTerrainProvider({ url: 'http://www.skylineglobe.com/SG/Elevation', layers: 'skylineglobe.tbp' }) })
Loading 3DML Exposed as 3D Tiles in Cesium Clients
3D Tiles can be requested in different elevation reprojection methods and different formats.
- Add a Cesium3DTileSet element: var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url : 'https://www.skylineglobe.com/SG/b3dm/1726297/tileset.json' }));
- Use the following path format: http://[ServerName]/sg/b3dm/[SGSID]/tileset.json E.g. http://www.skylineglobe.com/SG/b3dm/1726297/tileset.json Example: var viewer = new Cesium.Viewer("cesiumContainer"); var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url : 'https://www.skylineglobe.com/SG/b3dm/1726297/tileset.json' })); tileset.readyPromise.then(function(tileset) { viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0)); viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY); }); Note: You can also interactively browse, edit and run this code example in Cesium Sandcastle.
- You can set the OGC 3D Tiles version to serve to all Cesium clients (including TE4W) requesting 3D mesh layers exposed as 3D Tiles, by appending the 3D Tiles version (b3dmversion) query parameter to the end of your 3D Tile URL. Leave the parameter value empty to use the latest version. Use the following format: b3dmversion=[version #] E.g. http://www.skylineglobe.com/SG/b3dm/1726297/tileset.json?b3dmversion=V0.2 Note: If a b3dmversion query parameter is not appended to the URL, the 3D Tiles version is determined by the Default 3D Tiles Version setting on the Settings page. More about: SkylineGlobe Server settings >
- If you want to define how to handle the 3DML’s elevation values, append the vertical datum (vdatum) parameter to the end of your 3D Tile URL. The vdatum parameter can have either of the following values:
- convert_z: Reproject to ellipsoid (as required by the OGC 3D Tiles standard) for compatibility with terrain that uses true ellipsoid elevation.
- copy_z: Maintain elevation values as geoid, while declaring them as ellipsoid. Note: Most input coordinate systems and terrain data, including MPT, use geoid elevation values even though they are declared as ellipsoid when delivered to TE4W/Cesium, and thus they are actually compatible without reprojection.
- Use the following format: ?vdatum=[reprojection value: either copy_z. OR convert_z] E.g. http://www.skylineglobe.com/SG/b3dm/1726297/tileset.json?b3dmversion=V0.2&vdatum=copy_z OR http://www.skylineglobe.com/SG/b3dm/1726297Frederick_4TEDF/tileset.json?b3dmversion=V0.2&vdatum=convert_z