1. CustomLineMaterial

1.1. 初始化 new CustomLineMaterial(options)

自定义材质类(适用于线几何对象),不同的材质类型有不同的属性变量,具体参数如下所示:

  • CustomMaterialType.LINE_COLOR: 填充
    • color: 填充颜色。
  • CustomMaterialType.LINE_ARROW: 箭头
    • color: 箭头颜色。
  • CustomMaterialType.LINE_DASH: 虚线
    • color: 实线部分颜色。
    • gapColor: 虚线部分颜色。
    • dashLength: 虚线中线长度,单位为像素。
    • dashPattern: 虚线样式,以将值转为二进制后的样式01分别表示虚实
  • CustomMaterialType.LINE_GROW: 发光线
    • color: 发光线主体颜色。
    • glowPower: 辉光强度,占总线宽的百分比,值小于1。
    • taperPower: 锥形渐变区域强度,占总线宽的百分比,超过1则没有锥形效果。
  • CustomMaterialType.LINE_FLOW: 流动线
    • color: 流动线主体颜色。
    • speedFactor: 流动速度因子,与流动速度呈正比。
    • repeat: 贴图重复次数。
    • imagePath: 流动线型材质贴图地址(若要显示图片本身的颜色,需将颜色参数color设置为透明色 BOSGeo.Color.TRANSPARENT).

    Param Type Default Description
    options Object
    [options.type] CustomMaterialType BOSGeo.CustomMaterialType.COLOR

    材质类型

    [options.color] Color BOSGeo.Color.RED

    填充颜色

    [options.gapColor] Color BOSGeo.Color.TRANSPARENT

    虚线间隙颜色

    [options.dashLength] Number 16

    虚线中线长度,单位为像素

    [options.dashPattern] Number 255

    虚线样式,以将值转为二进制后的样式01分别表示虚实,341 = parseInt("101010101", 2),255 = parseInt("11111111", 2)

    [options.glowPower] Number 0.25

    辉光强度,占总线宽的百分比,值小于1

    [options.taperPower] Number 1.0

    锥形渐变区域强度,占总线宽的百分比,超过1则没有锥形效果

    [options.speedFactor] Number 4

    流动速度因子,与流动速度呈正比

    [options.repeat] Number 1

    贴图重复次数

    [options.imagePath] String

    材质贴图地址

    Example

    // 箭头线材质
    var arrowMaterial = new BOSGeo.CustomLineMaterial({
        type: BOSGeo.CustomMaterialType.LINE_ARROW,
    });
    // 虚线材质
    var dashMaterial = new BOSGeo.CustomLineMaterial({
        type: BOSGeo.CustomMaterialType.LINE_DASH,
        color: BOSGeo.Color.BLACK,
        dashLength: 8,
        dashPattern: parseInt("101010101", 2)
    });
    // 发光线材质
    var growMaterial = new BOSGeo.CustomLineMaterial({
        type: BOSGeo.CustomMaterialType.LINE_GROW,
        color: BOSGeo.Color.YELLOW,
        glowPower: 0.5,
        taperPower: 0.9
    });
    // 流动线材质
    var flowMaterial = new BOSGeo.CustomLineMaterial({
        type: BOSGeo.CustomMaterialType.LINE_FLOW,
        color: BOSGeo.Color.ORANGE, //若要显示图片本身的颜色,需将该颜色参数设置为透明色 BOSGeo.Color.TRANSPARENT,
        speedFactor: 6,
        imagePath: 'https://bosgeo.boswinner.com/Assets/Images/green_line.png'
    });
    

    1.2. 属性

    属性名 Type Default Description
    LineArrowMaterial CustomLineMaterial

    静态属性,默认的箭头材质

    LineColorMaterial CustomLineMaterial

    静态属性,默认的颜色材质(实线)

    LineDashMaterial CustomLineMaterial

    静态属性,默认的虚线材质

    LineFlowMaterial CustomLineMaterial

    静态属性,默认的流动线材质

    LineGrowMaterial CustomLineMaterial

    静态属性,默认的发光线材质

    color Color BOSGeo.Color.RED

    填充颜色

    dashLength Color 16

    虚线中线长度,单位为像素

    dashPattern Boolean 255

    虚线样式,以将值转为二进制后的样式01分别表示虚实,341 = parseInt("101010101", 2),255 = parseInt("11111111", 2)

    gapColor String BOSGeo.Color.TRANSPARENT

    虚线间隙颜色

    glowPower Color 0.25

    辉光强度,占总线宽的百分比,值小于1

    imagePath Cartesian2 材质贴图地址,默认为' https://bosgeo.boswinner.com/Assets/Images/green_line.png '

    材质贴图地址

    repeat Cartesian2 4

    贴图重复次数

    speedFactor Number 4

    流动速度因子,与流动速度呈正比

    taperPower Number 1.0

    锥形渐变区域强度,占总线宽的百分比,超过1则没有锥形效果

    type CustomMaterialType BOSGeo.CustomMaterialType.COLOR

    材质类型,只读属性

    1.3. 方法

    1.3.1. customLineMaterial.toMaterial() ⇒ Material | undefined

    转为Material对象

    Kind : instance method of CustomLineMaterial

    Returns : Materialundefined -

    undefined表示转换失败

    1.3.2. customLineMaterial.equals(otherMaterial) ⇒ Boolean

    材质是否一致

    Param Type
    otherMaterial CustomLineMaterial

    1.3.3. customLineMaterial.clone(otherMaterial) ⇒ CustomLineMaterial

    克隆对应类型的材质,当类型不一致时重新创建

    Kind : instance method of CustomLineMaterial

    Param Type
    otherMaterial CustomLineMaterialundefined
    版权所有@盈嘉互联(北京)科技有限公司 京ICP备15051988号-9 Copyright © 2022 all right reserved,powered by Gitbook该文件修订时间: 2022-07-19 11:34:25

    results matching ""

      No results matching ""