cesium之流动线
作者:互联网
http://cesium.xin/cesium/cn/Documentation1.72/Material.html?classFilter=mat
方式一 通过设置fadetype 实现流动的线
火星科技
原生Cesium
明显上面的更好
var viewer = new Cesium.Viewer('cesiumContainer');
function addPrimitiveFlowAppear(pos){
var primitive = new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new Cesium.PolylineGeometry({
positions : pos,
width : 5,
vertexFormat : Cesium.PolylineMaterialAppearance.VERTEX_FORMAT//可以不设置,一般会根据 appearance的类型自动默认对应的类型
}),
attributes : {
//color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 1.0, 1.0))
}
}),
appearance : new Cesium.PolylineMaterialAppearance({
material :
Cesium.Material.fromType(Cesium.Material.FadeType, {
repeat: false,
fadeInColor: Cesium.Color.fromCssColorString("#00ffff").withAlpha(10),
fadeOutColor:Cesium.Color.fromCssColorString("#00ffff").withAlpha(0.2),
time: new Cesium.Cartesian2(100.0, 1.0),
maximumDistance:0.15/2.5,
fadeDirection: {
x: true,
y: false,
}
})
})
});
return primitive;
}
// 通过设置fadetype 实现流动的线
var primi = addPrimitiveFlowAppear(Cesium.Cartesian3.fromDegreesArrayHeights( [117.208284, 31.809663, 36.2,
117.221568, 31.793622, 32.7,
117.271391, 31.797771, 24.3]) );
viewer.scene.primitives.add(primi);
var timex = 0;
function render() {
timex += 0.001;
if (timex >= 1) {
timex = 0; // 控制在0.0到1.0之间
}
primi.appearance.material.uniforms.time.x = timex -0.003;
Cesium.requestAnimationFrame(render);
}
Cesium.requestAnimationFrame(render);
viewer.camera.setView({
destination : Cesium.Cartesian3.fromDegrees(117.208284, 31.809663, 3600.2)
});
标签:1.0,流动,var,Cesium,new,cesium,timex 来源: https://www.cnblogs.com/hustshu/p/16122571.html