"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var _Cesium = Cesium,
  defined = _Cesium.defined,
  DeveloperError = _Cesium.DeveloperError,
  Color = _Cesium.Color,
  Primitive = _Cesium.Primitive,
  GeometryInstance = _Cesium.GeometryInstance,
  PolylineGeometry = _Cesium.PolylineGeometry,
  Cartesian3 = _Cesium.Cartesian3;
;
var _Cesium2 = Cesium,
  PolylineMaterialAppearance = _Cesium2.PolylineMaterialAppearance,
  Material = _Cesium2.Material;
;
var ODLineLayer = /*#__PURE__*/function () {
  function ODLineLayer(viewer, linData) {
    _classCallCheck(this, ODLineLayer);
    if (!defined(viewer)) {
      throw new DeveloperError('viewer is required');
    }
    this.viewer = viewer;
    this.primitive = null;
    this.loadLinesData(this.viewer, linData);
  }
  _createClass(ODLineLayer, [{
    key: "loadLinesData",
    value: function loadLinesData(viewer, linData) {
      var busLines = [];
      // linData.forEach(i => {
      //
      //   let points = []
      //   i.forEach(c => {
      //     points.push(c[0], c[1])
      //   });
      //   // points.push(points[0], points[1])
      //
      //   busLines.push({
      //     positions: linData,
      //     color: new Color(0.5, 0.6, 0.0, 1.0),
      //   });
      // })

      busLines.push({
        positions: linData,
        color: new Color(0.5, 0.6, 0.0, 1.0)
      });
      this.addLineDatas(busLines, viewer);
    }
  }, {
    key: "addLineDatas",
    value: function addLineDatas(busLines, viewer) {
      var _this = this;
      var scene = viewer.scene;
      busLines.forEach(function (line) {
        _this.primitive = new Primitive({
          geometryInstances: new GeometryInstance({
            geometry: new PolylineGeometry({
              positions: Cartesian3.fromDegreesArray(line.positions),
              width: 5
            })
          }),
          appearance: new PolylineMaterialAppearance({
            material: new Material({
              fabric: {
                type: 'ODLineMaterial',
                uniforms: {
                  color_0: line.color,
                  colorImage: Color.AQUA,
                  totoalFrameCount_1: 400
                },
                source: "\n                uniform float totoalFrameCount_1;\n                uniform vec4 color_0;\n                uniform vec4 colorImage;\n                czm_material czm_getMaterial(czm_materialInput materialInput)\n                {\n                    czm_material material = czm_getDefaultMaterial(materialInput);\n                    vec2 st = materialInput.st;\n                    float t = mod(czm_frameNumber, totoalFrameCount_1) / totoalFrameCount_1;\n                    t *= 1.03;\n                    float alpha = smoothstep(t - 0.1, t, st.s) * step(-t, -st.s);\n                    alpha += 0.1;\n                    alpha *= step(-0.4, -abs(0.5-st.t));\n                    // material.diffuse = color_0.rgb;\n                    material.diffuse = (colorImage.rgb+color_0.rgb);\n                    material.alpha = alpha;\n                    return material;\n                }\n              "
              },
              translucent: true
            }),
            faceForward: false,
            closed: false
          })
        });
        console.log(_this.primitive, 'this.primitive');
        scene.primitives.add(_this.primitive);
      });
    }
  }, {
    key: "destroy",
    value: function destroy() {
      this.primitive && this.viewer.scene.primitives.remove(this.primitive);
    }
  }]);
  return ODLineLayer;
}();
var _default = ODLineLayer;
exports["default"] = _default;
//# sourceMappingURL=ODLineLayer.js.map
