Commit c2322910 authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

New function: create 3d tileset

Refactor logic of creating a 3d tilset into a new function
parent fb213f5c
......@@ -19,24 +19,44 @@ const viewer = new Cesium.Viewer("cesiumGlobeContainer", {
});
/**
* Load and zoom to the extents of 3DTiles
* Add a tileset containing buildings
*
* @param {String} urlTiles URL of the 3DTiles to be loaded
* @returns {undefined} undefined
* @returns {Object} The tileset dataset
*/
const loadTiles = function (urlTiles) {
const tileset = new Cesium.Cesium3DTileset({
const createBuildingTileset = function (urlTiles) {
return new Cesium.Cesium3DTileset({
url: urlTiles,
});
viewer.scene.primitives.add(tileset);
};
tileset.readyPromise.then(function () {
// 3D tileset with all buildings
const nonDetailedBuilding225Tileset = createBuildingTileset(
"data_3d/3dtiles/1_full/tileset.json"
);
// 3D tileset with all buildings except Bau 225
const detailedBuilding225Tileset = createBuildingTileset(
"data_3d/3dtiles/2_partial/tileset.json"
);
/**
* Load and zoom to the extents of 3DTiles
* @param {Object} buildingTileset The 3D tileset to be loaded
* @returns {undefined} undefined
*/
const loadTiles = function (buildingTileset) {
// Add the tileset to the viewer
viewer.scene.primitives.add(buildingTileset);
buildingTileset.readyPromise.then(function () {
viewer
.zoomTo(
tileset,
new Cesium.HeadingPitchRange(
0.0,
-0.5,
tileset.boundingSphere.radius / 0.5
buildingTileset.boundingSphere.radius / 0.5
)
)
.otherwise(function (err) {
......@@ -59,11 +79,8 @@ const loadTiles = function (urlTiles) {
* @returns {undefined} undefined
*/
const loadNonDetailedBuilding225 = function () {
// Paths to data sources
const URL_3DTILES = "data_3d/3dtiles/1_full/tileset.json";
// Tileset with all buildings
loadTiles(URL_3DTILES);
// 3D tileset with all buildings
loadTiles(nonDetailedBuilding225Tileset);
};
/**
......@@ -93,12 +110,11 @@ const gltfLoad = function (gltfUrl, gltfId) {
* @returns {undefined} undefined
*/
const loadDetailedBuilding225 = function () {
// Paths to data sources
const URL_3DTILES = "data_3d/3dtiles/2_partial/tileset.json";
// Path to glTF data source
const URL_GLTF = "data_3d/gltf";
// Tileset without building 225
loadTiles(URL_3DTILES);
loadTiles(detailedBuilding225Tileset);
// Load Building 225
gltfLoad(URL_GLTF, "bosch_si225_3");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment