"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;
var _cesium = require("cesium");
var _excluded = ["map", "key", "name", "legend", "url", "labelField", "template", "layerControl", "unclickable", "cancelPopup", "tipTemplate"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var CesiumTilesLayer = exports["default"] = /*#__PURE__*/function (_Cesium3DTileset) {
  function CesiumTilesLayer(opt_options) {
    var _this;
    _classCallCheck(this, CesiumTilesLayer);
    var _ref = opt_options || {},
      map = _ref.map,
      key = _ref.key,
      name = _ref.name,
      legend = _ref.legend,
      url = _ref.url,
      labelField = _ref.labelField,
      template = _ref.template,
      layerControl = _ref.layerControl,
      unclickable = _ref.unclickable,
      cancelPopup = _ref.cancelPopup,
      tipTemplate = _ref.tipTemplate,
      defaultOpt = _objectWithoutProperties(_ref, _excluded);

    //处理浏览器Url字符转义异常的问题
    if (url) {
      var proxy = _cesium.Proxy;
      proxy.getURL = function (resource) {
        return resource.replaceAll('+', '%2B');
      };
      defaultOpt.url = new _cesium.Resource({
        url: url,
        proxy: proxy
      });
    }
    _this = _callSuper(this, CesiumTilesLayer, [_objectSpread({
      modelMatrix: _cesium.Matrix4.fromArray([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
      maximumMemoryUsage: 100,
      //不可设置太高，目标机子空闲内存值以内，防止浏览器过于卡
      maximumScreenSpaceError: 16,
      //用于驱动细节细化级别的最大屏幕空间错误;较高的值可提供更好的性能，但视觉质量较低。
      preferLeaves: true,
      shadows: false,
      //是否显示阴影
      skipLevelOfDetail: true,
      baseScreenSpaceError: 1024,
      skipScreenSpaceErrorFactor: 16,
      skipLevels: 1,
      immediatelyLoadDesiredLevelOfDetail: false,
      loadSiblings: false,
      cullWithChildrenBounds: true,
      dynamicScreenSpaceError: true,
      dynamicScreenSpaceErrorDensity: 0.00278,
      dynamicScreenSpaceErrorFactor: 4.0,
      dynamicScreenSpaceErrorHeightFalloff: 0.25
    }, defaultOpt)]);
    _this.map = map;

    // 图层标识
    _this.key = key;

    // 图层名称
    _this.name = name;

    // 图例
    _this.legend = legend;

    // 标签字段
    _this.labelField = labelField;

    // 模版内容
    _this.template = template;

    // 图层控制
    _this.layerControl = layerControl;

    // 是否允许触发点击效果
    _this.unclickable = unclickable;

    // 取消气泡
    _this.cancelPopup = cancelPopup;

    // 气泡模板
    _this.tipTemplate = tipTemplate;
    return _this;
  }
  _inherits(CesiumTilesLayer, _Cesium3DTileset);
  return _createClass(CesiumTilesLayer, [{
    key: "changeHeight",
    value: function changeHeight(originHeight, height) {
      var boundingSphere = this.boundingSphere;
      var cartographic = _cesium.Cartographic.fromCartesian(boundingSphere.center);
      var surface = _cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, originHeight);
      var offset = _cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
      var translation = _cesium.Cartesian3.subtract(offset, surface, new _cesium.Cartesian3());
      this.modelMatrix = _cesium.Matrix4.fromTranslation(translation);
    }
  }, {
    key: "changeOpacity",
    value: function changeOpacity(opacity) {
      this.style = new _cesium.Cesium3DTileStyle({
        color: "color('rgba(255,255,255,".concat(opacity, ")')")
      });
    }
  }]);
}(_cesium.Cesium3DTileset);
//# sourceMappingURL=CesiumTilesLayer.js.map
