Class: Polyline

Polyline

Polyline 相关的操作
一般通过api.polyline调用其方法


new Polyline()

protected

See:

Extends

Methods


add(data, fn)

添加一个或多个Polyline对象

如何获取自定义材质路径(material)见如下动图:

如何获取自定义材质包含的参数请调用如下方法:
let res = await __g.misc.getMaterial(material);
let params = res.data[0].params;

Parameters:
Name Type Description
data object | array

数据结构,支持对象或数组,对于每一个对象支持以下属性:

  • id (string) 字符串类型的ID

  • groupId (string) 可选,Group分组

  • userData (string) 可选,用户自定义数据

  • color (Color) 颜色值,支持四种格式,取值示例

  • coordinates (array) 坐标点数组,取值示例

  • coordinateType (number) 坐标系类型,取值范围:0为Projection类型,1为WGS84类型,2为火星坐标系(GCJ02),3为百度坐标系(BD09),默认值:0

  • range (array) 可视范围: [近裁距离, 远裁距离],取值范围: [任意负值, 任意正值]

  • thickness (number) 线宽,单位:米,默认值20

  • intensity (number) 亮度,取值范围:[0~1000],默认值:0.5

  • flowRate (number) 流速,取值范围:[0~1.0],默认值:0.5

  • depthTest (boolean) 是否做深度检测,默认为true,true会被遮挡,false不会被遮挡

  • shape (number) 样式,0:直线, 1:曲线,注意:设置为曲线坐标点多的时候会非常影响添加添加效率

  • style (PolylineStyle) 折线样式,箭头/光流/贴地/实线/虚线等,取值范围:[0~7],详情参考 PolylineStyle

  • tiling (number) 可选参数,材质贴图平铺比例,和PolylineStyle取值有关,目前仅部分样式支持此参数,从起始位置开始平铺,超过的部分会按此比例生成新的区域,类似CSS的repeat。如果这个值 <= 0 使用自动计算按Polyline长度比例平铺, >0使用用户输入的值去平铺

  • material (string) 可选参数,自定义材质路径,即资源库PAK文件里材质文件的路径,设置自定义材质参数后style相关参数会失效

  • scalarParameters (array) 可选参数,仅在设置自定义材质路径后生效,自定义材质数值类型参数,包含name/value键值对的数组,其中value为数值,格式示例:[{"name":"不透明度","value":0.5},{"name":"UV重复","value":1.0}]

  • vectorParameters (array) 可选参数,仅在设置自定义材质路径后生效,自定义材质矢量类型参数,包含name/value键值对的数组,其中value为数组,格式示例:[{"name":"color1","value":[1,1,1,1]},{"name":"color2","value":[1,0,0,1]}]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


clear(fn)

删除场景中所有的Polyline

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


delete(ids, fn)

删除一个或多个Polyline对象

Parameters:
Name Type Description
ids string | array

要删除的Polyline对象的ID或者ID数组(可以删除一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


focus(ids, distance, flyTime, rotation, fn)

自动定位到合适的观察距离

Parameters:
Name Type Description
ids string | array

Polyline对象的ID或者ID数组

distance number

可选参数,观察点距离目标点(被拍摄物体)的距离,取值范围:[0.01~任意正数],如果设置为0或者不设置,系统自动计算

flyTime number

可选参数,相机飞行的时间,取值范围:[0~任意正数],单位:秒,默认值2秒

rotation array

可选参数,相机旋转的欧拉角:[Pitch,Yaw,Roll],数组元素类型:(number),取值范围:Pitch[-90~90] Yaw[-180~180] Roll[0]

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


get(ids, fn)

根据ID获取Polyline的详细信息

Parameters:
Name Type Description
ids string | array

要获取的Polyline对象ID或者ID数组(可以获取一个或者多个)

fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Example
Polyline的详细信息
{
            "id":	"p1",
            "groupId":	"",
            "userData":	"",
            "coordinates":	[[493711.156250, 2488656.250000, 7.000000], [493698.093750, 2490060.250000, 8.400000], [494434.781250, 2490056.000000, 5.400000], [494663.906250, 2491221.000000, 3.800000]],
            "shape":	0,
            "style":	0,
            "thickness":	150.000000,
            "color":	[1.000000, 0.000000, 0.000000, 1.000000],
            "flowRate":	0.500000,
            "brightness":	0.800000,
            "tiling":	0.000000,
            "depthTest":	0
        }

hide(ids, fn)

隐藏Polyline

Parameters:
Name Type Description
ids string | array

Polyline对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


hideAll(fn)

隐藏所有Polyline

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setBrightness(id, newVal, fn)

设置新的亮度

Parameters:
Name Type Description
id string

字符串类型的ID

newVal number

新值

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setColor(id, newVal, fn)

设置新的颜色值

Parameters:
Name Type Description
id string

字符串类型的ID

newVal Color

新颜色值,支持四种格式,取值示例

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setCoordinates(id, newVal, fn)

设置坐标值

Parameters:
Name Type Description
id string

字符串类型的ID

newVal array

新坐标值,取值示例

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setDepth(id, newVal, fn)

设置是否做深度检测

Parameters:
Name Type Description
id string

字符串类型的ID

newVal boolean

是否做深度检测

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setFlowRate(id, newVal, fn)

设置新的流速

Parameters:
Name Type Description
id string

字符串类型的ID

newVal number

新值

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setShape(id, newVal, fn)

设置shape新的样式

Parameters:
Name Type Description
id string

字符串类型的ID

newVal number

新值, 0: 直线, 1: 曲线

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setStyle(id, newVal, fn)

设置新的样式

Parameters:
Name Type Description
id string

字符串类型的ID

newVal number

PolylineStyle新样式,取值范围:[0~5],参考 PolylineStyle

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


setThickness(id, newVal, fn)

设置新的厚度

Parameters:
Name Type Description
id string

字符串类型的ID

newVal number

新值

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


show(ids, fn)

显示Polyline

Parameters:
Name Type Description
ids string | array

Polyline对象的ID或者ID数组

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


showAll(fn)

显示所有Polyline

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式


update(data, fn)

修改一个或多个Polyline对象

Parameters:
Name Type Description
data object | array

数据结构,请参考add方法

fn function

可选的回调函数,请参考二次开发:异步接口调用方式


updateBegin()

用于批量多次修改对象的属性

在开始修改之前调用updateBegin,然后可以多次调用setXXX方法,最后调用updateEnd提交修改更新数据
注意:
updateBegin不是异步调用,不需要await,也没有回调函数参数

Inherited From:
Overrides:
Example
__g.xxx.updateBegin();
for (let i = 0; i < 1000; i++) {
     __g.xxx.setColor(i, Color.Yellow);
} 
__g.xxx.updateEnd(function () {
     log('update finished!');
});

updateEnd(fn)

用于批量多次修改对象的属性,与updateBegin配套使用
注意:
updateEnd是异步调用,可以用回调函数也可以await

Parameters:
Name Type Description
fn function

可选的回调函数,请参考二次开发:异步接口调用方式

Inherited From:
Overrides: