Class: FdParticleSystem

FdModel. FdParticleSystem

粒子系统


new FdParticleSystem(viewer [, id] [, option])

Parameters:
Name Type Argument Default Description
viewer Viewer
id String <optional>
GUID
option Object <optional>

粒子系统参数

Example
let viewer = Freedo.FdApp.createDefaultViewer('freedoContainer');
let mm = new Freedo.FdModel.FdModelManager(viewer);

// 如果 option 参数中不包含 position 属性,则会激活手动选取节点的功能;特别的,消防水柱需要 position 和 targetPosition 属性,这两个属性都可以选择设置或不设置(手动选取);

// 提供一个添加重力因素的更新回调函数,使用: updateCallBack:'_applyGravity'

// 1.选择默认参数:
let ent = mm.add('ParticleSystem', {
    type: 'fire', // 粒子系统类型: fire, bigFire, fountain, smoke, fireWater
});

// 2.手动设置参数:
let ent = mm.add('ParticleSystem', {
    type: 'bigFire',
    position:[longitude, latitude, height], // 粒子发射位置
    // targetPosition:[longitude, latitude, height], // 目标位置,仅支持消防水柱
    show: true,
    loop:true,
    lifetime:Number.MAX_VALUE,
    image: Freedo.FdApp.getFreedoXPath() + 'Assets/Textures/fire.png', 
    imageSize: new Freedo.Cartesian2(20.0, 20.0),
    minimumImageSize: new Freedo.Cartesian2(20.0, 20.0),
    maximumImageSize: new Freedo.Cartesian2(40.0, 40.0),
    emitter: ['Circle', 0.5],
    modelMatrix: Matrix4.IDENTITY,
    emitterModelMatrix: Matrix4.IDENTITY,
    color: Color.WHITE,
    startColor:Color.WHITE,
    endColor:Color.WHITE,
    scale: 1.0,
    startScale:1.0,
    endScale:1.0,
    emissionRate: 5.0, // 每秒发射的粒子数
    speed:1.0, // 设置 speed 会覆盖 minimumSpeed 和 maximumSpeed
    minimumSpeed:1.0,
    maximumSpeed:1.0,
    particleLife:5.0,
    minimumParticleLife:5.0,
    maximumParticleLife:5.0,
    mass:1.0,
    minimumMass:1.0,
    maximumMass:1.0,
    sizeInMeters: false, // 设置粒子的大小是米还是像素。当以米为单位调整粒子大小时,粒子大小不会根据视距的变化而变化
    bursts: [ new Freedo.ParticleBurst({ time: 5.0, minimum: 200, maximum: 300 })], // ParticleBurst 实例,周期性地发射粒子爆发。
    // updateCallBack: <function> // 可手动设置回调函数,每帧将调用一次回调函数以更新粒子。fountain 和 fireWater 默认使用 '_applyGravity'(添加重力因素)
});

Members


<readonly> data :Object

获取实体的属性数据

Type:
  • Object

<readonly> option :Object

获取粒子系统参数数据

Type:
  • Object

<readonly> particleSystem :ParticleSystem

获取粒子系统实例

Type:
  • ParticleSystem

Methods


clear()

清理


dispose()

销毁所有资源


getData()

获取实体的属性数据

Returns:

返回值格式:

{
   id: GUID,
   type: "ParticleSystem",
   option: {
     show: true,
     ...
   }
}
Type
Object

hide()

隐藏


on(listener [, scope])

注册事件捕捉

Parameters:
Name Type Argument Description
listener FdModel.FdParticleSystem~FdParticleSystemCallback

当有事件触发时被执行的函数。

scope Object <optional>

listener函数执行时的绑定的对象。

Returns:

返回一个函数,调用该函数可以取消监听。

Type
Freedo.Event~RemoveCallback

remove()

删除


reset()

重置


setOption(opts)

粒子系统实例化之后,通过该方法修改粒子系统的参数设置。

此时 updateCallback 参数的值为函数;其他参数值类型与创建时相同,如:emitter: ['Circle', 0.5]

当 type 为 fireWater 时, 可通过设置 position 或 targetPosition 来移动消防水柱

Parameters:
Name Type Description
opts Object

粒子系统参数


show()

显示

Type Definitions


FdParticleSystemCallback(eventType, eventArg)

Parameters:
Name Type Description
eventType String

事件类型:DataChanged

eventArg Object

DataChanged事件对应的参数