    import Zondy from '../../Zondy'
    import Symbol3DLayer from './Symbol3DLayer'
    import { Symbol3DLayerType } from '../../enum'
    import { defaultValue, toJSON } from '../../../util'
    import LineCapType from '../../enum/LineCapType'
    import LineJoinType from '../../enum/LineJoinType'
    import {
      ColorMaterial,
      LineStyleMarker3D,
      LineStylePattern3D
    } from '../support'

    /**
     * 三维线符号图层，用来在三维场景中绘制二维线，不支持二维地图视图<br/>
     * 示例如下：<br/>
     * <a href='#LineSymbol3DLayer'>[1、创建三维线符号图层]</a><br/>
     *
     * @class LineSymbol3DLayer
     * @moduleEX SymbolModule
     * @extends Symbol3DLayer
     * @param {Object} options 构造参数
     * @param {Number} [options.size = 1] 线宽度
     * @param {ColorMaterial} [options.material = new ColorMaterial()] 线的材质，目前支持的材质有：<br/>
     * ColorMaterial: 纯色材质，通过设置纯色材质来改变线的颜色
     * @param {LineStylePattern3D} [options.pattern = new LineStylePattern3D()] 三维虚线样式，仅当线材质为ColorMaterial时生效
     * @param {LineCapType} [options.cap = LineCapType.butt] 线首尾端点样式
     * @param {LineJoinType} [options.join = LineJoinType.miter] 线拐角样式
     * @param {LineStyleMarker3D} [options.marker = null] 线端点的Marker参数
     *
     * @summary <h5>支持如下方法：</h5>
     * <a href='#fromJSON'>[1、通过json数据构造一个LineSymbol3DLayer对象]</a><br/>
     * <a href='#toJSON'>[2、导出为json数据]</a><br/>
     * <a href='#clone'>[3、克隆并返回一个新的LineSymbol3DLayer对象]</a><br/>
     *
     * @example <caption><h7 id='LineSymbol3DLayer'>创建三维线符号图层</h7></caption>
     * // ES5引入方式
     * const { LineCapType, LineJoinType } = Zondy.Enum
     * const { LineStyleMarker3D, ColorMaterial, LineStylePattern3D } = Zondy.Symbol
     * // ES6引入方式
     * import { LineCapType, LineJoinType, LineStyleMarker3D, ColorMaterial, LineStylePattern3D } from "@mapgis/webclient-common"
     *
     * // 创建三维线符号图层
     * const lineSymbol3DLayer = new LineSymbol3DLayer({
     *   // 设置线宽度
     *   size: 4,
     *   // 设置线首尾端点样式
     *   cap: LineCapType.butt,
     *   // 设置线拐角样式
     *   join: LineJoinType.miter,
     *   // 设置线端点的Marker参数
     *   marker: new LineStyleMarker3D(),
     *   // 设置线的材质
     *   material: new ColorMaterial(),
     *   // 设置三维虚线样式
     *   pattern: new LineStylePattern3D()
     * })
     * */
    class LineSymbol3DLayer extends Symbol3DLayer {
      constructor(options) {
        super(options)
        options = defaultValue(options, {})
        /**
         * 三维符号图层类型
         * @member {Symbol3DLayerType} LineSymbol3DLayer.prototype.type
         */
        this.type = Symbol3DLayerType.line
        /**
         * 线首尾端点样式
         * @member {LineCapType} LineSymbol3DLayer.prototype.cap
         */
        this.cap = defaultValue(options.cap, LineCapType.butt)
        /**
         * 线拐角样式
         * @member {LineJoinType} LineSymbol3DLayer.prototype.join
         */
        this.join = defaultValue(options.join, LineJoinType.miter)
        /**
         * 线端点的Marker参数
         * @member {LineStyleMarker3D} LineSymbol3DLayer.prototype.marker
         */
        this.marker = defaultValue(options.marker, undefined)
        /**
         * 材质
         * @member {ColorMaterial} LineSymbol3DLayer.prototype.material
         */
        this.material = options.material
          ? ColorMaterial.fromJSON(options.material)
          : new ColorMaterial()
        /**
         * 三维虚线样式
         * @member {LineStylePattern3D} LineSymbol3DLayer.prototype.pattern
         */
        this.pattern = options.pattern
          ? LineStylePattern3D.fromJSON(options.pattern)
          : new LineStylePattern3D()
        /**
         * 线宽度
         * @member {Number} LineSymbol3DLayer.prototype.size
         */
        this.size = defaultValue(options.size, 1)
      }

      /**
       * <a id='fromJSON'/>
       * 通过json数据构造一个LineSymbol3DLayer对象
       * @param {Object} json json数据
       * @return {LineCallout3D} 新的LineSymbol3DLayer对象
       * */
      static fromJSON(json) {
        return new LineSymbol3DLayer(json)
      }

      /**
       * <a id='toJSON'/>
       * 导出为json数据
       * @return {Object} 导出的json数据
       * */
      toJSON() {
        return {
          type: this.type,
          cap: this.cap,
          join: this.join,
          marker: toJSON(this.marker, LineStyleMarker3D),
          material: toJSON(this.material, ColorMaterial),
          pattern: toJSON(this.pattern, LineStylePattern3D),
          size: this.size
        }
      }

      /**
       * <a id='clone'/>
       * 克隆并返回一个新的LineSymbol3DLayer对象
       * @return {LineSymbol3DLayer} 新的LineSymbol3DLayer对象
       * */
      clone() {
        return new LineSymbol3DLayer(this.toJSON())
      }
    }

    Zondy.Symbol.LineSymbol3DLayer = LineSymbol3DLayer
    export default LineSymbol3DLayer