diff --git a/public/js/globe.js b/public/js/globe.js index f9ce8891c4bf0cb11e656564a1c56527c4b127bb..981bf1f4892c369a5839d4da1c99ab8bab1d7cf4 100644 --- a/public/js/globe.js +++ b/public/js/globe.js @@ -398,12 +398,11 @@ viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { //looping threw all surfaces tileContent.forEach(t => { if(t.getProperty("description").includes("Roof")){ //HACK: checking if the are a roof surface (should come from feature_type) - - for (const [key, value] of Object.entries(shadowdata)) { //looping threw the shadowdata array + for (const [key, value] of Object.entries(shadowdata)) { //looping threw the shadowdata array if(key === t.getProperty("gml_id")){ //checking the id + console.log(value); shadowHourValue = value[chosenDate.hour-1]; //getting the current chosen hour from the timeline - t.color = Cesium.Color.fromCssColorString(getShadowPalette(shadowHourValue)); //coloring the surface - + t.color = Cesium.Color.fromCssColorString(getShadowPalette(shadowHourValue)); //coloring the surface } } diff --git a/public/js/shadowPalette.js b/public/js/shadowPalette.js index 7b7ed6a4bf72acf118f51b0f5eb6d6b0b77bb5d7..8fab0ad39179eacb38faca90c5e8d343ad527818 100644 --- a/public/js/shadowPalette.js +++ b/public/js/shadowPalette.js @@ -1,13 +1,17 @@ //Shadow palette for coloring the roofs //color pallet white->black -var shadowPalette = ['#ffffff','#f0f0f0','#d9d9d9','#bdbdbd','#969696','#737373','#525252','#252525']; -//const shadowPalette = colorPalette.reverse(); +var colorPalette = ['#ffffff','#f0f0f0','#d9d9d9','#bdbdbd','#969696','#737373','#525252','#252525']; +const shadowPalette = colorPalette.reverse(); //returns the responding color from the shadowPalette, depending on the inputShadowValue(0 to 1 in float) -function getShadowPalette(inputShadowValue){ - //TODO: add check for wrong inputShadowValues +function getShadowPalette(inputShadowValue){ //checking for the float values + var index = Math.ceil((shadowPalette.length-1)*inputShadowValue); + //console.log(inputShadowValue,"---",shadowPalette[index]); + return shadowPalette[index]; + + /* Can be ignored for now if(!Number.isInteger(inputShadowValue)){ var index = Math.ceil((shadowPalette.length-1)*inputShadowValue); //console.log(shadowPalette[index]); @@ -15,9 +19,16 @@ function getShadowPalette(inputShadowValue){ } //edge case for 0 and 1 else{ + //console.log(inputShadowValue); + if(inputShadowValue===0){ + //console.log(inputShadowValue); + return shadowPalette[shadowPalette.length-1]; + }else{ + return shadowPalette[0]; + } //console.log("black",shadowPalette[shadowPalette.length-1]); return shadowPalette[shadowPalette.length-1]; - } + }*/ }