Skip to content

Commit

Permalink
Merge pull request #13 from stefandegraaf/hill-shading
Browse files Browse the repository at this point in the history
use Object.values
  • Loading branch information
tebben authored Jul 31, 2024
2 parents 43c9629 + 43c0af9 commit deb3512
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions ctod/templates/static/slopeshade.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ const SlopeRampColorParams = {
Color6: "rgba(0, 0, 0, 0.5)",
};

function getHillShadingSlopeRamp() {
return Object.keys(SlopeRampParams).map((key) => SlopeRampParams[key]);
}

function getHillShadingSlopeRampColors() {
return Object.keys(SlopeRampColorParams).map(
(key) => SlopeRampColorParams[key]
);
}

function disableShading() {
viewer.scene.globe.material = undefined;
updateViewer();
Expand All @@ -40,18 +30,15 @@ function setShading() {
return;
}

const globe = viewer.scene.globe;
var material = getSlopeMaterial();
const shadingUniforms = material.uniforms;
shadingUniforms.image = getSlopeColorRamp();

globe.material = material;
const material = Cesium.Material.fromType("SlopeRamp");
material.uniforms.image = getSlopeColorRamp();
viewer.scene.globe.material = material;
updateViewer();
}

function getSlopeColorRamp() {
const values = getHillShadingSlopeRamp();
const colors = getHillShadingSlopeRampColors();
const values = Object.values(SlopeRampParams).map((value) => parseFloat(value));
const colors = Object.values(SlopeRampColorParams);
return createColorRamp(values, colors);
}

Expand All @@ -70,8 +57,4 @@ function createColorRamp(values, colors) {
ctx.fillRect(0, 0, 100, 1);

return ramp;
}

function getSlopeMaterial() {
return Cesium.Material.fromType("SlopeRamp");
}
}

0 comments on commit deb3512

Please sign in to comment.