From ca0d8d3a1a25e9ee6d606a621f9230e18dbd181a Mon Sep 17 00:00:00 2001
From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de>
Date: Thu, 28 Oct 2021 11:06:38 +0200
Subject: [PATCH] New function: apply styling selected buildings

---
 public/js/appCesium.js | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/public/js/appCesium.js b/public/js/appCesium.js
index 5cef36b..6efc42e 100644
--- a/public/js/appCesium.js
+++ b/public/js/appCesium.js
@@ -316,3 +316,31 @@ const resetStylingForAllBuildings = function (targetTileset) {
     },
   });
 };
+
+/**
+ * Apply a different color to the buildings that are selected in the buildings & data points drop-down list
+ *
+ * @param {Object} targetTileset The 3D tileset to be styled
+ * @param {Array} buildingIdArr An array of building IDs
+ * @returns {undefined} undefined
+ */
+const applyStylingForSelectedBuildings = function (
+  targetTileset,
+  buildingIdArr
+) {
+  targetTileset.style = new Cesium.Cesium3DTileStyle({
+    color: {
+      conditions: [
+        // The maximum number of buildings = seven
+        ["${_gebaeude} === " + buildingIdArr[0], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[1], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[2], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[3], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[4], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[5], 'color("red")'],
+        ["${_gebaeude} === " + buildingIdArr[6], 'color("red")'],
+        ["true", 'color("white")'],
+      ],
+    },
+  });
+};
-- 
GitLab