diff --git a/public/Testgebiete.js b/public/Testgebiete.js index 8edf424dcea1526fb271f65fb95c532642cc5ec9..4410b42a1a2adbc3036afa5e0e36ff01333c5eaf 100644 --- a/public/Testgebiete.js +++ b/public/Testgebiete.js @@ -51,17 +51,59 @@ var zoomAll = function (tileset) { + +// var HFT_testbld = viewer.scene.primitives.add( +// new Cesium.Cesium3DTileset({ +// url: Cesium.IonResource.fromAssetId(905706), +// }) +// ); + +var HFT_testbld = viewer.scene.primitives.add( + new Cesium.Cesium3DTileset({ + url: "buildingTiles/HFT_testbld/tileset.json", + show: true, + }) + ); + + + HFT_testbld.readyPromise.then(function (HFT_testbld) { + var height =55; + var cartographic = Cesium.Cartographic.fromCartesian( + HFT_testbld.boundingSphere.center + ); + var surface = Cesium.Cartesian3.fromRadians( + cartographic.longitude, + cartographic.latitude, + 0.0 + ); + var offset = Cesium.Cartesian3.fromRadians( + cartographic.longitude, + cartographic.latitude, + height + ); + var translation = Cesium.Cartesian3.subtract( + offset, + surface, + new Cesium.Cartesian3() + ); + // now shift / translate the tileset by the translation vector defined above + HFT_testbld.modelMatrix = Cesium.Matrix4.fromTranslation(translation); + + return zoomAll(HFT_testbld); // zoom or rather go to the translated tileset +}); + + var load3DTiles = function () { - tilesetLOD1 = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ + tilesetLOD3 = 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) - tilesetLOD1.style = new Cesium.Cesium3DTileStyle({ + Cesium.when(tilesetLOD3.readyPromise).then(function (tilesetLOD3) { + viewer.flyTo(tilesetLOD3) + tilesetLOD3.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${featureType} === 'Window'", "color('blue')"], @@ -73,18 +115,18 @@ var zoomAll = function (tileset) { }, show: true }); - // tilesetLOD1.style = new Cesium.Cesium3DTileStyle({ + // tilesetLOD3.style = new Cesium.Cesium3DTileStyle({ // color: "color('BLACK', 0.3)", // show: true // }); - var heightOffset = 50.0; - var boundingSphere = tilesetLOD1.boundingSphere; + var heightOffset = 49.0; + var boundingSphere = tilesetLOD3.boundingSphere; var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center); var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0); var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, heightOffset); var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3()); - tilesetLOD1.modelMatrix = Cesium.Matrix4.fromTranslation(translation); + tilesetLOD3.modelMatrix = Cesium.Matrix4.fromTranslation(translation); }) } @@ -95,7 +137,7 @@ 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; + const BUILDIG_TILESET_HEIGHT_OFFSET = 50; tileset.readyPromise.then(function (tileset) { var height = BUILDIG_TILESET_HEIGHT_OFFSET; @@ -211,9 +253,9 @@ var toggleBuildingTiles = function () { } else { tileset.show = true - if (tilesetLOD1.show === true){ + if (tilesetLOD3.show === true){ $('#prettyBuildingsCheckbox').prop('checked', false); - tilesetLOD1.show = false + tilesetLOD3.show = false } } } @@ -246,12 +288,12 @@ var toggleFellbachTexturedTiles = function () { } var togglePrettyBuildingTiles = function () { - // tilesetLOD1.show = tilesetLOD1.show ? false : true; - if (tilesetLOD1.show === true) { - tilesetLOD1.show = false + // tilesetLOD3.show = tilesetLOD3.show ? false : true; + if (tilesetLOD3.show === true) { + tilesetLOD3.show = false } else { - tilesetLOD1.show = true + tilesetLOD3.show = true if (tileset.show === true){ $('#simpleBuildingsCheckbox').prop('checked', false); tileset.show = false @@ -371,7 +413,7 @@ var togglePrettyBuildingTiles = function () { Cesium.Camera.DEFAULT_VIEW_RECTANGLE = extent; Cesium.Camera.DEFAULT_VIEW_FACTOR = 0; - viewer.flyTo(tilesetLOD1); + viewer.flyTo(tilesetLOD3); diff --git a/public/buildingTiles/HFT_testbld/b3dms/R.b3dm b/public/buildingTiles/HFT_testbld/b3dms/R.b3dm new file mode 100644 index 0000000000000000000000000000000000000000..61d93e1740e73572f822a6286769815331c3e767 Binary files /dev/null and b/public/buildingTiles/HFT_testbld/b3dms/R.b3dm differ diff --git a/public/buildingTiles/HFT_testbld/tileset.json b/public/buildingTiles/HFT_testbld/tileset.json new file mode 100644 index 0000000000000000000000000000000000000000..a14f1b06b663cc0669d6aab9f42f2cee63965c1c --- /dev/null +++ b/public/buildingTiles/HFT_testbld/tileset.json @@ -0,0 +1,48 @@ +{ + "asset": { + "version": "0.0" + }, + "geometricError": 16.611315407063895, + "root": { + "refine": "ADD", + "boundingVolume": { + "region": [ + 0.16008864671949422, + 0.8513738167393398, + 0.1600914408830295, + 0.851375630141581, + 251.0, + 253.0 + ] + }, + "content": { + "uri": "b3dms/R.b3dm", + "boundingVolume": { + "region": [ + 0.16008864671949422, + 0.8513738167393398, + 0.1600914408830295, + 0.851375630141581, + 251.0, + 253.0 + ] + } + }, + "geometricError": 0.0 + }, + "properties": { + "FeatureType": {}, + "gmlID": { + "maximum": 1, + "minimum": 1 + }, + "Longitude": { + "maximum": 9.172563898765713, + "minimum": 9.172563898765713 + }, + "Latitude": { + "maximum": 48.78023038740355, + "minimum": 48.78023038740355 + } + } +} \ No newline at end of file