线样式(无同步间距调节)
This commit is contained in:
@ -7,9 +7,11 @@ function PolylineFlowMult() {
|
||||
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.1;//速度
|
||||
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 PolylineFlowMult() {
|
||||
10,
|
||||
result.speed
|
||||
);
|
||||
result.rotate = Cesium.Property.getValueOrDefault(
|
||||
this._rotate,
|
||||
time,
|
||||
true,
|
||||
result.rotate
|
||||
);
|
||||
result.lineBackAlpha = this.lineBackAlpha;
|
||||
result.frameNumber = Cesium.getTimestamp();
|
||||
return result;
|
||||
@ -52,6 +60,7 @@ function PolylineFlowMult() {
|
||||
(other instanceof PolylineFlowMultMaterialProperty &&
|
||||
Cesium.Property.equals(this._color, other._color) &&
|
||||
Cesium.Property.equals(this._speed, other.speed) &&
|
||||
Cesium.Property.equals(this._rotate, other.rotate) &&
|
||||
Cesium.Property.equals(this.lineBackAlpha, other.lineBackAlpha))
|
||||
);
|
||||
}
|
||||
@ -60,6 +69,7 @@ function PolylineFlowMult() {
|
||||
Object.defineProperties(PolylineFlowMultMaterialProperty.prototype, {
|
||||
color: Cesium.createPropertyDescriptor("color"),
|
||||
speed: Cesium.createPropertyDescriptor("speed"),
|
||||
rotate: Cesium.createPropertyDescriptor("rotate"),
|
||||
transparency: Cesium.createPropertyDescriptor("lineBackAlpha"),
|
||||
});
|
||||
|
||||
@ -80,27 +90,47 @@ function PolylineFlowMult() {
|
||||
float baseTime = fract(czm_frameNumber * speed / 60.0) * 1.1;
|
||||
|
||||
// 高频时间轴(控制高光点)
|
||||
float highlightTime = fract(czm_frameNumber * speed * 3.0 / 60.0);
|
||||
// float highlightTime = fract(czm_frameNumber * speed * 3.0 / 60.0);
|
||||
float highlightTime = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
float highlightSpacing = 0.3; // 高光点间隔
|
||||
|
||||
// 主光带透明度计算
|
||||
float mainAlpha = smoothstep(baseTime-0.1, baseTime, st.s) * step(-baseTime, -st.s);
|
||||
|
||||
// 多高光点计算(3个周期性光斑)
|
||||
float highlight1 = smoothstep(highlightTime-0.05, highlightTime, st.s) *
|
||||
float highlight11 = smoothstep(highlightTime-0.05, highlightTime, st.s) *
|
||||
step(-highlightTime, -st.s) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(st.s - highlightTime)));
|
||||
|
||||
float highlight2 = smoothstep(highlightTime+highlightSpacing-0.05,
|
||||
float highlight21 = smoothstep(highlightTime+highlightSpacing-0.05,
|
||||
highlightTime+highlightSpacing, st.s) *
|
||||
step(-(highlightTime+highlightSpacing), -st.s) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(st.s - (highlightTime+highlightSpacing))));
|
||||
|
||||
float highlight3 = smoothstep(highlightTime+2.0*highlightSpacing-0.05,
|
||||
float highlight31 = smoothstep(highlightTime+2.0*highlightSpacing-0.05,
|
||||
highlightTime+2.0*highlightSpacing, st.s) *
|
||||
step(-(highlightTime+2.0*highlightSpacing), -st.s) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(st.s - (highlightTime+2.0*highlightSpacing))));
|
||||
|
||||
|
||||
float highlight12 = smoothstep(highlightTime-0.05, highlightTime, 1.0 - st.s) *
|
||||
step(-highlightTime, -(1.0-st.s)) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(1.0 - st.s - highlightTime)));
|
||||
|
||||
float highlight22 = smoothstep(highlightTime+highlightSpacing-0.05,
|
||||
highlightTime+highlightSpacing, 1.0 - st.s) *
|
||||
step(-(highlightTime+highlightSpacing),-(1.0 - st.s)) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(1.0-st.s - (highlightTime+highlightSpacing))));
|
||||
|
||||
float highlight32 = smoothstep(highlightTime+2.0*highlightSpacing-0.05,
|
||||
highlightTime+2.0*highlightSpacing, 1.0 - st.s) *
|
||||
step(-(highlightTime+2.0*highlightSpacing), -(1.0-st.s)) *
|
||||
(1.0 - smoothstep(0.0, highlightSpacing, abs(1.0 - st.s - (highlightTime+2.0*highlightSpacing))));
|
||||
|
||||
|
||||
float highlight1 = !rotate?highlight11:highlight12;
|
||||
float highlight2 = !rotate?highlight21:highlight22;
|
||||
float highlight3 = !rotate?highlight31:highlight32;
|
||||
// 合并效果
|
||||
// material.alpha = mainAlpha * 0.7 +
|
||||
// (highlight1 + highlight2 + highlight3) * 0.5 +
|
||||
@ -120,6 +150,7 @@ function PolylineFlowMult() {
|
||||
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