线贴图 速度相同 切换有问题
This commit is contained in:
		@ -12,7 +12,7 @@ function LineTexture() {
 | 
			
		||||
      this.image = options.image || "";
 | 
			
		||||
      this.color = new Cesium.Color.fromCssColorString(options.color || "rgba(255,255,255,1)");
 | 
			
		||||
      this.speed = options.speed != undefined ? options.speed : 1.0;
 | 
			
		||||
      this.repeat = options.repeat || 1.0;
 | 
			
		||||
      this.repeat = options.repeat || new Cesium.Cartesian2(1.0, 1.0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get isConstant() {
 | 
			
		||||
@ -52,7 +52,7 @@ function LineTexture() {
 | 
			
		||||
      result.repeat = Cesium.Property.getValueOrDefault(
 | 
			
		||||
        this._repeat,
 | 
			
		||||
        time,
 | 
			
		||||
        1.0,
 | 
			
		||||
        new Cesium.Cartesian2(1.0, 1.0),
 | 
			
		||||
        result.repeat
 | 
			
		||||
      );
 | 
			
		||||
      result.frameNumber = Cesium.getTimestamp();
 | 
			
		||||
@ -85,14 +85,14 @@ function LineTexture() {
 | 
			
		||||
        uniform vec4 color;
 | 
			
		||||
        uniform sampler2D image;
 | 
			
		||||
        uniform float speed;
 | 
			
		||||
        uniform float repeat;
 | 
			
		||||
        // uniform float repeat;
 | 
			
		||||
        czm_material czm_getMaterial(czm_materialInput materialInput)
 | 
			
		||||
        {
 | 
			
		||||
          czm_material material = czm_getDefaultMaterial(materialInput);
 | 
			
		||||
          vec2 st = materialInput.st;
 | 
			
		||||
          st.s *= repeat; // 关键:通过repeat控制纹理密度
 | 
			
		||||
          st.s *= repeat.x; // 关键:通过repeat控制纹理密度
 | 
			
		||||
          // 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));
 | 
			
		||||
          vec4 colorImage = speed==0.0?texture2D(image, vec2(fract(st.s), st.t)):texture2D(image, vec2(fract(st.s + frameNumber / 1000.0 / speed * repeat.x / repeat.y ), st.t));
 | 
			
		||||
          material.alpha = colorImage.a * color.a;
 | 
			
		||||
          material.diffuse = color.rgb;
 | 
			
		||||
          return material;
 | 
			
		||||
@ -106,7 +106,7 @@ function LineTexture() {
 | 
			
		||||
        uniforms: {
 | 
			
		||||
          color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
 | 
			
		||||
          image: '',
 | 
			
		||||
          repeat: 1.0,
 | 
			
		||||
          repeat: new Cesium.Cartesian2(1.0, 1.0),
 | 
			
		||||
          speed: 1.0,
 | 
			
		||||
          frameNumber: Cesium.getTimestamp(),
 | 
			
		||||
          uTime: 1
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user