"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _Cesium = Cesium,
  Event = _Cesium.Event,
  Material = _Cesium.Material,
  Color = _Cesium.Color,
  createPropertyDescriptor = _Cesium.createPropertyDescriptor,
  defined = _Cesium.defined,
  Property = _Cesium.Property;
;
var CircleRippleMaterialSource = "\n                                            uniform vec4 color;\n                                            uniform float speed;\n                                            uniform float count;\n                                            uniform float gradient;\n                                            czm_material czm_getMaterial(czm_materialInput materialInput)\n                                            {\n                                            czm_material material = czm_getDefaultMaterial(materialInput);\n                                            material.diffuse = 1.5 * color.rgb;\n                                            vec2 st = materialInput.st;\n                                            float dis = distance(st, vec2(0.5, 0.5));\n                                            float per = fract(czm_frameNumber * speed / 1000.0);\n                                            if(count == 1.0){\n                                                if(dis > per * 0.5){\n                                                discard;\n                                                }else {\n                                                material.alpha = color.a  * dis / per / 2.0;\n                                                }\n                                            } else {\n                                                vec3 str = materialInput.str;\n                                                if(abs(str.z)  > 0.001){\n                                                discard;\n                                                }\n                                                if(dis > 0.5){\n                                                discard;\n                                                } else {\n                                                float perDis = 0.5 / count;\n                                                float disNum;\n                                                float bl = 0.0;\n                                                for(int i = 0; i <= 999; i++){\n                                                    if(float(i) <= count){\n                                                    disNum = perDis * float(i) - dis + per / count;\n                                                    if(disNum > 0.0){\n                                                        if(disNum < perDis){\n                                                        bl = 1.0 - disNum / perDis;\n                                                        }\n                                                        else if(disNum - perDis < perDis){\n                                                        bl = 1.0 - abs(1.0 - disNum / perDis);\n                                                        }\n                                                        material.alpha = pow(bl,(1.0 + 10.0 * (1.0 - gradient)));\n                                                    }\n                                                    }\n                                                }\n                                                }\n                                            }\n                                            return material;\n                                            }";

/**
 * 圆形扫描以及圆形扩散的类对象
 * @alias EV_CircleScan
 * @constructor
 * @param {Viewer} viewer       视图对象
 */

function CircleRippleMaterialProperty(options) {
  this._definitionChanged = new Event();
  this._color = options.color;
  this._speed = options.speed;
  this.color = options.color;
  this.speed = options.speed;
  this.count = options.count;
  this.gradient = options.gradient;
  //   Cesium.CircleRippleMaterialProperty = CircleRippleMaterialProperty;
  Material.CircleRippleMaterialProperty = 'CircleRippleMaterialProperty';
  Material.CircleRippleMaterialType = 'CircleRippleMaterialType';
  Material.CircleRippleMaterialSource = CircleRippleMaterialSource;
  //   if (defined(customMaterial)) {
  //     if (defined(customMaterial.FShader)) {
  //       Material.PolylineTrailLinkSource = customMaterial.FShader;
  //     }
  //     if (defined(customMaterial.ColorImage)) {
  //       Material.PolylineTrailLinkImage = customMaterial.ColorImage;
  //     }
  //   }
  Material._materialCache.addMaterial(Material.CircleRippleMaterialType, {
    fabric: {
      type: Material.CircleRippleMaterialType,
      uniforms: {
        color: new Color(1.0, 1.0, 0.0, 1.0),
        speed: 3.0,
        count: 4,
        gradient: 0.2,
        scale: 1.0 // 设置固定的缩放因子
      },

      source: Material.CircleRippleMaterialSource
    },
    translucent: function translucent(material) {
      return true;
    }
  });
}
Object.defineProperties(CircleRippleMaterialProperty.prototype, {
  isConstant: {
    get: function get() {
      return false;
    }
  },
  definitionChanged: {
    get: function get() {
      return this._definitionChanged;
    }
  },
  color: createPropertyDescriptor('color'),
  speed: createPropertyDescriptor('speed'),
  count: createPropertyDescriptor('count'),
  gradient: createPropertyDescriptor('gradient')
});
CircleRippleMaterialProperty.prototype.getType = function (time) {
  return Material.CircleRippleMaterialType;
};
CircleRippleMaterialProperty.prototype.getValue = function (time, result) {
  if (!defined(result)) {
    result = {};
  }
  result.color = Property.getValueOrDefault(this._color, time, Color.RED, result.color);
  result.speed = Property.getValueOrDefault(this._speed, time, 10, result.speed);
  result.count = this.count;
  result.gradient = this.gradient;
  return result;
};
CircleRippleMaterialProperty.prototype.equals = function (other) {
  return this === other || other instanceof CircleRippleMaterialProperty && Property.equals(this._color, other._color) && Property.equals(this._speed, other._speed) && Property.equals(this.count, other.count) && Property.equals(this.gradient, other.gradient);
};
var _default = CircleRippleMaterialProperty;
exports["default"] = _default;
//# sourceMappingURL=CircleRippleMaterialProperty.js.map
