From 8be8f75279ddf771166eb73e39b6db66d8482523 Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Thu, 24 Jun 2021 09:58:56 +0200 Subject: [PATCH] Move function that loads gltf files --- public/js/appCesium.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/public/js/appCesium.js b/public/js/appCesium.js index 2a43571..5a213f7 100644 --- a/public/js/appCesium.js +++ b/public/js/appCesium.js @@ -46,6 +46,21 @@ const loadNonDetailed = function () { loadTiles(URL_3DTILES); }; +const gltfLoad = function (gltfId, gltfUrl) { + const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( + Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0) + ); + + viewer.scene.primitives.add( + Cesium.Model.fromGltf({ + url: `${gltfUrl}/${gltfId}.gltf`, + modelMatrix: modelMatrix, + scale: 0.0254, + allowPicking: true, + }) + ); +}; + // Function for loading 3DTiles + glTF models const loadDetailed = function () { // Paths to data sources @@ -55,24 +70,8 @@ const loadDetailed = function () { // Tileset without building 225 loadTiles(URL_3DTILES); - // Function for loading glTFs - const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( - Cesium.Cartesian3.fromDegrees(9.083385, 48.881342, 0) - ); - - const gltfLoad = function (gltfId) { - viewer.scene.primitives.add( - Cesium.Model.fromGltf({ - url: `${URL_GLTF}/${gltfId}.gltf`, - modelMatrix: modelMatrix, - scale: 0.0254, - allowPicking: true, - }) - ); - }; - // Load Building 225 - gltfLoad("bosch_si225_3"); + gltfLoad("bosch_si225_3", URL_GLTF); // Load sensors in Building 225 const gltfArray = [ @@ -112,7 +111,7 @@ const loadDetailed = function () { "sensor_383_v2", ]; - gltfArray.forEach((val) => gltfLoad(val)); + gltfArray.forEach((sensor) => gltfLoad(sensor, URL_GLTF)); }; if (!LOAD_DETAILED_BLDG225) { -- GitLab