能帮我看看问题出在哪么 redWalls 这个墙怎么也调用不了getColorRamp1这个canvas
var redWalls = viewer.entities.add({
name: ‘the Red wall at height1’,
wall: {
positions: Cesium.Cartesian3.fromDegreesArrayHeights([
116.232575,39.535532,0.0,
116.232785,39.535532,0.0,
116.232890,39.535532,0.0,
]),
minimumHeights: [200.0, 200.0,200.0],//高度
material:new Cesium.ImageMaterialProperty({
// image:”2.png”,
image:getColorRamp1([0.01, 0.02, 0.03, 0.04, 0.05], true),
transparent:true
})
}
});
function getColorRamp1(elevationRamp1, isVertical = true) {
var ramp1 = document.createElement(‘canvas’);
ramp1.width = isVertical ? 1 : 100;
ramp1.height = isVertical ? 10 : 1;
var ctx1 = ramp1.getContext(‘2d’);
ctx1.rect(0, 0, 1, 100);
ctx1.fillStyle=”white”;
ctx1.fill();
var values1 = elevationRamp1;
var grd1 = isVertical ? ctx1.createLinearGradient(0, 0, 0, 100) : ctx1.createLinearGradient(0, 0, 100, 0);
grd1.addColorStop(values1[0], ‘#FFFFFF’); //black
//grd.addColorStop(values[0], ‘#000000’); //black
grd1.addColorStop(values1[1], ‘#000000’); //blue
grd1.addColorStop(values1[2], ‘#FF00FF’); //pink
grd1.addColorStop(values1[3], ‘#00FFFF’); //red
grd1.addColorStop(values1[4], ‘#0000FF’); //orange
ctx1.fillStyle = grd1;
if (isVertical)
ctx1.fillRect(0, 0, 1, 100);
else
ctx1.fillRect(0, 0, 100, 1);
return ramp1;
}