pixi-particle-system 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Emitter.d.ts +285 -0
- package/dist/Emitter.d.ts.map +1 -0
- package/dist/EmitterConfig.d.ts +79 -0
- package/dist/EmitterConfig.d.ts.map +1 -0
- package/dist/behavior/EmitterBehavior.d.ts +79 -0
- package/dist/behavior/EmitterBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/AlphaBehavior.d.ts +98 -0
- package/dist/behavior/built-in/AlphaBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/ColorBehavior.d.ts +98 -0
- package/dist/behavior/built-in/ColorBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/MovementBehavior.d.ts +184 -0
- package/dist/behavior/built-in/MovementBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/RotationBehavior.d.ts +132 -0
- package/dist/behavior/built-in/RotationBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/ScaleBehavior.d.ts +114 -0
- package/dist/behavior/built-in/ScaleBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/SpawnBehavior.d.ts +191 -0
- package/dist/behavior/built-in/SpawnBehavior.d.ts.map +1 -0
- package/dist/behavior/built-in/TextureBehavior.d.ts +77 -0
- package/dist/behavior/built-in/TextureBehavior.d.ts.map +1 -0
- package/dist/behavior/index.d.ts +9 -0
- package/dist/behavior/index.d.ts.map +1 -0
- package/dist/data/easing/Ease.d.ts +57 -0
- package/dist/data/easing/Ease.d.ts.map +1 -0
- package/dist/data/easing/eases/BackEase.d.ts +49 -0
- package/dist/data/easing/eases/BackEase.d.ts.map +1 -0
- package/dist/data/easing/eases/BounceEase.d.ts +47 -0
- package/dist/data/easing/eases/BounceEase.d.ts.map +1 -0
- package/dist/data/easing/eases/CircleEase.d.ts +50 -0
- package/dist/data/easing/eases/CircleEase.d.ts.map +1 -0
- package/dist/data/easing/eases/ElasticEase.d.ts +47 -0
- package/dist/data/easing/eases/ElasticEase.d.ts.map +1 -0
- package/dist/data/easing/eases/PowerEase.d.ts +192 -0
- package/dist/data/easing/eases/PowerEase.d.ts.map +1 -0
- package/dist/data/easing/eases/SineEase.d.ts +48 -0
- package/dist/data/easing/eases/SineEase.d.ts.map +1 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/list/ColorList.d.ts +18 -0
- package/dist/data/list/ColorList.d.ts.map +1 -0
- package/dist/data/list/List.d.ts +81 -0
- package/dist/data/list/List.d.ts.map +1 -0
- package/dist/data/list/NumberList.d.ts +17 -0
- package/dist/data/list/NumberList.d.ts.map +1 -0
- package/dist/error/EmitterError.d.ts +12 -0
- package/dist/error/EmitterError.d.ts.map +1 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1657 -0
- package/dist/index.js.map +1 -0
- package/dist/particle/EmitterParticle.d.ts +127 -0
- package/dist/particle/EmitterParticle.d.ts.map +1 -0
- package/dist/particle/index.d.ts +2 -0
- package/dist/particle/index.d.ts.map +1 -0
- package/dist/util/ColorUtil.d.ts +31 -0
- package/dist/util/ColorUtil.d.ts.map +1 -0
- package/dist/util/Types.d.ts +91 -0
- package/dist/util/Types.d.ts.map +1 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/index.d.ts.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { ParticleContainer } from 'pixi.js';
|
|
2
|
+
import { AlphaBehavior } from './behavior/built-in/AlphaBehavior';
|
|
3
|
+
import { ColorBehavior } from './behavior/built-in/ColorBehavior';
|
|
4
|
+
import { MovementBehavior } from './behavior/built-in/MovementBehavior';
|
|
5
|
+
import { RotationBehavior } from './behavior/built-in/RotationBehavior';
|
|
6
|
+
import { ScaleBehavior } from './behavior/built-in/ScaleBehavior';
|
|
7
|
+
import { SpawnBehavior } from './behavior/built-in/SpawnBehavior';
|
|
8
|
+
import { TextureBehavior } from './behavior/built-in/TextureBehavior';
|
|
9
|
+
import { InitBehavior, UpdateBehavior } from './behavior/EmitterBehavior';
|
|
10
|
+
import { Ease } from './data/easing/Ease';
|
|
11
|
+
import { EmitterConfig } from './EmitterConfig';
|
|
12
|
+
import { BaseParticleData, EmitterParticle, IEmitterParticle } from './particle/EmitterParticle';
|
|
13
|
+
/**
|
|
14
|
+
* Extra emitter options allowing for custom particles/particle data.
|
|
15
|
+
* @template DataType Type describing the data object stored on particles.
|
|
16
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
17
|
+
* @group Emitter/
|
|
18
|
+
*/
|
|
19
|
+
export type EmitterOptions<DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> = {
|
|
20
|
+
/**
|
|
21
|
+
* Creates and returns object containing particle data. By default,
|
|
22
|
+
* uses {@link BaseParticleData} object to store particle data.
|
|
23
|
+
* @returns New particle data object.
|
|
24
|
+
*/
|
|
25
|
+
dataFactory?: () => DataType;
|
|
26
|
+
/**
|
|
27
|
+
* Creates and returns new instance of a particle. By default,
|
|
28
|
+
* uses {@link EmitterParticle} as the base particle class.
|
|
29
|
+
* @param data Data used by the particle.
|
|
30
|
+
* @returns New particle instance.
|
|
31
|
+
*/
|
|
32
|
+
particleFactory?: (data: DataType) => ParticleType;
|
|
33
|
+
/**
|
|
34
|
+
* Initializes any custom data for the particles. By default,
|
|
35
|
+
* does nothing, as there is no custom data.
|
|
36
|
+
* @param data Data used by the particle.
|
|
37
|
+
*/
|
|
38
|
+
customDataInitializer?: (data: DataType) => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Class responsible for spawning and managing particles using various behaviors.
|
|
42
|
+
*
|
|
43
|
+
* Emitter is the core class of the particle system, handling particle creation, updating,
|
|
44
|
+
* and recycling. It utilizes a set of behaviors to define how particles are initialized
|
|
45
|
+
* and updated over their lifetime.
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const emitter = new Emitter(particleContainer, {
|
|
49
|
+
* emitterVersion: 0,
|
|
50
|
+
* minParticleLifetime: 1,
|
|
51
|
+
* maxParticleLifetime: 3,
|
|
52
|
+
* spawnInterval: 0.1,
|
|
53
|
+
* maxParticles: 500,
|
|
54
|
+
* alphaBehavior: {
|
|
55
|
+
* mode: "list",
|
|
56
|
+
* list: [1, 0]
|
|
57
|
+
* },
|
|
58
|
+
* scaleBehavior: {
|
|
59
|
+
* mode: "random",
|
|
60
|
+
* xList: [0.5, 1],
|
|
61
|
+
* yList: [0.5, 1]
|
|
62
|
+
* }
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* emitter.play();
|
|
66
|
+
* ```
|
|
67
|
+
* @template DataType Type describing the data object stored on particles.
|
|
68
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
69
|
+
* @group Emitter
|
|
70
|
+
*/
|
|
71
|
+
export declare class Emitter<DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = EmitterParticle<DataType>> {
|
|
72
|
+
private readonly _version;
|
|
73
|
+
private readonly _dataFactory;
|
|
74
|
+
private readonly _particleFactory;
|
|
75
|
+
private readonly _customDataInitializer;
|
|
76
|
+
private readonly _parent;
|
|
77
|
+
private readonly _particles;
|
|
78
|
+
private readonly _pooledParticles;
|
|
79
|
+
private readonly _initBehaviors;
|
|
80
|
+
private readonly _updateBehaviors;
|
|
81
|
+
private readonly _alphaBehavior;
|
|
82
|
+
private readonly _colorBehavior;
|
|
83
|
+
private readonly _movementBehavior;
|
|
84
|
+
private readonly _rotationBehavior;
|
|
85
|
+
private readonly _scaleBehavior;
|
|
86
|
+
private readonly _spawnBehavior;
|
|
87
|
+
private readonly _textureBehavior;
|
|
88
|
+
private _ease;
|
|
89
|
+
private _easeFunction;
|
|
90
|
+
private _minLifetime;
|
|
91
|
+
private _maxLifetime;
|
|
92
|
+
private _spawnInterval;
|
|
93
|
+
private _spawnChance;
|
|
94
|
+
private _maxParticles;
|
|
95
|
+
private _addAtBack;
|
|
96
|
+
private _particlesPerWave;
|
|
97
|
+
private _particleCount;
|
|
98
|
+
private _spawnTimer;
|
|
99
|
+
private _emitterLife;
|
|
100
|
+
private _onComplete;
|
|
101
|
+
private _isActive;
|
|
102
|
+
private _isEmitting;
|
|
103
|
+
private _isPaused;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new Emitter.
|
|
106
|
+
* @param parent Parent ParticleContainer to which particles will be added.
|
|
107
|
+
* @param initialConfig Optional initial configuration for the emitter.
|
|
108
|
+
* @param options Optional factories and initializers for custom particle data and particles.
|
|
109
|
+
*/
|
|
110
|
+
constructor(parent: ParticleContainer, initialConfig?: EmitterConfig, options?: EmitterOptions<DataType, ParticleType>);
|
|
111
|
+
/**
|
|
112
|
+
* Current version of the emitter.
|
|
113
|
+
*/
|
|
114
|
+
get version(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Parent ParticleContainer of the emitter.
|
|
117
|
+
*/
|
|
118
|
+
get parent(): ParticleContainer;
|
|
119
|
+
/**
|
|
120
|
+
* Number of active particles in the emitter.
|
|
121
|
+
*/
|
|
122
|
+
get particleCount(): number;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the emitter is currently emitting new particles.
|
|
125
|
+
*/
|
|
126
|
+
get isEmitting(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Whether the emitter is currently paused.
|
|
129
|
+
*/
|
|
130
|
+
get isPaused(): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Minimum lifetime of particles in seconds.
|
|
133
|
+
*/
|
|
134
|
+
get minLifetime(): number;
|
|
135
|
+
set minLifetime(value: number);
|
|
136
|
+
/**
|
|
137
|
+
* Maximum lifetime of particles in seconds.
|
|
138
|
+
*/
|
|
139
|
+
get maxLifetime(): number;
|
|
140
|
+
set maxLifetime(value: number);
|
|
141
|
+
/**
|
|
142
|
+
* Interval between particle spawns in seconds.
|
|
143
|
+
*/
|
|
144
|
+
get spawnInterval(): number;
|
|
145
|
+
set spawnInterval(value: number);
|
|
146
|
+
/**
|
|
147
|
+
* Chance of spawning a particle (0.0 - 1.0).
|
|
148
|
+
*/
|
|
149
|
+
get spawnChance(): number;
|
|
150
|
+
set spawnChance(value: number);
|
|
151
|
+
/**
|
|
152
|
+
* Maximum number of particles allowed in the emitter.
|
|
153
|
+
*/
|
|
154
|
+
get maxParticles(): number;
|
|
155
|
+
set maxParticles(value: number);
|
|
156
|
+
/**
|
|
157
|
+
* Whether to add new particles at the back of the container.
|
|
158
|
+
*/
|
|
159
|
+
get addAtBack(): boolean;
|
|
160
|
+
set addAtBack(value: boolean);
|
|
161
|
+
/**
|
|
162
|
+
* Number of particles to spawn per wave.
|
|
163
|
+
*/
|
|
164
|
+
get particlesPerWave(): number;
|
|
165
|
+
set particlesPerWave(value: number);
|
|
166
|
+
/**
|
|
167
|
+
* Ease applied to particle lifetime.
|
|
168
|
+
*/
|
|
169
|
+
get ease(): Ease;
|
|
170
|
+
set ease(value: Ease);
|
|
171
|
+
/**
|
|
172
|
+
* Alpha behavior of the emitter.
|
|
173
|
+
*/
|
|
174
|
+
get alphaBehavior(): AlphaBehavior<DataType, ParticleType>;
|
|
175
|
+
/**
|
|
176
|
+
* Color behavior of the emitter.
|
|
177
|
+
*/
|
|
178
|
+
get colorBehavior(): ColorBehavior<DataType, ParticleType>;
|
|
179
|
+
/**
|
|
180
|
+
* Movement behavior of the emitter.
|
|
181
|
+
*/
|
|
182
|
+
get movementBehavior(): MovementBehavior<DataType, ParticleType>;
|
|
183
|
+
/**
|
|
184
|
+
* Rotation behavior of the emitter.
|
|
185
|
+
*/
|
|
186
|
+
get rotationBehavior(): RotationBehavior<DataType, ParticleType>;
|
|
187
|
+
/**
|
|
188
|
+
* Scale behavior of the emitter.
|
|
189
|
+
*/
|
|
190
|
+
get scaleBehavior(): ScaleBehavior<DataType, ParticleType>;
|
|
191
|
+
/**
|
|
192
|
+
* Spawn behavior of the emitter.
|
|
193
|
+
*/
|
|
194
|
+
get spawnBehavior(): SpawnBehavior<DataType, ParticleType>;
|
|
195
|
+
/**
|
|
196
|
+
* Texture behavior of the emitter.
|
|
197
|
+
*/
|
|
198
|
+
get textureBehavior(): TextureBehavior<DataType, ParticleType>;
|
|
199
|
+
/**
|
|
200
|
+
* Applies a configuration to the emitter.
|
|
201
|
+
* @param config Configuration to apply.
|
|
202
|
+
*/
|
|
203
|
+
applyConfig(config: EmitterConfig): void;
|
|
204
|
+
/**
|
|
205
|
+
* Retrieves the current configuration for emitter and its behaviors.
|
|
206
|
+
* @returns Current configuration object.
|
|
207
|
+
*/
|
|
208
|
+
getConfig(): EmitterConfig;
|
|
209
|
+
/**
|
|
210
|
+
* Starts the emitter and hooks into the shared ticker.
|
|
211
|
+
*/
|
|
212
|
+
play(): void;
|
|
213
|
+
/**
|
|
214
|
+
* Pauses the emitter by unhooking from the shared ticker.
|
|
215
|
+
*/
|
|
216
|
+
pause(): void;
|
|
217
|
+
/**
|
|
218
|
+
* Resumes the emitter by rehooking into the shared ticker.
|
|
219
|
+
*/
|
|
220
|
+
resume(): void;
|
|
221
|
+
/**
|
|
222
|
+
* Stops new particles from spawning, and lets existing particles die naturally.
|
|
223
|
+
* @param instant When true, particles are removed instantly.
|
|
224
|
+
*/
|
|
225
|
+
stop(instant?: boolean): void;
|
|
226
|
+
/**
|
|
227
|
+
* Prewarms the emitter by simulating particle spawning and updating for a given time.
|
|
228
|
+
* @param time Time in seconds to prewarm the emitter.
|
|
229
|
+
*/
|
|
230
|
+
prewarm(time: number): void;
|
|
231
|
+
/**
|
|
232
|
+
* Checks if a behavior is currently active in the emitter's init behaviors.
|
|
233
|
+
* @param behavior Behavior to check.
|
|
234
|
+
* @returns Whether the behavior is active.
|
|
235
|
+
*/
|
|
236
|
+
isBehaviorInitActive(behavior: InitBehavior<DataType, ParticleType>): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Checks if a behavior is currently active in the emitter's update behaviors.
|
|
239
|
+
* @param behavior Behavior to check.
|
|
240
|
+
* @returns Whether the behavior is active.
|
|
241
|
+
*/
|
|
242
|
+
isBehaviorUpdateActive(behavior: UpdateBehavior<DataType, ParticleType>): boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Adds a behavior to the active init behaviors.
|
|
245
|
+
* @param behavior Behavior to add.
|
|
246
|
+
*/
|
|
247
|
+
addToActiveInitBehaviors(behavior: InitBehavior<DataType, ParticleType>): void;
|
|
248
|
+
/**
|
|
249
|
+
* Adds a behavior to the active update behaviors.
|
|
250
|
+
* @param behavior Behavior to add.
|
|
251
|
+
*/
|
|
252
|
+
addToActiveUpdateBehaviors(behavior: UpdateBehavior<DataType, ParticleType>): void;
|
|
253
|
+
/**
|
|
254
|
+
* Removes a behavior from the active init behaviors.
|
|
255
|
+
* @param behavior Behavior to remove.
|
|
256
|
+
*/
|
|
257
|
+
removeFromActiveInitBehaviors(behavior: InitBehavior<DataType, ParticleType>): void;
|
|
258
|
+
/**
|
|
259
|
+
* Removes a behavior from the active update behaviors.
|
|
260
|
+
* @param behavior Behavior to remove.
|
|
261
|
+
*/
|
|
262
|
+
removeFromActiveUpdateBehaviors(behavior: UpdateBehavior<DataType, ParticleType>): void;
|
|
263
|
+
/**
|
|
264
|
+
* Updates the emitter.
|
|
265
|
+
* @param ticker Ticker instance.
|
|
266
|
+
*/
|
|
267
|
+
private update;
|
|
268
|
+
/**
|
|
269
|
+
* Recycles a particle back into the pool.
|
|
270
|
+
* @param particle Particle to recycle.
|
|
271
|
+
*/
|
|
272
|
+
private recycleParticle;
|
|
273
|
+
/**
|
|
274
|
+
* Parses a version string into major/minor/patch components.
|
|
275
|
+
* @param version Version string to parse.
|
|
276
|
+
* @returns Parsed version components.
|
|
277
|
+
*/
|
|
278
|
+
private parseVersionString;
|
|
279
|
+
/**
|
|
280
|
+
* Checks compatibility between the emitter version and config version.
|
|
281
|
+
* @param configVersion Config version to check.
|
|
282
|
+
*/
|
|
283
|
+
private checkCompatibility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G;IACI,wBAAwB,CAC3B,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,GAC/C,IAAI;IAiBP;;;OAGG;IACI,0BAA0B,CAC7B,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,GACjD,IAAI;IAiBP;;;OAGG;IACI,6BAA6B,CAChC,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,GAC/C,IAAI;IAQP;;;OAGG;IACI,+BAA+B,CAClC,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,GACjD,IAAI;IAQP;;;OAGG;IACH,OAAO,CAAC,MAAM;IA4Id;;;OAGG;IACH,OAAO,CAAC,eAAe;IAQvB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CA2B7B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AlphaBehaviorConfig } from './behavior/built-in/AlphaBehavior';
|
|
2
|
+
import { ColorBehaviorConfig } from './behavior/built-in/ColorBehavior';
|
|
3
|
+
import { MovementBehaviorConfig } from './behavior/built-in/MovementBehavior';
|
|
4
|
+
import { RotationBehaviorConfig } from './behavior/built-in/RotationBehavior';
|
|
5
|
+
import { ScaleBehaviorConfig } from './behavior/built-in/ScaleBehavior';
|
|
6
|
+
import { SpawnBehaviorConfig } from './behavior/built-in/SpawnBehavior';
|
|
7
|
+
import { TextureBehaviorConfig } from './behavior/built-in/TextureBehavior';
|
|
8
|
+
import { Ease } from './data/easing/Ease';
|
|
9
|
+
/**
|
|
10
|
+
* Type describing the configuration options for an Emitter.
|
|
11
|
+
* @group Emitter/
|
|
12
|
+
*/
|
|
13
|
+
export type EmitterConfig = {
|
|
14
|
+
/**
|
|
15
|
+
* Emitter version this config was made for.
|
|
16
|
+
*/
|
|
17
|
+
emitterVersion: string;
|
|
18
|
+
/**
|
|
19
|
+
* Minimum lifetime of particles emitted, in seconds.
|
|
20
|
+
*/
|
|
21
|
+
minParticleLifetime?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Maximum lifetime of particles emitted, in seconds.
|
|
24
|
+
*/
|
|
25
|
+
maxParticleLifetime?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Interval between spawn waves, in seconds.
|
|
28
|
+
*/
|
|
29
|
+
spawnInterval?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Chance of spawning particles each wave, between 0 and 1.
|
|
32
|
+
*/
|
|
33
|
+
spawnChance?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum number of particles allowed alive at once.
|
|
36
|
+
*/
|
|
37
|
+
maxParticles?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Whether new particles are added to the back of the particle list (behind other particles).
|
|
40
|
+
*/
|
|
41
|
+
addAtBack?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Number of particles to spawn each wave.
|
|
44
|
+
*/
|
|
45
|
+
particlesPerWave?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Easing applied to particle's lifetime.
|
|
48
|
+
*/
|
|
49
|
+
ease?: Ease;
|
|
50
|
+
/**
|
|
51
|
+
* Configuration for the AlphaBehavior.
|
|
52
|
+
*/
|
|
53
|
+
alphaBehavior?: AlphaBehaviorConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Configuration for the ColorBehavior.
|
|
56
|
+
*/
|
|
57
|
+
colorBehavior?: ColorBehaviorConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Configuration for the MovementBehavior.
|
|
60
|
+
*/
|
|
61
|
+
movementBehavior?: MovementBehaviorConfig;
|
|
62
|
+
/**
|
|
63
|
+
* Configuration for the RotationBehavior.
|
|
64
|
+
*/
|
|
65
|
+
rotationBehavior?: RotationBehaviorConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Configuration for the ScaleBehavior.
|
|
68
|
+
*/
|
|
69
|
+
scaleBehavior?: ScaleBehaviorConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for the SpawnBehavior.
|
|
72
|
+
*/
|
|
73
|
+
spawnBehavior?: SpawnBehaviorConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for the TextureBehavior.
|
|
76
|
+
*/
|
|
77
|
+
textureBehavior?: TextureBehaviorConfig;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=EmitterConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmitterConfig.d.ts","sourceRoot":"","sources":["../src/EmitterConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAEpC;;OAEG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;CAC3C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Emitter } from '../Emitter';
|
|
2
|
+
import { BaseParticleData, IEmitterParticle } from '../particle/EmitterParticle';
|
|
3
|
+
import { BehaviorOrder } from '../util/Types';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base for all behavior to build upon.
|
|
6
|
+
*
|
|
7
|
+
* This class provides the foundational structure and methods that all
|
|
8
|
+
* emitter behaviors must implement, ensuring consistency and interoperability.
|
|
9
|
+
*
|
|
10
|
+
* In addition to the core functionality, this class also defines interfaces
|
|
11
|
+
* for behaviors that initialize particles ({@link InitBehavior}) and
|
|
12
|
+
* those that update particles ({@link UpdateBehavior}) during the emitter's update cycle.
|
|
13
|
+
* @template ConfigType Type describing the configuration object for this behavior.
|
|
14
|
+
* @template DataType Type describing the data object stored on particles.
|
|
15
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
16
|
+
* @group Behavior/EmitterBehavior
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class EmitterBehavior<ConfigType, DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> {
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
protected readonly _emitter: Emitter<DataType, ParticleType>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of the behavior.
|
|
25
|
+
* @param emitter Emitter instance this behavior belongs to.
|
|
26
|
+
*/
|
|
27
|
+
constructor(emitter: Emitter<DataType, ParticleType>);
|
|
28
|
+
/**
|
|
29
|
+
* Defines at which step of the update cycle the behavior is applied.
|
|
30
|
+
*
|
|
31
|
+
* - `initial`: Earliest step, useful when other behaviors depend on this behavior.
|
|
32
|
+
* - `normal`: Default step for most behaviors.
|
|
33
|
+
* - `late`: Latest step, useful for behaviors that should override others or depend on their properties.
|
|
34
|
+
*/
|
|
35
|
+
abstract get updateOrder(): BehaviorOrder;
|
|
36
|
+
/**
|
|
37
|
+
* Reset the behavior and apply the provided configuration.
|
|
38
|
+
* @param config Behavior configuration.
|
|
39
|
+
*/
|
|
40
|
+
applyConfig(config: ConfigType): void;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve the current behavior properties as a configuration object.
|
|
43
|
+
* If the behavior is inactive, `undefined` is returned.
|
|
44
|
+
* @returns Behavior configuration object or `undefined` if inactive.
|
|
45
|
+
*/
|
|
46
|
+
abstract getConfig(): ConfigType | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Reset the behavior to its default state.
|
|
49
|
+
*/
|
|
50
|
+
protected abstract reset(): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Interface defining behaviors which update particles when they are first created.
|
|
54
|
+
* @template DataType Type describing the data object stored on particles.
|
|
55
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
56
|
+
* @group Behavior/EmitterBehavior/
|
|
57
|
+
*/
|
|
58
|
+
export interface InitBehavior<DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> extends EmitterBehavior<unknown, DataType, ParticleType> {
|
|
59
|
+
/**
|
|
60
|
+
* Initialize the particle.
|
|
61
|
+
* @param particle Particle to initialize.
|
|
62
|
+
*/
|
|
63
|
+
init(particle: ParticleType): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Interface defining behaviors which update particles on each update cycle.
|
|
67
|
+
* @template DataType Type describing the data object stored on particles.
|
|
68
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
69
|
+
* @group Behavior/EmitterBehavior/
|
|
70
|
+
*/
|
|
71
|
+
export interface UpdateBehavior<DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> extends EmitterBehavior<unknown, DataType, ParticleType> {
|
|
72
|
+
/**
|
|
73
|
+
* Updates the particle.
|
|
74
|
+
* @param particle Particle to update.
|
|
75
|
+
* @param deltaTime Time elapsed since the last update, in seconds.
|
|
76
|
+
*/
|
|
77
|
+
update(particle: ParticleType, deltaTime: number): void;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=EmitterBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmitterBehavior.d.ts","sourceRoot":"","sources":["../../src/behavior/EmitterBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AACH,8BAAsB,eAAe,CACjC,UAAU,EACV,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,EACpD,YAAY,SAAS,gBAAgB,CAAC,QAAQ,CAAC,GAC3C,gBAAgB,CAAC,QAAQ,CAAC;IAE9B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAE7D;;;OAGG;gBACS,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC;IAIpD;;;;;;OAMG;IACH,aAAoB,WAAW,IAAI,aAAa,CAAC;IAEjD;;;OAGG;IACI,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAM5C;;;;OAIG;aACa,SAAS,IAAI,UAAU,GAAG,SAAS;IAEnD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CACzB,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,EACpD,YAAY,SAAS,gBAAgB,CAAC,QAAQ,CAAC,GAC3C,gBAAgB,CAAC,QAAQ,CAAC,CAChC,SAAQ,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC;IACtD;;;OAGG;IACH,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;CACtC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAC3B,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,EACpD,YAAY,SAAS,gBAAgB,CAAC,QAAQ,CAAC,GAC3C,gBAAgB,CAAC,QAAQ,CAAC,CAChC,SAAQ,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC;IACtD;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3D"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { NumberList } from '../../data/list/NumberList';
|
|
2
|
+
import { Emitter } from '../../Emitter';
|
|
3
|
+
import { BaseParticleData, IEmitterParticle } from '../../particle/EmitterParticle';
|
|
4
|
+
import { BehaviorOrder, BehaviorSingleListConfig, BehaviorStaticConfig } from '../../util/Types';
|
|
5
|
+
import { EmitterBehavior, InitBehavior, UpdateBehavior } from '../EmitterBehavior';
|
|
6
|
+
/**
|
|
7
|
+
* Type defining the configuration for AlphaBehavior.
|
|
8
|
+
*/
|
|
9
|
+
export type AlphaBehaviorConfig = BehaviorStaticConfig<number> | BehaviorSingleListConfig<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Behavior used to control the transparency of particles over their lifetime.
|
|
12
|
+
*
|
|
13
|
+
* Behavior supports three modes, a `static` mode where a single value is applied to all particles,
|
|
14
|
+
* a `list` mode where values are interpolated over the particle's lifetime based on a provided list,
|
|
15
|
+
* and a `random` mode where a random value from the list is applied to the particle upon initialization.
|
|
16
|
+
* @see {@link BehaviorStaticConfig} for static configuration options.
|
|
17
|
+
* @see {@link BehaviorSingleListConfig} for list configuration options.
|
|
18
|
+
* @template DataType Type describing the data object stored on particles.
|
|
19
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
20
|
+
* @group Behavior/AlphaBehavior
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Apply a static alpha value of 0.5 to all particles.
|
|
24
|
+
* alphaBehavior.applyConfig({
|
|
25
|
+
* value: 0.5
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Interpolate particle alpha from 0.0 to 1.0 over lifetime.
|
|
29
|
+
* alphaBehavior.applyConfig({
|
|
30
|
+
* listData: [
|
|
31
|
+
* { time: 0.0, value: 0.0 },
|
|
32
|
+
* { time: 1.0, value: 1.0 }
|
|
33
|
+
* ],
|
|
34
|
+
* mode: "list"
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Assign a random alpha value between 0.2 and 0.8.
|
|
38
|
+
* alphaBehavior.applyConfig({
|
|
39
|
+
* listData: [
|
|
40
|
+
* { time: 0.0, value: 0.2 },
|
|
41
|
+
* { time: 1.0, value: 0.8 }
|
|
42
|
+
* ],
|
|
43
|
+
* mode: "random"
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class AlphaBehavior<DataType extends BaseParticleData = BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> extends EmitterBehavior<AlphaBehaviorConfig, DataType, ParticleType> implements InitBehavior<DataType, ParticleType>, UpdateBehavior<DataType, ParticleType> {
|
|
48
|
+
private readonly _list;
|
|
49
|
+
private _staticValue;
|
|
50
|
+
private _mode;
|
|
51
|
+
/**
|
|
52
|
+
* Creates new instance of AlphaBehavior.
|
|
53
|
+
* @param emitter Emitter instance this behavior belongs to.
|
|
54
|
+
*/
|
|
55
|
+
constructor(emitter: Emitter<DataType, ParticleType>);
|
|
56
|
+
/**
|
|
57
|
+
* @inheritdoc
|
|
58
|
+
*/
|
|
59
|
+
get updateOrder(): BehaviorOrder;
|
|
60
|
+
/**
|
|
61
|
+
* Number list used to interpolate alpha values over particle lifetime.
|
|
62
|
+
*
|
|
63
|
+
* A behavior will always have a list, even when not using list-based configuration,
|
|
64
|
+
* but the list might not be initialized and will be empty in that case.
|
|
65
|
+
*/
|
|
66
|
+
get list(): NumberList;
|
|
67
|
+
/**
|
|
68
|
+
* Mode currently used by the behavior.
|
|
69
|
+
*/
|
|
70
|
+
get mode(): "static" | "list" | "random";
|
|
71
|
+
set mode(value: "static" | "list" | "random");
|
|
72
|
+
/**
|
|
73
|
+
* Alpha value applied to all particles in `static` mode.
|
|
74
|
+
*/
|
|
75
|
+
get staticValue(): number;
|
|
76
|
+
set staticValue(value: number);
|
|
77
|
+
/**
|
|
78
|
+
* @inheritdoc
|
|
79
|
+
*/
|
|
80
|
+
applyConfig(config: AlphaBehaviorConfig): void;
|
|
81
|
+
/**
|
|
82
|
+
* @inheritdoc
|
|
83
|
+
*/
|
|
84
|
+
getConfig(): AlphaBehaviorConfig | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* @inheritdoc
|
|
87
|
+
*/
|
|
88
|
+
init(particle: ParticleType): void;
|
|
89
|
+
/**
|
|
90
|
+
* @inheritdoc
|
|
91
|
+
*/
|
|
92
|
+
update(particle: ParticleType): void;
|
|
93
|
+
/**
|
|
94
|
+
* @inheritdoc
|
|
95
|
+
*/
|
|
96
|
+
protected reset(): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=AlphaBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlphaBehavior.d.ts","sourceRo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,MAAM,GAAG,QAAQ,EAQlD;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;IACD,IAAW,WAAW,CAAC,KAAK,EAAE,MAAM,EAEnC;IAED;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAqBrD;;OAEG;IACI,SAAS,IAAI,mBAAmB,GAAG,SAAS;IAwBnD;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAczC;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI3C;;OAEG;IACH,SAAS,CAAC,KAAK,IAAI,IAAI;CAO1B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ColorList } from '../../data/list/ColorList';
|
|
2
|
+
import { Emitter } from '../../Emitter';
|
|
3
|
+
import { BaseParticleData, IEmitterParticle } from '../../particle/EmitterParticle';
|
|
4
|
+
import { BehaviorOrder, BehaviorSingleListConfig, BehaviorStaticConfig } from '../../util/Types';
|
|
5
|
+
import { EmitterBehavior, InitBehavior, UpdateBehavior } from '../EmitterBehavior';
|
|
6
|
+
/**
|
|
7
|
+
* Type defining the configuration for ColorBehavior.
|
|
8
|
+
*/
|
|
9
|
+
export type ColorBehaviorConfig = BehaviorStaticConfig<string> | BehaviorSingleListConfig<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Behavior used to control the color tint of particles over their lifetime.
|
|
12
|
+
*
|
|
13
|
+
* Behavior supports three modes, a `static` mode where a single value is applied to all particles,
|
|
14
|
+
* a `list` mode where values are interpolated over the particle's lifetime based on a provided list,
|
|
15
|
+
* and a `random` mode where a random value from the list is applied to the particle upon initialization.
|
|
16
|
+
* @see {@link BehaviorStaticConfig} for static configuration options.
|
|
17
|
+
* @see {@link BehaviorSingleListConfig} for list configuration options.
|
|
18
|
+
* @template DataType Type describing the data object stored on particles.
|
|
19
|
+
* @template ParticleType Type describing the particle used within the emitter.
|
|
20
|
+
* @group Behavior/ColorBehavior
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Apply a static tint to all particles.
|
|
24
|
+
* alphaBehavior.applyConfig({
|
|
25
|
+
* value: "#ff00ff"
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Interpolate particle tint from white to black over lifetime.
|
|
29
|
+
* alphaBehavior.applyConfig({
|
|
30
|
+
* listData: [
|
|
31
|
+
* { time: 0.0, value: "#ffffff" },
|
|
32
|
+
* { time: 1.0, value: "#000000" }
|
|
33
|
+
* ],
|
|
34
|
+
* mode: "list"
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Assign a random tint value between the two stops.
|
|
38
|
+
* alphaBehavior.applyConfig({
|
|
39
|
+
* listData: [
|
|
40
|
+
* { time: 0.0, value: "#ff00ff" },
|
|
41
|
+
* { time: 1.0, value: "#00ff00" }
|
|
42
|
+
* ],
|
|
43
|
+
* mode: "random"
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class ColorBehavior<DataType extends BaseParticleData, ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>> extends EmitterBehavior<ColorBehaviorConfig, DataType, ParticleType> implements InitBehavior<DataType, ParticleType>, UpdateBehavior<DataType, ParticleType> {
|
|
48
|
+
private readonly _list;
|
|
49
|
+
private _staticValue;
|
|
50
|
+
private _mode;
|
|
51
|
+
/**
|
|
52
|
+
* Creates new instance of ColorBehavior.
|
|
53
|
+
* @param emitter Emitter instance this behavior belongs to.
|
|
54
|
+
*/
|
|
55
|
+
constructor(emitter: Emitter<DataType, ParticleType>);
|
|
56
|
+
/**
|
|
57
|
+
* @inheritdoc
|
|
58
|
+
*/
|
|
59
|
+
get updateOrder(): BehaviorOrder;
|
|
60
|
+
/**
|
|
61
|
+
* Color list used to interpolate tint values over particle lifetime.
|
|
62
|
+
*
|
|
63
|
+
* A behavior will always have a list, even when not using list-based configuration,
|
|
64
|
+
* but the list might not be initialized and will be empty in that case.
|
|
65
|
+
*/
|
|
66
|
+
get list(): ColorList;
|
|
67
|
+
/**
|
|
68
|
+
* Mode currently used by the behavior.
|
|
69
|
+
*/
|
|
70
|
+
get mode(): "static" | "list" | "random";
|
|
71
|
+
set mode(value: "static" | "list" | "random");
|
|
72
|
+
/**
|
|
73
|
+
* Tint value applied to all particles in `static` mode.
|
|
74
|
+
*/
|
|
75
|
+
get staticValue(): string;
|
|
76
|
+
set staticValue(value: string);
|
|
77
|
+
/**
|
|
78
|
+
* @inheritdoc
|
|
79
|
+
*/
|
|
80
|
+
applyConfig(config: ColorBehaviorConfig): void;
|
|
81
|
+
/**
|
|
82
|
+
* @inheritdoc
|
|
83
|
+
*/
|
|
84
|
+
getConfig(): ColorBehaviorConfig | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* @inheritdoc
|
|
87
|
+
*/
|
|
88
|
+
init(particle: ParticleType): void;
|
|
89
|
+
/**
|
|
90
|
+
* @inheritdoc
|
|
91
|
+
*/
|
|
92
|
+
update(particle: ParticleType): void;
|
|
93
|
+
/**
|
|
94
|
+
* @inheritdoc
|
|
95
|
+
*/
|
|
96
|
+
protected reset(): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=ColorBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorBehavior.d.ts","sourceRoot":"","sources":["../../../src/behavior/built-in/ColorBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACH,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,eAAe,EACf,YAAY,EACZ,cAAc,EACjB,MAAM,oBAAoB,CAAC;AAE5B;;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