修改间距大值 缓冲区bug
This commit is contained in:
@ -12,7 +12,7 @@ function FlowDashedLine() {
|
||||
this._dashSize = undefined;
|
||||
this.color = new Cesium.Color.fromCssColorString(options.color || "rgba(255,255,255,1)");
|
||||
this.speed = options.speed != undefined ? options.speed : 1.0;//速度
|
||||
this.space = options.space || 0.01;//速度
|
||||
this.space = options.space || 0.0;//速度
|
||||
this.dashSize = options.dashSize || 0.03;//速度
|
||||
this.uType = options.uType === undefined ? 1 : options.uType;//类型:0:普通流动线 1:虚化虚线
|
||||
this.lineBackAlpha = options.lineBackAlpha || 0.05;
|
||||
@ -105,15 +105,16 @@ function FlowDashedLine() {
|
||||
czm_material material = czm_getDefaultMaterial(materialInput);
|
||||
vec2 st = materialInput.st;
|
||||
|
||||
// 计算流动虚线
|
||||
float dashSize = 0.03;
|
||||
// float gapSize = 0.01;
|
||||
// float dashSize = dashSize;
|
||||
float dashSize = 0.1;
|
||||
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.0, 0.4, pattern) - smoothstep(0.6, 1.0, pattern);
|
||||
// speed现在表示完成一次完整动画循环的秒数
|
||||
float progress = speed==0.0 ? 0.0 : fract(frameNumber / 1000.0 / speed);
|
||||
float pattern = fract(st.x / dashSize * (1.0 + gapSize) + progress / dashSize * (1.0 + gapSize));
|
||||
float dash1 = step(0.0, pattern) - step(1.0/(1.0 + gapSize), pattern);
|
||||
float dash2 = smoothstep(0.0, 0.2, pattern) -
|
||||
smoothstep(1.0/(1.0 + gapSize),
|
||||
1.0/(1.0 + gapSize) + 0.2,
|
||||
pattern);
|
||||
float dash = (float(uType) != 1.0)?dash1:dash2;
|
||||
material.alpha = dash;
|
||||
material.diffuse = color.rgb;
|
||||
@ -129,8 +130,9 @@ function FlowDashedLine() {
|
||||
uniforms: {
|
||||
color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
|
||||
speed: 1,
|
||||
space: 0.01,
|
||||
space: 0.0,
|
||||
dashSize: 0.03,
|
||||
frameNumber: Cesium.getTimestamp(),
|
||||
uType: 1,
|
||||
lineBackAlpha: 0.05,
|
||||
},
|
||||
|
@ -55,6 +55,7 @@ function LineTexture() {
|
||||
1.0,
|
||||
result.repeat
|
||||
);
|
||||
result.frameNumber = Cesium.getTimestamp();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -90,7 +91,8 @@ function LineTexture() {
|
||||
czm_material material = czm_getDefaultMaterial(materialInput);
|
||||
vec2 st = materialInput.st;
|
||||
st.s *= repeat; // 关键:通过repeat控制纹理密度
|
||||
vec4 colorImage = texture2D(image, vec2(fract(st.s + speed*czm_frameNumber* 0.01), st.t));
|
||||
// vec4 colorImage = texture2D(image, vec2(fract(st.s + speed*czm_frameNumber* 0.01), st.t));
|
||||
vec4 colorImage = speed==0.0?texture2D(image, vec2(fract(st.s), st.t)):texture2D(image, vec2(fract(st.s + frameNumber / 1000.0 / speed * repeat ), st.t));
|
||||
material.alpha = colorImage.a * color.a;
|
||||
material.diffuse = color.rgb;
|
||||
return material;
|
||||
@ -106,6 +108,7 @@ function LineTexture() {
|
||||
image: '',
|
||||
repeat: 1.0,
|
||||
speed: 1.0,
|
||||
frameNumber: Cesium.getTimestamp(),
|
||||
uTime: 1
|
||||
},
|
||||
source: Cesium.Material.LineTextureMaterialSource,
|
||||
|
@ -50,7 +50,8 @@ function PolylineFlow() {
|
||||
result.rotate
|
||||
);
|
||||
result.lineBackAlpha = this.lineBackAlpha;
|
||||
result.frameNumber = Cesium.getTimestamp();
|
||||
result.frameTime = Cesium.getTimestamp();
|
||||
// result.frameNumber = Cesium.getTimestamp();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -88,7 +89,8 @@ function PolylineFlow() {
|
||||
vec2 st = materialInput.st;
|
||||
//获取当前帧数,10秒内变化0-1
|
||||
// float time = fract(czm_frameNumber * speed / 60.0);
|
||||
float time = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
// float time = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
float time = fract(frameTime / 1000.0 / abs(speed));
|
||||
//长度1/10
|
||||
// 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);
|
||||
@ -114,6 +116,7 @@ function PolylineFlow() {
|
||||
color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
|
||||
speed: 0.1,
|
||||
rotate: true,
|
||||
frameTime: Cesium.getTimestamp(),
|
||||
lineBackAlpha: 0.05,
|
||||
},
|
||||
source: Cesium.Material.PolylineFlowMaterialSource,
|
||||
|
@ -50,7 +50,7 @@ function PolylineFlowMult() {
|
||||
result.rotate
|
||||
);
|
||||
result.lineBackAlpha = this.lineBackAlpha;
|
||||
result.frameNumber = Cesium.getTimestamp();
|
||||
result.frameTime = Cesium.getTimestamp();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -91,7 +91,8 @@ function PolylineFlowMult() {
|
||||
|
||||
// 高频时间轴(控制高光点)
|
||||
// float highlightTime = fract(czm_frameNumber * speed * 3.0 / 60.0);
|
||||
float highlightTime = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
// float highlightTime = fract(abs(speed) * czm_frameNumber * 0.01);
|
||||
float highlightTime = fract(frameTime / 1000.0 / abs(speed));
|
||||
float highlightSpacing = 0.3; // 高光点间隔
|
||||
|
||||
// 主光带透明度计算
|
||||
@ -151,6 +152,7 @@ function PolylineFlowMult() {
|
||||
color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
|
||||
speed: 0.1,
|
||||
rotate: true,
|
||||
frameTime: Cesium.getTimestamp(),
|
||||
lineBackAlpha: 0.05,
|
||||
},
|
||||
source: Cesium.Material.PolylineFlowMaterialSource,
|
||||
|
Reference in New Issue
Block a user