zoukankan      html  css  js  c++  java
  • vue中cesium自定义材料之流动线条效果

    import Cesium from 'cesium/Cesium'
    
    /*
    流动纹理线
     color 颜色
     duration 持续时间 毫秒
    */
    function PolylineTrailLinkMaterialProperty (color, duration) {
      this._definitionChanged = new Cesium.Event()
      this._color = undefined
      this._colorSubscription = undefined
      this.color = color
      this.duration = duration
      this._time = new Date().getTime()
    }
    Cesium.defineProperties(PolylineTrailLinkMaterialProperty.prototype, {
      isConstant: {
        get: function () {
          return false
        }
      },
      definitionChanged: {
        get: function () {
          return this._definitionChanged
        }
      },
      color: Cesium.createPropertyDescriptor('color')
    })
    PolylineTrailLinkMaterialProperty.prototype.getType = function (time) {
      return 'PolylineTrailLink'
    }
    PolylineTrailLinkMaterialProperty.prototype.getValue = function (time, result) {
      // debugger
      if (!Cesium.defined(result)) {
        result = {}
      }
      result.color = Cesium.Property.getValueOrClonedDefault(
        this._color,
        time,
        Cesium.Color.WHITE,
        result.color
      )
      result.image = Cesium.Material.PolylineTrailLinkImage
      result.time =
        ((new Date().getTime() - this._time) % this.duration) / this.duration
      return result
    }
    PolylineTrailLinkMaterialProperty.prototype.equals = function (other) {
      return (
        this === other ||
        (other instanceof PolylineTrailLinkMaterialProperty &&
          Property.equals(this._color, other._color))
      )
    }
    Cesium.PolylineTrailLinkMaterialProperty = PolylineTrailLinkMaterialProperty
    Cesium.Material.PolylineTrailLinkType = 'PolylineTrailLink'
    Cesium.Material.PolylineTrailLinkImage = require('../assets/layout/cable.png')
    Cesium.Material.PolylineTrailLinkSource =
      'czm_material czm_getMaterial(czm_materialInput materialInput)
    
                                                          {
    
                                                               czm_material material = czm_getDefaultMaterial(materialInput);
    
                                                               vec2 st = materialInput.st;
    
                                                               vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));
    
                                                               material.alpha = colorImage.a * color.a;
    
                                                               material.diffuse = (colorImage.rgb+color.rgb)/2.0;
    
                                                               return material;
    
                                                           }'
    Cesium.Material._materialCache.addMaterial(
      Cesium.Material.PolylineTrailLinkType,
      {
        fabric: {
          type: Cesium.Material.PolylineTrailLinkType,
          uniforms: {
            color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
            image: Cesium.Material.PolylineTrailLinkImage,
            time: 0
          },
          source: Cesium.Material.PolylineTrailLinkSource
        },
        translucent: function (material) {
          return true
        }
      }
    )
    this.loopMaterial = new Cesium.PolylineTrailLinkMaterialProperty(
          Cesium.Color.AQUA,
          3750
        )
  • 相关阅读:
    表单验证
    obs 之 OBSObj
    rtmp流媒体协议分析(h264、aac)
    lintcode 508.Wiggle Sort
    SVN备份批处理文件
    防火墙没关导致 ORA-12541: TNS: 无监听程序
    [转]window10系统安装oracle11g时遇到INS-13001环境不满足最低要求
    关键驱动因素、约束和浮动因素
    C#之虚函数 非常清晰全面的讲解
    今天有个朋友问我抽象方法和接口的区别,为了解释清楚这个事情,我在网上看到一篇文章讲的非常好给大家分享一下,也感谢原作者的付出
  • 原文地址:https://www.cnblogs.com/hlweng-0207/p/11912232.html
Copyright © 2011-2022 走看看