线样式(无同步间距调节)
This commit is contained in:
@ -7,9 +7,11 @@ function PolylineFlow() {
|
||||
this._definitionChanged = new Cesium.Event();
|
||||
this._color = undefined;
|
||||
this._speed = undefined;
|
||||
this._rotate = undefined;
|
||||
this.color = new Cesium.Color.fromCssColorString(options.color || "rgba(255,255,255,1)");
|
||||
this.speed = options.speed || 0.25;//速度
|
||||
this.speed = options.speed != undefined ? options.speed : 1.0;//速度
|
||||
this.lineBackAlpha = options.lineBackAlpha || 0.05;
|
||||
this.rotate = options.rotate;
|
||||
}
|
||||
|
||||
get isConstant() {
|
||||
@ -41,6 +43,12 @@ function PolylineFlow() {
|
||||
10,
|
||||
result.speed
|
||||
);
|
||||
result.rotate = Cesium.Property.getValueOrDefault(
|
||||
this._rotate,
|
||||
time,
|
||||
true,
|
||||
result.rotate
|
||||
);
|
||||
result.lineBackAlpha = this.lineBackAlpha;
|
||||
result.frameNumber = Cesium.getTimestamp();
|
||||
return result;
|
||||
@ -60,6 +68,7 @@ function PolylineFlow() {
|
||||
Object.defineProperties(PolylineFlowMaterialProperty.prototype, {
|
||||
color: Cesium.createPropertyDescriptor("color"),
|
||||
speed: Cesium.createPropertyDescriptor("speed"),
|
||||
rotate: Cesium.createPropertyDescriptor("rotate"),
|
||||
transparency: Cesium.createPropertyDescriptor("lineBackAlpha"),
|
||||
});
|
||||
|
||||
@ -78,11 +87,16 @@ function PolylineFlow() {
|
||||
//获取st(uv)
|
||||
vec2 st = materialInput.st;
|
||||
//获取当前帧数,10秒内变化0-1
|
||||
float time = fract(czm_frameNumber * speed / 60.0);
|
||||
// float time = fract(czm_frameNumber * speed / 60.0);
|
||||
float time = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
//长度1/10
|
||||
time = time * (1.0 + 0.1);
|
||||
// time = time * (1.0 + 0.1);
|
||||
float staticAlpha = rotate?smoothstep(0.0,1.0, 1.0-st.s) * step(-1.0,-(1.0-st.s)):smoothstep(0.0,1.0, st.s) * step(-1.0,-st.s);
|
||||
|
||||
//平滑过渡函数
|
||||
float alpha = smoothstep(time-0.1,time,st.s) * step(-time,-st.s);
|
||||
float alpha1 = smoothstep(time-0.1,time,1.0-st.s) * step(-time,- (1.0-st.s));
|
||||
float alpha2 = smoothstep(time-0.1,time,st.s) * step(-time,- st.s);
|
||||
float alpha =(speed== 0.0)? staticAlpha:(speed < 0.0)?alpha2:alpha1;
|
||||
//光带轨迹(不会完全透明)
|
||||
alpha += lineBackAlpha;
|
||||
material.alpha = alpha;
|
||||
@ -99,6 +113,7 @@ function PolylineFlow() {
|
||||
uniforms: {
|
||||
color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
|
||||
speed: 0.1,
|
||||
rotate: true,
|
||||
lineBackAlpha: 0.05,
|
||||
},
|
||||
source: Cesium.Material.PolylineFlowMaterialSource,
|
||||
|
Reference in New Issue
Block a user