线样式(无同步间距调节)
This commit is contained in:
@ -8,8 +8,12 @@ function FlowDashedLine() {
|
||||
this._color = undefined;
|
||||
this._speed = undefined;
|
||||
this._uType = undefined;
|
||||
this._space = undefined;
|
||||
this._dashSize = 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.space = options.space || 0.01;//速度
|
||||
this.dashSize = options.dashSize || 0.03;//速度
|
||||
this.uType = options.uType === undefined ? 1 : options.uType;//类型:0:普通流动线 1:虚化虚线
|
||||
this.lineBackAlpha = options.lineBackAlpha || 0.05;
|
||||
}
|
||||
@ -43,6 +47,18 @@ function FlowDashedLine() {
|
||||
10,
|
||||
result.speed
|
||||
);
|
||||
result.space = Cesium.Property.getValueOrDefault(
|
||||
this._space,
|
||||
time,
|
||||
10,
|
||||
result.space
|
||||
);
|
||||
result.dashSize = Cesium.Property.getValueOrDefault(
|
||||
this._dashSize,
|
||||
time,
|
||||
10,
|
||||
result.dashSize
|
||||
);
|
||||
result.uType = Cesium.Property.getValueOrDefault(
|
||||
this._uType,
|
||||
time,
|
||||
@ -69,6 +85,8 @@ function FlowDashedLine() {
|
||||
Object.defineProperties(FlowDashedLineFlowMaterialProperty.prototype, {
|
||||
color: Cesium.createPropertyDescriptor("color"),
|
||||
speed: Cesium.createPropertyDescriptor("speed"),
|
||||
space: Cesium.createPropertyDescriptor("space"),
|
||||
dashSize: Cesium.createPropertyDescriptor("dashSize"),
|
||||
uType: Cesium.createPropertyDescriptor("uType"),
|
||||
transparency: Cesium.createPropertyDescriptor("lineBackAlpha"),
|
||||
});
|
||||
@ -89,11 +107,13 @@ function FlowDashedLine() {
|
||||
|
||||
// 计算流动虚线
|
||||
float dashSize = 0.03;
|
||||
float gapSize = 0.01;
|
||||
float progress = fract(czm_frameNumber * 0.01); // 时间控制流动
|
||||
// float gapSize = 0.01;
|
||||
// float dashSize = dashSize;
|
||||
float gapSize = space;
|
||||
float progress = fract(speed * czm_frameNumber * 0.01); // 时间控制流动
|
||||
float pattern = fract(st.x / (dashSize + gapSize) + progress);
|
||||
float dash1 = step(0.1, pattern) - step(0.9, pattern);
|
||||
float dash2 = smoothstep(0.1, 0.3, pattern) - smoothstep(0.7, 0.9, pattern);
|
||||
float dash2 = smoothstep(0.0, 0.4, pattern) - smoothstep(0.6, 1.0, pattern);
|
||||
float dash = (float(uType) != 1.0)?dash1:dash2;
|
||||
material.alpha = dash;
|
||||
material.diffuse = color.rgb;
|
||||
@ -108,7 +128,9 @@ function FlowDashedLine() {
|
||||
type: Cesium.Material.FlowDashedLineMaterialType,
|
||||
uniforms: {
|
||||
color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
|
||||
speed: 0.1,
|
||||
speed: 1,
|
||||
space: 0.01,
|
||||
dashSize: 0.03,
|
||||
uType: 1,
|
||||
lineBackAlpha: 0.05,
|
||||
},
|
||||
|
Reference in New Issue
Block a user