Class: Beam

Beam

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


<protected> new Beam()

See:

Extends

Methods


add(data, fn)

添加一个或多个Beam对象

Parameters:
Name Type Description
data object | array

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

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

  • groupId (string) 可选,Group分组

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

  • duration (number) 光流粒子的生命周期,取值范围:[0.1~3.0],单位:秒

  • thickness (number) 光流线的宽度,取值范围: [0.01~10.0],单位:因Beam是粒子加上自发光不能精确单位,故目前按比例显示,需要精确单位的推荐使用Polyline

  • interval (number) 光流粒子发射间隔,取值范围:[1.0~10.0],单位:秒

  • velocity (number) 光流粒子的速度,取值范围:[0.1~5.0]

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

  • coordinates (array) 光流的polyline的坐标数组

fn function

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


clear(fn)

删除场景中所有的Beam

Parameters:
Name Type Description
fn function

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


delete(ids, fn)

删除一个或多个Beam对象

Parameters:
Name Type Description
ids string | array

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

fn function

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


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

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

Parameters:
Name Type Description
ids string | array

Beam对象的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获取Beam的详细信息

Parameters:
Name Type Description
ids string | array

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

fn function

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

Example
Beam的详细信息
{
            "id":	"1",
            "groupId":	"",
            "userData":	"",
            "duration":	3.000000,
            "thickness":	0.800000,
            "interval":	0.500000,
            "velocity":	5.000000,
            "color":	[1.000000, 0.000000, 0.000000],
            "coordinates":	[[491599.500000, 2490045.000000, 11.304688], [492483.500000, 2490050.500000, 8.177969], [492621.187500, 2489262.500000, 11.311719]]
        }

hide(ids, fn)

隐藏Beam

Parameters:
Name Type Description
ids string | array

Beam对象的ID或者ID数组

fn function

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


hideAll(fn)

隐藏所有Beam

Parameters:
Name Type Description
fn function

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


setColor(id, newVal, fn)

设置Color

Parameters:
Name Type Description
id string

Beam对象的ID

newVal Color

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

fn function

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


setCoordinates(id, newVal, fn)

设置Coordinates

Parameters:
Name Type Description
id string

Beam对象的ID

newVal array

新值

fn function

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


setDuration(id, newVal, fn)

设置Duration

Parameters:
Name Type Description
id any

Beam对象的ID

newVal any

新值

fn function

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


setInterval(id, newVal, fn)

设置Interval

Parameters:
Name Type Description
id string

Beam对象的ID

newVal number

新值

fn function

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


setThickness(id, newVal, fn)

设置Thickness

Parameters:
Name Type Description
id string

Beam对象的ID

newVal number

新厚度值,取值范围:[0.01-100]

fn function

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


setVelocity(id, newVal, fn)

设置Velocity

Parameters:
Name Type Description
id string

Beam对象的ID

newVal number

新值

fn function

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


show(ids, fn)

显示Beam

Parameters:
Name Type Description
ids string | array

Beam对象的ID或者ID数组

fn function

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


showAll(fn)

显示所有Beam

Parameters:
Name Type Description
fn function

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


update(data, fn)

修改一个或多个Beam对象

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: