cesium 动态纹理-颜色-设置频率

一个是根据时间设置频率:(有动画轴)
具体区别:material里回调

var startTime = Cesium.JulianDate.now();
var speedtime=200; //毫秒

function computeCircle(radius) {
    var positions = [];
    for (var i = 0; i < 360; i++) {
        var radians = Cesium.Math.toRadians(i);
        positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians)));
    }
    return positions;
}

//时间相关
var greenTube = viewer.entities.add({
    name : 'green tube with rounded corners',
    polylineVolume : {
        positions : Cesium.Cartesian3.fromDegreesArray([-86.0, 31.0,
                                                        -86.0, 35.0,
                                                        -90.0, 35.0]),
        shape : computeCircle(6000.0),
        material : new Cesium.ColorMaterialProperty(new Cesium.CallbackProperty(function() { 
            let diff = Cesium.JulianDate.secondsDifference( Cesium.JulianDate.now(), startTime) ;
            let v = parseInt(Math.floor(diff*1000)/speedtime)%2;
            console.log(v);
            return Cesium.Color.GREEN.withAlpha(v);
        }, false))
    }
});

一个与时间无关,设置频率:(无动画轴)

//时间无关
var intervaltime=4; //间隔
let i = 0;
var redTube = viewer.entities.add({
    name : 'red tube with rounded corners',
    polylineVolume : {
        positions : Cesium.Cartesian3.fromDegreesArray([-87.0, 30.0,
                                                        -87.0, 34.0,
                                                        -91.0, 34.0]),
        shape : computeCircle(6000.0),
        material : new Cesium.ColorMaterialProperty(new Cesium.CallbackProperty(function() { 
            i+=1;
            i=i%intervaltime;
            return Cesium.Color.RED.withAlpha(i/intervaltime);
        }, false))
    }
});

你可能感兴趣的:(cesium 动态纹理-颜色-设置频率)