# 粒子行为模拟 (Simulation) 

[Simulation](https://vjmap.com/map3d/api/interfaces/Simulation.html) 通常指的是通过脚本对粒子系统进行扩展和控制的方式。例如，可以通过编写脚本来改变粒子的颜色、大小、速度等属性，或者根据游戏状态动态调整粒子系统的参数。这使得粒子效果能够响应游戏逻辑，增加互动性。


常用行为模拟类

## 施加力 [ApplyForce](https://vjmap.com/map3d/api/classes/ApplyForce.html)

模拟行为类型名称: `ApplyForce`

|属性|类型|描述|
|:---|:---|:---|
|direction|vec3|方向（**不会归一化**，向量长度会直接乘进加速度，需要时自行 `normalize()`）|
|magnitude|value|力大小——实际是**加速度**：每帧 `velocity += direction × magnitude × delta`（与粒子质量无关）|

## 噪声 [Noise](https://vjmap.com/map3d/api/classes/Noise.html)

模拟行为类型名称: `Noise`

|属性|类型|描述|
|:---|:---|:---|
|frequency|value||
|power|value||
|positionAmount|value||
|rotationAmount|value||

## 振荡力场 [TurbulenceField](https://vjmap.com/map3d/api/classes/TurbulenceField.html)

模拟行为类型名称: `TurbulenceField`

|属性|类型|描述|
|:---|:---|:---|
|scale|vec3||
|octaves|number|噪声函数的八度数|
|velocityMultiplier|vec3||
|timeScale|vec3||

## 重力 [GravityForce](https://vjmap.com/map3d/api/classes/GravityForce.html)

模拟行为类型名称: `GravityForce`

|属性|类型|描述|
|:---|:---|:---|
|center|vec3|中心|
|magnitude|number|引力强度：粒子朝 `center` 的加速度 = `magnitude / 距离²`（距离越近越强）|

## 生命周期内颜色 [ColorOverLife](https://vjmap.com/map3d/api/classes/ColorOverLife.html)

模拟行为类型名称: `ColorOverLife`

|属性|类型|描述|
|:---|:---|:---|
|color|colorFunc|颜色|

## 生命周期内旋转 [RotationOverLife](https://vjmap.com/map3d/api/classes/RotationOverLife.html)

模拟行为类型名称: `RotationOverLife`

|属性|类型|描述|
|:---|:---|:---|
|angularVelocity|valueFunc||

## 生命周期内旋转3D [Rotation3DOverLife](https://vjmap.com/map3d/api/classes/Rotation3DOverLife.html)

模拟行为类型名称: `Rotation3DOverLife`

|属性|类型|描述|
|:---|:---|:---|
|angularVelocity|rotationFunc||


## 生命周期内大小 [SizeOverLife](https://vjmap.com/map3d/api/classes/SizeOverLife.html)

模拟行为类型名称: `SizeOverLife`

|属性|类型|描述|
|:---|:---|:---|
|size|valueFunc||

## 颜色随速度变化 [ColorBySpeed](https://vjmap.com/map3d/api/classes/ColorBySpeed.html)

模拟行为类型名称: `ColorBySpeed`

|属性|类型|描述|
|:---|:---|:---|
|color|colorFunc|颜色|
|speedRange|range|速度区间|


## 旋转随速度变化 [RotationBySpeed](https://vjmap.com/map3d/api/classes/RotationBySpeed.html)

模拟行为类型名称: `RotationBySpeed`

|属性|类型|描述|
|:---|:---|:---|
|angularVelocity|valueFunc||
|speedRange|range|速度区间|

## 大小随速度变化 [SizeBySpeed](https://vjmap.com/map3d/api/classes/SizeBySpeed.html)

模拟行为类型名称: `SizeBySpeed`

|属性|类型|描述|
|:---|:---|:---|
|size|valueFunc||
|speedRange|range|速度区间|


## 生命周期内速度 [SpeedOverLife](https://vjmap.com/map3d/api/classes/SpeedOverLife.html)

模拟行为类型名称: `SpeedOverLife`

|属性|类型|描述|
|:---|:---|:---|
|speed|valueFunc||

## 生命周期内帧率 [FrameOverLife](https://vjmap.com/map3d/api/classes/FrameOverLife.html)

模拟行为类型名称: `FrameOverLife`

|属性|类型|描述|
|:---|:---|:---|
|frame|valueFunc||

## 生命周期内受力 [ForceOverLife](https://vjmap.com/map3d/api/classes/ForceOverLife.html)

模拟行为类型名称: `ForceOverLife`

|属性|类型|描述|
|:---|:---|:---|
|x|valueFunc||
|y|valueFunc||
|z|valueFunc||

##  [OrbitOverLife](https://vjmap.com/map3d/api/classes/OrbitOverLife.html)

模拟行为类型名称: `OrbitOverLife`

|属性|类型|描述|
|:---|:---|:---|
|orbitSpeed|valueFunc||
|axis|vec3||

##  [WidthOverLength](https://vjmap.com/map3d/api/classes/WidthOverLength.html)

模拟行为类型名称: `WidthOverLength`

|属性|类型|描述|
|:---|:---|:---|
|width|valueFunc||

## 改变发射方向 [ChangeEmitDirection](https://vjmap.com/map3d/api/classes/ChangeEmitDirection.html)

模拟行为类型名称: `ChangeEmitDirection`

|属性|类型|描述|
|:---|:---|:---|
|angle|value||


## 发射子粒子系统 [EmitSubParticleSystem](https://vjmap.com/map3d/api/classes/EmitSubParticleSystem.html)

模拟行为类型名称: `EmitSubParticleSystem`

|属性|类型|描述|
|:---|:---|:---|
|particleSystem|self||
|useVelocityAsBasis|boolean||
|subParticleSystem|ParticleEmitter|子粒子系统的**发射器对象**（如 `addParticle(...)` 的返回值，不是 `ParticleSystem`）|
|mode|number|何时发射子粒子：`0` = Death（粒子死亡时）、`1` = Birth（粒子出生时）、`2` = Frame（每帧，默认）；可用 `vjmap3d.SubParticleEmitMode.Death` 等枚举|
|emitProbability|number||

##  生命周期内限速 [LimitSpeedOverLife](https://vjmap.com/map3d/api/classes/LimitSpeedOverLife.html)

模拟行为类型名称: `LimitSpeedOverLife`

|属性|类型|描述|
|:---|:---|:---|
|speed|valueFunc||
|dampen|number|抑制值|

##  应用碰撞 [ApplyCollision](https://vjmap.com/map3d/api/classes/ApplyCollision.html)

模拟行为类型名称: `ApplyCollision`

|属性|类型|描述|
|:---|:---|:---|
|resolver|PhysicsResolver `{ resolve(pos: Vector3, normal: Vector3): boolean }`|碰撞求解器对象（注意字段名是 `resolver` 不是 `resolve`）|
|bounce|number|反弹系数（碰撞后速度乘以该值）。必须传**数字**，传 ValueGenerator（如 `new ConstantValue(0.5)`）会得到 NaN|