    import { Layer } from './baseLayer'
    import { Zondy } from '../../base'
    import { defaultValue } from '../../util'
    import { LayerType, LoadStatus } from '../../base/enum'

    /**
     * Cesium3DTiles图层
     * @class Cesium3DTilesCacheLayer
     * @moduleEX LayerManagerModule
     * @extends Layer
     * @param {Object} options 构造参数
     * @param {String} [options.url = ''] 服务链接
     * @param {Boolean} [options.autoReset = true] 是否跳转到模型位置
     * @param {Number} [options.duration = 0] 跳转到模型位置的时间，以秒为单位
     * @param {Boolean} [options.debugShowBoundingVolume = false] 是否显示外包盒
     * @param {Number} [options.maximumScreenSpaceError = 16] 最大屏幕空间误差，影响模型的加载数量
     * @param {Object} [options.headers = undefined] 设置数据请求头
     * @param {Boolean} [options.enableHighLight = true] 是否启用点击高亮
     * @param {Color} [options.highLightColor = Color(255, 255, 0, 255)] 高亮颜色，默认黄色
     * @param {Function} [options.highLightCallback(pickFeature, scenePosition) = undefined] 高亮后的回调事件,pickFeature:点选的要素，scenePosition:鼠标点选的屏幕像素坐标
     */

    class Cesium3DTilesCacheLayer extends Layer {
      constructor(options) {
        super(options)
        options = defaultValue(options, {})

        /**
         * 服务基地址
         * @member {String} Cesium3DTilesCacheLayer.prototype.url
         */
        this.url = defaultValue(options.url, '')
        /**
         * 图层类型
         * @member {String} Cesium3DTilesCacheLayer.prototype.type
         */
        this.type = LayerType.cesium3DTiles
        /**
         * 服务版本号
         * @member {String} Cesium3DTilesCacheLayer.prototype.version
         */
        this.version = undefined
        /**
         * 模型外包盒
         * @member {Object} Cesium3DTilesCacheLayer.prototype.boundingVolume
         */
        this.boundingVolume = undefined
        /**
         * 服务名
         * @member {String} Cesium3DTilesCacheLayer.prototype.sceneName
         */
        this.sceneName = undefined
        /**
         * 服务包含的表字段数组
         * @member {String} Cesium3DTilesCacheLayer.prototype.fieldInfo
         */
        this.fieldInfo = undefined
        /**
         * 模型位置
         * @member {Object} Cesium3DTilesCacheLayer.prototype.position
         */
        this.position = undefined
        /**
         * 模型坐标系
         * @member {Object} Cesium3DTilesCacheLayer.prototype.spatialReference
         */
        this.spatialReference = undefined
        /**
         * 描述信息
         * @member {String} Cesium3DTilesCacheLayer.prototype.description
         */
        this.description = '3DTiles图层'
        /**
         * 模型加载后，是否自动跳转
         * @member {Boolean} Cesium3DTilesCacheLayer.prototype.autoReset
         */
        this.autoReset = defaultValue(options.autoReset, true)
        /**
         * 跳转持续时间
         * @member {Number} Cesium3DTilesCacheLayer.prototype.duration
         */
        this.duration = defaultValue(options.duration, 1)
        /**
         * 最大屏幕空间误差，用来控制模型加载数量
         * @member {Number} Cesium3DTilesCacheLayer.prototype.maximumScreenSpaceError
         */
        this.maximumScreenSpaceError = defaultValue(
          options.maximumScreenSpaceError,
          16
        )
      }

      /**
       * 从igs获取图层信息的方法
       */
      load() {
        const self = this
        return new Promise((resolve) => {
          self.loadStatus = LoadStatus.loaded
          self.loaded = true
          resolve(self)
        })
      }

      /**
       * 将图层转为json对象
       * @return {Object} josn对象
       * */
      toJSON() {
        const json = super.toJSON()
        json.url = this.url
        json.autoReset = this.autoReset
        json.duration = this.duration
        json.debugShowBoundingVolume = this.debugShowBoundingVolume
        json.maximumScreenSpaceError = this.maximumScreenSpaceError
        json.headers = this.headers
        json.enableHighLight = this.enableHighLight
        json.highLightColor = this.highLightColor
        json.highLightCallback = this.highLightCallback
        return JSON.parse(JSON.stringify(json))
      }

      /**
       * 克隆并返回一个新图层
       * @return {Cesium3DTilesCacheLayer} 新的图层对象
       * */
      clone() {
        return new Cesium3DTilesCacheLayer(this.toJSON())
      }
    }

    Zondy.Layer.Cesium3DTilesCacheLayer = Cesium3DTilesCacheLayer
    export default Cesium3DTilesCacheLayer