MCPcopy Create free account
hub / github.com/esengine/esengine / CollisionModule

Class CollisionModule

packages/particle/src/modules/CollisionModule.ts:34–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 * Collision module for particle boundaries
33 */
34export class CollisionModule implements IParticleModule {
35 readonly name = 'Collision';
36 enabled = true;
37
38 // ============= 边界设置 | Boundary Settings =============
39
40 /** 边界类型 | Boundary type */
41 boundaryType: BoundaryType = BoundaryType.Rectangle;
42
43 /** 碰撞行为 | Collision behavior */
44 behavior: CollisionBehavior = CollisionBehavior.Kill;
45
46 // ============= 矩形边界 | Rectangle Boundary =============
47
48 /** 左边界(相对于发射器)| Left boundary (relative to emitter) */
49 left: number = -200;
50
51 /** 右边界(相对于发射器)| Right boundary (relative to emitter) */
52 right: number = 200;
53
54 /** 上边界(相对于发射器)| Top boundary (relative to emitter) */
55 top: number = -200;
56
57 /** 下边界(相对于发射器)| Bottom boundary (relative to emitter) */
58 bottom: number = 200;
59
60 // ============= 圆形边界 | Circle Boundary =============
61
62 /** 圆形边界半径 | Circle boundary radius */
63 radius: number = 200;
64
65 // ============= 反弹设置 | Bounce Settings =============
66
67 /** 反弹系数 (0-1),1 = 完全弹性 | Bounce factor (0-1), 1 = fully elastic */
68 bounceFactor: number = 0.8;
69
70 /** 最小速度阈值(低于此速度时销毁)| Min velocity threshold (kill if below) */
71 minVelocityThreshold: number = 5;
72
73 /** 反弹时的生命损失 (0-1) | Life loss on bounce (0-1) */
74 lifeLossOnBounce: number = 0;
75
76 // ============= 发射器位置(运行时设置)| Emitter Position (set at runtime) =============
77
78 /** 发射器 X 坐标 | Emitter X position */
79 emitterX: number = 0;
80
81 /** 发射器 Y 坐标 | Emitter Y position */
82 emitterY: number = 0;
83
84 /** 粒子死亡标记数组 | Particle death flag array */
85 private _particlesToKill: Set<Particle> = new Set();
86
87 /**
88 * 获取需要销毁的粒子
89 * Get particles to kill
90 */
91 getParticlesToKill(): Set<Particle> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected