From cecb9f7d0e104530837f8ce45b24695a1e5d792b Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Thu, 24 Jun 2021 10:09:08 +0200 Subject: [PATCH] Add documentation to functions / Cesium app --- public/js/appCesium.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/public/js/appCesium.js b/public/js/appCesium.js index 5a213f7..2d355aa 100644 --- a/public/js/appCesium.js +++ b/public/js/appCesium.js @@ -15,6 +15,11 @@ const viewer = new Cesium.Viewer("cesiumGlobeContainer", { }), }); +/** + * Load and zoom to the extents of 3DTiles + * @param {String} urlTiles URL to the 3DTiles to be loaded + * @returns {undefined} undefined + */ const loadTiles = function (urlTiles) { const tileset = new Cesium.Cesium3DTileset({ url: urlTiles, @@ -37,7 +42,11 @@ const loadTiles = function (urlTiles) { }); }; -// Function for loading 3DTiles only +/** + * Load 3DTiles for all the buildings; ignore any glTF models + * @param{*} + * @returns {undefined} undefined + */ const loadNonDetailed = function () { // Paths to data sources const URL_3DTILES = "data_3d/3dtiles/1_full/tileset.json"; @@ -46,7 +55,13 @@ const loadNonDetailed = function () { loadTiles(URL_3DTILES); }; -const gltfLoad = function (gltfId, gltfUrl) { +/** + * Load glTF models + * @param {String} gltfUrl Path to the folder containing the glTF models + * @param {String} gltfId Name of the glTF model file without the extension i.e. exclude the `.gltf` suffix + * @returns {undefined} undefined + */ +const gltfLoad = function (gltfUrl, gltfId) { const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0) ); @@ -61,7 +76,11 @@ const gltfLoad = function (gltfId, gltfUrl) { ); }; -// Function for loading 3DTiles + glTF models +/** + * Load detailed glTF models for Building 225 and 3DTiles for the rest of the buildings + * @param{*} + * @returns {undefined} undefined + */ const loadDetailed = function () { // Paths to data sources const URL_3DTILES = "data_3d/3dtiles/2_partial/tileset.json"; @@ -71,7 +90,7 @@ const loadDetailed = function () { loadTiles(URL_3DTILES); // Load Building 225 - gltfLoad("bosch_si225_3", URL_GLTF); + gltfLoad(URL_GLTF, "bosch_si225_3"); // Load sensors in Building 225 const gltfArray = [ @@ -111,7 +130,7 @@ const loadDetailed = function () { "sensor_383_v2", ]; - gltfArray.forEach((sensor) => gltfLoad(sensor, URL_GLTF)); + gltfArray.forEach((sensor) => gltfLoad(URL_GLTF, sensor)); }; if (!LOAD_DETAILED_BLDG225) { @@ -125,7 +144,7 @@ if (!LOAD_DETAILED_BLDG225) { /** * Activate feature picking for the displayed 3DTiles * @param {*} - * @returns {void} + * @returns {undefined} */ const activate3DTileFeaturePicking = function () { // HTML overlay for showing feature name on mouseover -- GitLab