diff --git a/public/HFT.html b/public/HFT.html index bb02ad58d41f5d61c930a33df5dd376a4cd1b08a..ae3427ed3c6ec8b0ec86fb773d6e6f037cbb8813 100644 --- a/public/HFT.html +++ b/public/HFT.html @@ -84,6 +84,15 @@ </label> </td> </tr> + </tr> + <tr> + <td style=" padding-bottom: 10px;"><strong>Pretty Buildings </strong> </td> + <td style=" padding-bottom: 10px; padding-left: 15px;"><label class="switch"> + <input type="checkbox" onclick="togglePrettyBuildingTiles()" checked> + <span class="slider round"></span> + </label> + </td> + </tr> </tbody> </table> </div> diff --git a/public/HFT.js b/public/HFT.js index cf65e57be1833afb0e8bbb6e80c33c205cb016b8..2ac13d9ca1a1649b5c0be4f0b28f08f5303a439a 100644 --- a/public/HFT.js +++ b/public/HFT.js @@ -22,11 +22,15 @@ var extent = Cesium.Rectangle.fromDegrees(9.162794728779428, 48.78605872069245, Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent; Cesium.Camera.DEFAULT_VIEW_FACTOR = 0; - - - viewer.scene.globe.enableLighting = true; // set lighting to true +// load 3d Tile set of HFT from Cesium ION. +var tileset = viewer.scene.primitives.add( + new Cesium.Cesium3DTileset({ + url: Cesium.IonResource.fromAssetId(656401), + }) +); + // define a function to zoom to the tileset (invoke later) var zoomAll = function (tileset) { return new Promise(function (resolve, reject) { @@ -42,23 +46,16 @@ var zoomAll = function (tileset) { }); }; -//////////////////////////// load 3d building tiles or OSM 3d Buildings /////////////////////// -// here is the switch to switch between different 3d buildings - // load 3d Tile set of SToeckach. - // var tileset = viewer.scene.primitives.add( - // new Cesium.Cesium3DTileset({ - // url: "https://steinbeis-3dps.eu/3DGeoVolumes/collections/Stuttgart/HFTBuildings_3DModel_noTexture/3dtiles/tileset.json"//Cesium.IonResource.fromAssetId(656401), - // }) - // ); + var load3DTiles = function () { tilesetLOD1 = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url: "https://steinbeis-3dps.eu/3DGeoVolumes/collections/Stuttgart/HFTBuildings_3DModel_noTexture/3dtiles/tileset.json" //Cesium.IonResource.fromAssetId(656401), })); - // + Cesium.when(tilesetLOD1.readyPromise).then(function (tilesetLOD1) { viewer.flyTo(tilesetLOD1) @@ -93,7 +90,6 @@ var zoomAll = function (tileset) { //////// important value. to find the correct value trail and error is needed for a perfect fit const BUILDIG_TILESET_HEIGHT_OFFSET = 54; - var tileset = tilesetLOD1 tileset.readyPromise.then(function (tileset) { var height = BUILDIG_TILESET_HEIGHT_OFFSET; @@ -118,7 +114,7 @@ var zoomAll = function (tileset) { // now shift / translate the tileset by the translation vector defined above tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation); - //return zoomAll(tileset); // zoom or rather go to the translated tileset + return zoomAll(tileset); // zoom or rather go to the translated tileset }); @@ -206,5 +202,9 @@ var toggleBuildingTiles = function () { tileset.show = tileset.show ? false : true; } +var togglePrettyBuildingTiles = function () { + tilesetLOD1.show = tilesetLOD1.show ? false : true; +} +