custom-pixi-particles 7.1.1 → 7.1.2
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/index.d.ts +15 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/Model.d.ts +32 -0
- package/dist/lib/Model.js +44 -0
- package/dist/lib/Model.js.map +1 -0
- package/dist/lib/Particle.d.ts +234 -0
- package/dist/lib/Particle.js +201 -0
- package/dist/lib/Particle.js.map +1 -0
- package/dist/lib/ParticlePool.d.ts +37 -0
- package/dist/lib/ParticlePool.js +56 -0
- package/dist/lib/ParticlePool.js.map +1 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +61 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +118 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +42 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +78 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/Behaviour.d.ts +33 -0
- package/dist/lib/behaviour/Behaviour.js +45 -0
- package/dist/lib/behaviour/Behaviour.js.map +1 -0
- package/dist/lib/behaviour/BehaviourNames.d.ts +22 -0
- package/dist/lib/behaviour/BehaviourNames.js +23 -0
- package/dist/lib/behaviour/BehaviourNames.js.map +1 -0
- package/dist/lib/behaviour/CollisionBehaviour.d.ts +86 -0
- package/dist/lib/behaviour/CollisionBehaviour.js +140 -0
- package/dist/lib/behaviour/CollisionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/ColorBehaviour.d.ts +67 -0
- package/dist/lib/behaviour/ColorBehaviour.js +193 -0
- package/dist/lib/behaviour/ColorBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +52 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +105 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +69 -0
- package/dist/lib/behaviour/EmitterBehaviours.js +116 -0
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +53 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js +80 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +1 -0
- package/dist/lib/behaviour/GroupingBehaviour.d.ts +57 -0
- package/dist/lib/behaviour/GroupingBehaviour.js +143 -0
- package/dist/lib/behaviour/GroupingBehaviour.js.map +1 -0
- package/dist/lib/behaviour/LifeBehaviour.d.ts +47 -0
- package/dist/lib/behaviour/LifeBehaviour.js +65 -0
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/LightEffectBehaviour.d.ts +59 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js +94 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js.map +1 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.d.ts +28 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js +50 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/PositionBehaviour.d.ts +164 -0
- package/dist/lib/behaviour/PositionBehaviour.js +484 -0
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/RotationBehaviour.d.ts +59 -0
- package/dist/lib/behaviour/RotationBehaviour.js +100 -0
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SizeBehaviour.d.ts +61 -0
- package/dist/lib/behaviour/SizeBehaviour.js +156 -0
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +58 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js +132 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SpawnBehaviour.d.ts +89 -0
- package/dist/lib/behaviour/SpawnBehaviour.js +705 -0
- package/dist/lib/behaviour/SpawnBehaviour.js.map +1 -0
- package/dist/lib/behaviour/StretchBehaviour.d.ts +30 -0
- package/dist/lib/behaviour/StretchBehaviour.js +59 -0
- package/dist/lib/behaviour/StretchBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TemperatureBehaviour.d.ts +47 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js +64 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TimelineBehaviour.d.ts +73 -0
- package/dist/lib/behaviour/TimelineBehaviour.js +100 -0
- package/dist/lib/behaviour/TimelineBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +73 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.js +133 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -0
- package/dist/lib/behaviour/index.d.ts +23 -0
- package/dist/lib/behaviour/index.js +24 -0
- package/dist/lib/behaviour/index.js.map +1 -0
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +19 -0
- package/dist/lib/customPixiParticlesSettingsInterface.js +2 -0
- package/dist/lib/customPixiParticlesSettingsInterface.js.map +1 -0
- package/dist/lib/emission/AbstractEmission.d.ts +30 -0
- package/dist/lib/emission/AbstractEmission.js +39 -0
- package/dist/lib/emission/AbstractEmission.js.map +1 -0
- package/dist/lib/emission/EmissionTypes.d.ts +6 -0
- package/dist/lib/emission/EmissionTypes.js +6 -0
- package/dist/lib/emission/EmissionTypes.js.map +1 -0
- package/dist/lib/emission/RandomEmission.d.ts +44 -0
- package/dist/lib/emission/RandomEmission.js +66 -0
- package/dist/lib/emission/RandomEmission.js.map +1 -0
- package/dist/lib/emission/StandardEmission.d.ts +62 -0
- package/dist/lib/emission/StandardEmission.js +87 -0
- package/dist/lib/emission/StandardEmission.js.map +1 -0
- package/dist/lib/emission/UniformEmission.d.ts +56 -0
- package/dist/lib/emission/UniformEmission.js +83 -0
- package/dist/lib/emission/UniformEmission.js.map +1 -0
- package/dist/lib/emission/index.d.ts +6 -0
- package/dist/lib/emission/index.js +7 -0
- package/dist/lib/emission/index.js.map +1 -0
- package/dist/lib/emitter/Duration.d.ts +27 -0
- package/dist/lib/emitter/Duration.js +41 -0
- package/dist/lib/emitter/Duration.js.map +1 -0
- package/dist/lib/emitter/Emitter.d.ts +116 -0
- package/dist/lib/emitter/Emitter.js +240 -0
- package/dist/lib/emitter/Emitter.js.map +1 -0
- package/dist/lib/emitter/index.d.ts +3 -0
- package/dist/lib/emitter/index.js +4 -0
- package/dist/lib/emitter/index.js.map +1 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.js +21 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/parser/BehaviourParser.d.ts +21 -0
- package/dist/lib/parser/BehaviourParser.js +72 -0
- package/dist/lib/parser/BehaviourParser.js.map +1 -0
- package/dist/lib/parser/CompatibilityHelper.d.ts +12 -0
- package/dist/lib/parser/CompatibilityHelper.js +19 -0
- package/dist/lib/parser/CompatibilityHelper.js.map +1 -0
- package/dist/lib/parser/EmitControllerParser.d.ts +27 -0
- package/dist/lib/parser/EmitControllerParser.js +39 -0
- package/dist/lib/parser/EmitControllerParser.js.map +1 -0
- package/dist/lib/parser/EmitterParser.d.ts +67 -0
- package/dist/lib/parser/EmitterParser.js +168 -0
- package/dist/lib/parser/EmitterParser.js.map +1 -0
- package/dist/lib/parser/index.d.ts +5 -0
- package/dist/lib/parser/index.js +6 -0
- package/dist/lib/parser/index.js.map +1 -0
- package/dist/lib/pixi/Renderer.d.ts +125 -0
- package/dist/lib/pixi/Renderer.js +566 -0
- package/dist/lib/pixi/Renderer.js.map +1 -0
- package/dist/lib/pixi/TestRenderer.d.ts +125 -0
- package/dist/lib/pixi/TestRenderer.js +560 -0
- package/dist/lib/pixi/TestRenderer.js.map +1 -0
- package/dist/lib/util/Color.d.ts +133 -0
- package/dist/lib/util/Color.js +173 -0
- package/dist/lib/util/Color.js.map +1 -0
- package/dist/lib/util/List.d.ts +49 -0
- package/dist/lib/util/List.js +87 -0
- package/dist/lib/util/List.js.map +1 -0
- package/dist/lib/util/MinMax.d.ts +34 -0
- package/dist/lib/util/MinMax.js +46 -0
- package/dist/lib/util/MinMax.js.map +1 -0
- package/dist/lib/util/Point.d.ts +34 -0
- package/dist/lib/util/Point.js +46 -0
- package/dist/lib/util/Point.js.map +1 -0
- package/dist/lib/util/Random.d.ts +24 -0
- package/dist/lib/util/Random.js +30 -0
- package/dist/lib/util/Random.js.map +1 -0
- package/dist/lib/util/ThereBack.d.ts +14 -0
- package/dist/lib/util/ThereBack.js +23 -0
- package/dist/lib/util/ThereBack.js.map +1 -0
- package/dist/lib/util/index.d.ts +5 -0
- package/dist/lib/util/index.js +6 -0
- package/dist/lib/util/index.js.map +1 -0
- package/dist/lib/util/maths.d.ts +10 -0
- package/dist/lib/util/maths.js +13 -0
- package/dist/lib/util/maths.js.map +1 -0
- package/dist/lib/util/turbulencePool.d.ts +4 -0
- package/dist/lib/util/turbulencePool.js +7 -0
- package/dist/lib/util/turbulencePool.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Renderer from './lib/pixi/Renderer';
|
|
2
|
+
import { ICustomPixiParticlesSettings } from './lib/customPixiParticlesSettingsInterface';
|
|
3
|
+
import TestRenderer from './lib/pixi/TestRenderer';
|
|
4
|
+
/**
|
|
5
|
+
* Constructs a renderer for custom pixi particles
|
|
6
|
+
* @class Renderer
|
|
7
|
+
* @param {ICustomPixiParticlesSettings} settings The settings for the renderer
|
|
8
|
+
*/
|
|
9
|
+
declare const customPixiParticles: {
|
|
10
|
+
create(settings: ICustomPixiParticlesSettings): Renderer;
|
|
11
|
+
};
|
|
12
|
+
declare const _customPixiParticlesEditorOnly: {
|
|
13
|
+
create(settings: ICustomPixiParticlesSettings): TestRenderer;
|
|
14
|
+
};
|
|
15
|
+
export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ICustomPixiParticlesSettings };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Renderer from './lib/pixi/Renderer';
|
|
2
|
+
import TestRenderer from './lib/pixi/TestRenderer';
|
|
3
|
+
/**
|
|
4
|
+
* Constructs a renderer for custom pixi particles
|
|
5
|
+
* @class Renderer
|
|
6
|
+
* @param {ICustomPixiParticlesSettings} settings The settings for the renderer
|
|
7
|
+
*/
|
|
8
|
+
const customPixiParticles = {
|
|
9
|
+
create(settings) {
|
|
10
|
+
const { textures, emitterConfig, animatedSpriteZeroPad = 2, animatedSpriteIndexToStart = 0, finishingTextures = [], vertices = true, position = true, rotation = true, uvs = true, tint = true, maxParticles = 10000, maxFPS = 60, minFPS = 30, tickerSpeed = 0.02, } = settings;
|
|
11
|
+
return new Renderer({
|
|
12
|
+
textures,
|
|
13
|
+
animatedSpriteZeroPad,
|
|
14
|
+
animatedSpriteIndexToStart,
|
|
15
|
+
emitterConfig,
|
|
16
|
+
finishingTextures,
|
|
17
|
+
vertices,
|
|
18
|
+
position,
|
|
19
|
+
rotation,
|
|
20
|
+
uvs,
|
|
21
|
+
tint,
|
|
22
|
+
maxParticles,
|
|
23
|
+
maxFPS,
|
|
24
|
+
minFPS,
|
|
25
|
+
tickerSpeed,
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const _customPixiParticlesEditorOnly = {
|
|
30
|
+
create(settings) {
|
|
31
|
+
const { textures, emitterConfig, animatedSpriteZeroPad = 2, animatedSpriteIndexToStart = 0, finishingTextures = [], maxFPS = 60, minFPS = 60, tickerSpeed = 0.02, } = settings;
|
|
32
|
+
return new TestRenderer({
|
|
33
|
+
textures,
|
|
34
|
+
animatedSpriteZeroPad,
|
|
35
|
+
animatedSpriteIndexToStart,
|
|
36
|
+
emitterConfig,
|
|
37
|
+
finishingTextures,
|
|
38
|
+
maxFPS,
|
|
39
|
+
minFPS,
|
|
40
|
+
tickerSpeed,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly };
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAE1C,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAElD;;;;GAIG;AACH,MAAM,mBAAmB,GAAG;IAC1B,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,GAAG,GAAG,IAAI,EACV,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,QAAQ,CAAC;YAClB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,MAAM,8BAA8B,GAAG;IACrC,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,YAAY,CAAC;YACtB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,8BAA8B,EAAgC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default class Model {
|
|
2
|
+
/**
|
|
3
|
+
* Boolean value indicating whether warping is enabled
|
|
4
|
+
*/
|
|
5
|
+
warp: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The Z position of the camera
|
|
8
|
+
*/
|
|
9
|
+
cameraZ: number;
|
|
10
|
+
/**
|
|
11
|
+
* The conversion rate for cameraZ
|
|
12
|
+
*/
|
|
13
|
+
cameraZConverter: number;
|
|
14
|
+
/**
|
|
15
|
+
* The speed of warp
|
|
16
|
+
*/
|
|
17
|
+
warpSpeed: number;
|
|
18
|
+
/**
|
|
19
|
+
* The base speed of warp
|
|
20
|
+
*/
|
|
21
|
+
warpBaseSpeed: number;
|
|
22
|
+
/**
|
|
23
|
+
* Update the model with the behaviour object
|
|
24
|
+
* @param {Object} behaviour - The behaviour object
|
|
25
|
+
*/
|
|
26
|
+
update(behaviour: any): void;
|
|
27
|
+
/**
|
|
28
|
+
* Update the camera position based on the delta time
|
|
29
|
+
* @param {number} deltaTime - The delta time
|
|
30
|
+
*/
|
|
31
|
+
updateCamera(deltaTime: number): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default class Model {
|
|
2
|
+
constructor() {
|
|
3
|
+
/**
|
|
4
|
+
* Boolean value indicating whether warping is enabled
|
|
5
|
+
*/
|
|
6
|
+
this.warp = false;
|
|
7
|
+
/**
|
|
8
|
+
* The Z position of the camera
|
|
9
|
+
*/
|
|
10
|
+
this.cameraZ = 0;
|
|
11
|
+
/**
|
|
12
|
+
* The conversion rate for cameraZ
|
|
13
|
+
*/
|
|
14
|
+
this.cameraZConverter = 0;
|
|
15
|
+
/**
|
|
16
|
+
* The speed of warp
|
|
17
|
+
*/
|
|
18
|
+
this.warpSpeed = 0;
|
|
19
|
+
/**
|
|
20
|
+
* The base speed of warp
|
|
21
|
+
*/
|
|
22
|
+
this.warpBaseSpeed = 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Update the model with the behaviour object
|
|
26
|
+
* @param {Object} behaviour - The behaviour object
|
|
27
|
+
*/
|
|
28
|
+
update(behaviour) {
|
|
29
|
+
this.warp = behaviour.warp || false;
|
|
30
|
+
this.cameraZConverter = behaviour.cameraZConverter;
|
|
31
|
+
this.warpSpeed = behaviour.warpSpeed;
|
|
32
|
+
this.warpBaseSpeed = behaviour.warpBaseSpeed;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Update the camera position based on the delta time
|
|
36
|
+
* @param {number} deltaTime - The delta time
|
|
37
|
+
*/
|
|
38
|
+
updateCamera(deltaTime) {
|
|
39
|
+
if (!this.warp)
|
|
40
|
+
return;
|
|
41
|
+
this.cameraZ += deltaTime * this.cameraZConverter * this.warpSpeed * this.warpBaseSpeed;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=Model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Model.js","sourceRoot":"","sources":["../../src/lib/Model.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,KAAK;IAA1B;QACE;;WAEG;QACH,SAAI,GAAY,KAAK,CAAA;QAErB;;WAEG;QACH,YAAO,GAAW,CAAC,CAAA;QAEnB;;WAEG;QACH,qBAAgB,GAAW,CAAC,CAAA;QAE5B;;WAEG;QACH,cAAS,GAAW,CAAC,CAAA;QAErB;;WAEG;QACH,kBAAa,GAAW,CAAC,CAAA;IAqB3B,CAAC;IAnBC;;;OAGG;IACH,MAAM,CAAC,SAAc;QACnB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,KAAK,CAAA;QACnC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAA;QAClD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAA;QACpC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAA;IAC9C,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAM;QACtB,IAAI,CAAC,OAAO,IAAI,SAAS,GAAG,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,aAAa,CAAA;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Sprite } from 'pixi.js';
|
|
2
|
+
import { Color, Point } from './util';
|
|
3
|
+
import ThereBack from './util/ThereBack';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a particle object used in particle system simulations
|
|
6
|
+
*/
|
|
7
|
+
export default class Particle {
|
|
8
|
+
static _UID: {
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
next: Particle | null;
|
|
12
|
+
prev: Particle | null;
|
|
13
|
+
/**
|
|
14
|
+
* Stores the unique ID of the particle
|
|
15
|
+
*/
|
|
16
|
+
uid: number;
|
|
17
|
+
/**
|
|
18
|
+
* Stores the movement of the particle
|
|
19
|
+
*/
|
|
20
|
+
movement: Point;
|
|
21
|
+
/**
|
|
22
|
+
* Stores the acceleration of the particle
|
|
23
|
+
*/
|
|
24
|
+
acceleration: Point;
|
|
25
|
+
/**
|
|
26
|
+
* Stores the velocity of the particle
|
|
27
|
+
*/
|
|
28
|
+
velocity: Point;
|
|
29
|
+
/**
|
|
30
|
+
* Stores the size of the particle
|
|
31
|
+
*/
|
|
32
|
+
size: Point;
|
|
33
|
+
/**
|
|
34
|
+
* Stores the starting size of the particle
|
|
35
|
+
*/
|
|
36
|
+
sizeStart: Point;
|
|
37
|
+
/**
|
|
38
|
+
* Stores the starting warp size of the particle
|
|
39
|
+
*/
|
|
40
|
+
warpSizeStart: Point;
|
|
41
|
+
/**
|
|
42
|
+
* Stores the ending size of the particle
|
|
43
|
+
*/
|
|
44
|
+
sizeEnd: Point;
|
|
45
|
+
/**
|
|
46
|
+
* Stores the x value of the particle for sin wave
|
|
47
|
+
*/
|
|
48
|
+
sinXVal: Point;
|
|
49
|
+
/**
|
|
50
|
+
* Stores the y value of the particle for sin wave
|
|
51
|
+
*/
|
|
52
|
+
sinYVal: Point;
|
|
53
|
+
/**
|
|
54
|
+
* Stores the color of the particle
|
|
55
|
+
*/
|
|
56
|
+
color: Color;
|
|
57
|
+
/**
|
|
58
|
+
* Stores the starting color of the particle
|
|
59
|
+
*/
|
|
60
|
+
colorStart: Color;
|
|
61
|
+
/**
|
|
62
|
+
* Stores the ending color of the particle
|
|
63
|
+
*/
|
|
64
|
+
colorEnd: Color;
|
|
65
|
+
superColorAlphaEnd: number;
|
|
66
|
+
/**
|
|
67
|
+
* Stores the maximum life time of the particle
|
|
68
|
+
*/
|
|
69
|
+
maxLifeTime: number;
|
|
70
|
+
/**
|
|
71
|
+
* Stores the current life time of the particle
|
|
72
|
+
*/
|
|
73
|
+
lifeTime: number;
|
|
74
|
+
/**
|
|
75
|
+
* Stores the current life progress of the particle
|
|
76
|
+
*/
|
|
77
|
+
lifeProgress: number;
|
|
78
|
+
/**
|
|
79
|
+
* Stores the x position of the particle
|
|
80
|
+
*/
|
|
81
|
+
x: number;
|
|
82
|
+
/**
|
|
83
|
+
* Stores the y position of the particle
|
|
84
|
+
*/
|
|
85
|
+
y: number;
|
|
86
|
+
/**
|
|
87
|
+
* Stores the z position of the particle
|
|
88
|
+
*/
|
|
89
|
+
z: number;
|
|
90
|
+
/**
|
|
91
|
+
* Stores the velocity angle of the particle
|
|
92
|
+
*/
|
|
93
|
+
velocityAngle: number;
|
|
94
|
+
/**
|
|
95
|
+
* Stores the radians per second of the particle
|
|
96
|
+
*/
|
|
97
|
+
radiansPerSecond: number;
|
|
98
|
+
/**
|
|
99
|
+
* Stores the radius of the particle
|
|
100
|
+
*/
|
|
101
|
+
radius: number;
|
|
102
|
+
radiusX: number;
|
|
103
|
+
radiusY: number;
|
|
104
|
+
/**
|
|
105
|
+
* Stores the starting radius of the particle
|
|
106
|
+
*/
|
|
107
|
+
radiusStart: number;
|
|
108
|
+
/**
|
|
109
|
+
* Stores the ending radius of the particle
|
|
110
|
+
*/
|
|
111
|
+
radiusEnd: number;
|
|
112
|
+
/**
|
|
113
|
+
* Stores the cosine of the direction of the particle
|
|
114
|
+
*/
|
|
115
|
+
directionCos: number;
|
|
116
|
+
/**
|
|
117
|
+
* Stores the sine of the direction of the particle
|
|
118
|
+
*/
|
|
119
|
+
directionSin: number;
|
|
120
|
+
/**
|
|
121
|
+
* Stores the rotation of the particle
|
|
122
|
+
*/
|
|
123
|
+
rotation: number;
|
|
124
|
+
/**
|
|
125
|
+
* Stores the rotation delta of the particle
|
|
126
|
+
*/
|
|
127
|
+
rotationDelta: number;
|
|
128
|
+
/**
|
|
129
|
+
* Stores the angle of the particle
|
|
130
|
+
*/
|
|
131
|
+
angle: number;
|
|
132
|
+
/**
|
|
133
|
+
* Stores the sprite of the particle
|
|
134
|
+
*/
|
|
135
|
+
sprite: Sprite;
|
|
136
|
+
/**
|
|
137
|
+
* Stores whether the vortices are shown
|
|
138
|
+
*/
|
|
139
|
+
showVortices: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Stores whether the turbulence is enabled
|
|
142
|
+
*/
|
|
143
|
+
turbulence: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Stores the finishing texture of the particle
|
|
146
|
+
*/
|
|
147
|
+
finishingTexture: number;
|
|
148
|
+
/**
|
|
149
|
+
* Stores the camera z position of the particle
|
|
150
|
+
*/
|
|
151
|
+
cameraZ: number;
|
|
152
|
+
/**
|
|
153
|
+
* Stores the camera z position converter of the particle
|
|
154
|
+
*/
|
|
155
|
+
cameraZConverter: number;
|
|
156
|
+
/**
|
|
157
|
+
* Stores the warp speed of the particle
|
|
158
|
+
*/
|
|
159
|
+
warpSpeed: number;
|
|
160
|
+
/**
|
|
161
|
+
* Stores the warp base speed of the particle
|
|
162
|
+
*/
|
|
163
|
+
warpBaseSpeed: number;
|
|
164
|
+
/**
|
|
165
|
+
* Stores the warp field of view of the particle
|
|
166
|
+
*/
|
|
167
|
+
warpFov: number;
|
|
168
|
+
/**
|
|
169
|
+
* Stores the warp stretch of the particle
|
|
170
|
+
*/
|
|
171
|
+
warpStretch: number;
|
|
172
|
+
skipPositionBehaviour: boolean;
|
|
173
|
+
skipAngularVelocityBehaviour: boolean;
|
|
174
|
+
skipColorBehaviour: boolean;
|
|
175
|
+
skipEmitDirectionBehaviour: boolean;
|
|
176
|
+
skipRotationBehaviour: boolean;
|
|
177
|
+
skipSizeBehaviour: boolean;
|
|
178
|
+
skipAttractionRepulsionBehaviour: boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Stores the warp distance scale converter of the particle
|
|
181
|
+
*/
|
|
182
|
+
warpDistanceScaleConverter: number;
|
|
183
|
+
sizeDifference: {
|
|
184
|
+
x: number;
|
|
185
|
+
y: number;
|
|
186
|
+
};
|
|
187
|
+
fromAtoB: boolean;
|
|
188
|
+
fromAtoBTwoWays: boolean;
|
|
189
|
+
pointA: Point;
|
|
190
|
+
pointB: Point;
|
|
191
|
+
there: ThereBack;
|
|
192
|
+
back: ThereBack;
|
|
193
|
+
xStart: number;
|
|
194
|
+
yStart: number;
|
|
195
|
+
xTarget: number;
|
|
196
|
+
yTarget: number;
|
|
197
|
+
thereDuration: number;
|
|
198
|
+
backDuration: number;
|
|
199
|
+
progress: number;
|
|
200
|
+
time: number;
|
|
201
|
+
thereAmplitude: number;
|
|
202
|
+
backAmplitude: number;
|
|
203
|
+
direction: number;
|
|
204
|
+
noiseOffset: Point;
|
|
205
|
+
timeline: any[];
|
|
206
|
+
initialDirectionCos: number;
|
|
207
|
+
initialDirectionSin: number;
|
|
208
|
+
velocityScale: number;
|
|
209
|
+
rotationAcceleration: number;
|
|
210
|
+
/**
|
|
211
|
+
* Constructs a particle object
|
|
212
|
+
*/
|
|
213
|
+
constructor();
|
|
214
|
+
/**
|
|
215
|
+
* Resets the particle object
|
|
216
|
+
*/
|
|
217
|
+
reset(): void;
|
|
218
|
+
/**
|
|
219
|
+
* Checks if the particle is almost dead
|
|
220
|
+
*
|
|
221
|
+
* @return {boolean} True if the particle is almost dead, otherwise false
|
|
222
|
+
*/
|
|
223
|
+
isAlmostDead(): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Checks if the particle is dead
|
|
226
|
+
*
|
|
227
|
+
* @return {boolean} True if the particle is dead, otherwise false
|
|
228
|
+
*/
|
|
229
|
+
isDead(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Hides the particle
|
|
232
|
+
*/
|
|
233
|
+
hide(): void;
|
|
234
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Color, Point } from './util';
|
|
2
|
+
import ThereBack from './util/ThereBack';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a particle object used in particle system simulations
|
|
5
|
+
*/
|
|
6
|
+
class Particle {
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a particle object
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
this.next = null;
|
|
12
|
+
this.prev = null;
|
|
13
|
+
/**
|
|
14
|
+
* Stores the unique ID of the particle
|
|
15
|
+
*/
|
|
16
|
+
this.uid = Particle._UID.value++;
|
|
17
|
+
/**
|
|
18
|
+
* Stores the movement of the particle
|
|
19
|
+
*/
|
|
20
|
+
this.movement = new Point();
|
|
21
|
+
/**
|
|
22
|
+
* Stores the acceleration of the particle
|
|
23
|
+
*/
|
|
24
|
+
this.acceleration = new Point();
|
|
25
|
+
/**
|
|
26
|
+
* Stores the velocity of the particle
|
|
27
|
+
*/
|
|
28
|
+
this.velocity = new Point();
|
|
29
|
+
/**
|
|
30
|
+
* Stores the size of the particle
|
|
31
|
+
*/
|
|
32
|
+
this.size = new Point();
|
|
33
|
+
/**
|
|
34
|
+
* Stores the starting size of the particle
|
|
35
|
+
*/
|
|
36
|
+
this.sizeStart = new Point();
|
|
37
|
+
/**
|
|
38
|
+
* Stores the starting warp size of the particle
|
|
39
|
+
*/
|
|
40
|
+
this.warpSizeStart = new Point();
|
|
41
|
+
/**
|
|
42
|
+
* Stores the ending size of the particle
|
|
43
|
+
*/
|
|
44
|
+
this.sizeEnd = new Point();
|
|
45
|
+
/**
|
|
46
|
+
* Stores the x value of the particle for sin wave
|
|
47
|
+
*/
|
|
48
|
+
this.sinXVal = new Point();
|
|
49
|
+
/**
|
|
50
|
+
* Stores the y value of the particle for sin wave
|
|
51
|
+
*/
|
|
52
|
+
this.sinYVal = new Point();
|
|
53
|
+
/**
|
|
54
|
+
* Stores the color of the particle
|
|
55
|
+
*/
|
|
56
|
+
this.color = new Color();
|
|
57
|
+
/**
|
|
58
|
+
* Stores the starting color of the particle
|
|
59
|
+
*/
|
|
60
|
+
this.colorStart = new Color();
|
|
61
|
+
/**
|
|
62
|
+
* Stores the ending color of the particle
|
|
63
|
+
*/
|
|
64
|
+
this.colorEnd = new Color();
|
|
65
|
+
this.superColorAlphaEnd = 1;
|
|
66
|
+
this.skipPositionBehaviour = false;
|
|
67
|
+
this.skipAngularVelocityBehaviour = false;
|
|
68
|
+
this.skipColorBehaviour = false;
|
|
69
|
+
this.skipEmitDirectionBehaviour = false;
|
|
70
|
+
this.skipRotationBehaviour = false;
|
|
71
|
+
this.skipSizeBehaviour = false;
|
|
72
|
+
this.skipAttractionRepulsionBehaviour = false;
|
|
73
|
+
this.fromAtoB = false;
|
|
74
|
+
this.fromAtoBTwoWays = false;
|
|
75
|
+
this.pointA = new Point();
|
|
76
|
+
this.pointB = new Point();
|
|
77
|
+
this.there = new ThereBack();
|
|
78
|
+
this.back = new ThereBack();
|
|
79
|
+
this.xStart = 0;
|
|
80
|
+
this.yStart = 0;
|
|
81
|
+
this.xTarget = 0;
|
|
82
|
+
this.yTarget = 0;
|
|
83
|
+
this.thereDuration = 1;
|
|
84
|
+
this.backDuration = 1;
|
|
85
|
+
this.progress = 0;
|
|
86
|
+
this.time = 0;
|
|
87
|
+
this.thereAmplitude = 10;
|
|
88
|
+
this.backAmplitude = 10;
|
|
89
|
+
this.direction = 1;
|
|
90
|
+
this.noiseOffset = new Point();
|
|
91
|
+
this.timeline = [];
|
|
92
|
+
this.initialDirectionCos = 0;
|
|
93
|
+
this.initialDirectionSin = 0;
|
|
94
|
+
this.velocityScale = 1;
|
|
95
|
+
this.rotationAcceleration = 0;
|
|
96
|
+
this.reset();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resets the particle object
|
|
100
|
+
*/
|
|
101
|
+
reset() {
|
|
102
|
+
this.maxLifeTime = 0;
|
|
103
|
+
this.lifeTime = 0;
|
|
104
|
+
this.lifeProgress = 0;
|
|
105
|
+
this.x = 0;
|
|
106
|
+
this.y = 0;
|
|
107
|
+
this.z = 0;
|
|
108
|
+
this.timeline = [];
|
|
109
|
+
this.skipPositionBehaviour = false;
|
|
110
|
+
this.skipAngularVelocityBehaviour = false;
|
|
111
|
+
this.skipColorBehaviour = false;
|
|
112
|
+
this.skipAttractionRepulsionBehaviour = false;
|
|
113
|
+
this.skipEmitDirectionBehaviour = false;
|
|
114
|
+
this.skipRotationBehaviour = false;
|
|
115
|
+
this.skipSizeBehaviour = false;
|
|
116
|
+
this.movement.set(0, 0);
|
|
117
|
+
this.acceleration.set(0, 0);
|
|
118
|
+
this.velocity.set(0, 0);
|
|
119
|
+
this.sinXVal.set(0, 0);
|
|
120
|
+
this.sinYVal.set(0, 0);
|
|
121
|
+
this.velocityAngle = 0;
|
|
122
|
+
this.radiansPerSecond = 0;
|
|
123
|
+
this.radius = 0;
|
|
124
|
+
this.radiusStart = 0;
|
|
125
|
+
this.radiusEnd = 0;
|
|
126
|
+
this.directionCos = 1;
|
|
127
|
+
this.directionSin = 0;
|
|
128
|
+
this.finishingTexture = 0;
|
|
129
|
+
this.showVortices = false;
|
|
130
|
+
this.turbulence = false;
|
|
131
|
+
this.rotation = 0;
|
|
132
|
+
this.rotationDelta = 0;
|
|
133
|
+
this.size.set(1, 1);
|
|
134
|
+
this.sizeStart.set(0, 0);
|
|
135
|
+
this.warpSizeStart.set(0, 0);
|
|
136
|
+
this.sizeEnd.set(0, 0);
|
|
137
|
+
this.color.set(255, 255, 255, 1);
|
|
138
|
+
this.colorStart.set(0, 0, 0, 1);
|
|
139
|
+
this.colorEnd.set(0, 0, 0, 1);
|
|
140
|
+
this.superColorAlphaEnd = 1;
|
|
141
|
+
this.cameraZ = 0;
|
|
142
|
+
this.cameraZConverter = 10;
|
|
143
|
+
this.warpSpeed = 0;
|
|
144
|
+
this.warpBaseSpeed = 0;
|
|
145
|
+
this.warpFov = 20;
|
|
146
|
+
this.warpStretch = 5;
|
|
147
|
+
this.warpDistanceScaleConverter = 2000;
|
|
148
|
+
this.sizeDifference = { x: 1, y: 1 };
|
|
149
|
+
this.fromAtoB = false;
|
|
150
|
+
this.fromAtoBTwoWays = false;
|
|
151
|
+
this.pointA.set(0, 0);
|
|
152
|
+
this.pointB.set(0, 0);
|
|
153
|
+
this.there.set('', '', '');
|
|
154
|
+
this.back.set('', '', '');
|
|
155
|
+
this.thereDuration = 1;
|
|
156
|
+
this.backDuration = 1;
|
|
157
|
+
this.thereAmplitude = 10;
|
|
158
|
+
this.backAmplitude = 10;
|
|
159
|
+
this.progress = 0;
|
|
160
|
+
this.direction = 1;
|
|
161
|
+
this.time = 0;
|
|
162
|
+
this.xStart = 0;
|
|
163
|
+
this.yStart = 0;
|
|
164
|
+
this.xTarget = 0;
|
|
165
|
+
this.yTarget = 0;
|
|
166
|
+
this.noiseOffset = new Point();
|
|
167
|
+
this.initialDirectionCos = 0;
|
|
168
|
+
this.initialDirectionSin = 0;
|
|
169
|
+
this.velocityScale = 1;
|
|
170
|
+
this.rotationAcceleration = 0;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Checks if the particle is almost dead
|
|
174
|
+
*
|
|
175
|
+
* @return {boolean} True if the particle is almost dead, otherwise false
|
|
176
|
+
*/
|
|
177
|
+
isAlmostDead() {
|
|
178
|
+
return this.lifeTime >= this.maxLifeTime - 0.1;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Checks if the particle is dead
|
|
182
|
+
*
|
|
183
|
+
* @return {boolean} True if the particle is dead, otherwise false
|
|
184
|
+
*/
|
|
185
|
+
isDead() {
|
|
186
|
+
return this.lifeTime >= this.maxLifeTime;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Hides the particle
|
|
190
|
+
*/
|
|
191
|
+
hide() {
|
|
192
|
+
if (!this.sprite)
|
|
193
|
+
return;
|
|
194
|
+
if (!this.sprite.visible)
|
|
195
|
+
return;
|
|
196
|
+
this.sprite.visible = false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
Particle._UID = { value: 0 };
|
|
200
|
+
export default Particle;
|
|
201
|
+
//# sourceMappingURL=Particle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Particle.js","sourceRoot":"","sources":["../../src/lib/Particle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAExC;;GAEG;AACH,MAAqB,QAAQ;IAmP3B;;OAEG;IACH;QApPA,SAAI,GAAoB,IAAI,CAAA;QAC5B,SAAI,GAAoB,IAAI,CAAA;QAE5B;;WAEG;QACH,QAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QAE3B;;WAEG;QACH,aAAQ,GAAG,IAAI,KAAK,EAAE,CAAA;QAEtB;;WAEG;QACH,iBAAY,GAAG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AC,CAAA;QACf,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;QAEhB,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAM;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAM;QAChC,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;IAC7B,CAAC;;AA3WM,aAAI,GAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,AAAlC,CAAkC;eAD1B,QAAQ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Particle from './Particle';
|
|
2
|
+
/**
|
|
3
|
+
* @class ParticlePool
|
|
4
|
+
* A class for managing a pool of particles.
|
|
5
|
+
*/
|
|
6
|
+
export default class ParticlePool {
|
|
7
|
+
/**
|
|
8
|
+
* A static global instance of ParticlePool.
|
|
9
|
+
*/
|
|
10
|
+
static global: ParticlePool;
|
|
11
|
+
/**
|
|
12
|
+
* The first element in the pool.
|
|
13
|
+
*/
|
|
14
|
+
first: Particle | null;
|
|
15
|
+
/**
|
|
16
|
+
* Removes a particle from the pool and returns it.
|
|
17
|
+
*
|
|
18
|
+
* @returns {Particle} The removed particle.
|
|
19
|
+
*/
|
|
20
|
+
pop(): Particle;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new particle.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Particle} The newly created particle.
|
|
25
|
+
*/
|
|
26
|
+
create(): Particle;
|
|
27
|
+
/**
|
|
28
|
+
* Adds a particle to the pool.
|
|
29
|
+
*
|
|
30
|
+
* @param {Particle} particle The particle to add.
|
|
31
|
+
*/
|
|
32
|
+
push(particle: Particle): void;
|
|
33
|
+
/**
|
|
34
|
+
* Resets the particle pool.
|
|
35
|
+
*/
|
|
36
|
+
reset(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Particle from './Particle';
|
|
2
|
+
/**
|
|
3
|
+
* @class ParticlePool
|
|
4
|
+
* A class for managing a pool of particles.
|
|
5
|
+
*/
|
|
6
|
+
class ParticlePool {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* The first element in the pool.
|
|
10
|
+
*/
|
|
11
|
+
this.first = null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Removes a particle from the pool and returns it.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Particle} The removed particle.
|
|
17
|
+
*/
|
|
18
|
+
pop() {
|
|
19
|
+
if (!this.first)
|
|
20
|
+
return this.create();
|
|
21
|
+
const current = this.first;
|
|
22
|
+
this.first = current.next;
|
|
23
|
+
current.next = null;
|
|
24
|
+
return current;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new particle.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Particle} The newly created particle.
|
|
30
|
+
*/
|
|
31
|
+
create() {
|
|
32
|
+
return new Particle();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Adds a particle to the pool.
|
|
36
|
+
*
|
|
37
|
+
* @param {Particle} particle The particle to add.
|
|
38
|
+
*/
|
|
39
|
+
push(particle) {
|
|
40
|
+
particle.next = this.first;
|
|
41
|
+
this.first = particle;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resets the particle pool.
|
|
45
|
+
*/
|
|
46
|
+
reset() {
|
|
47
|
+
this.first = null;
|
|
48
|
+
ParticlePool.global = new ParticlePool();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A static global instance of ParticlePool.
|
|
53
|
+
*/
|
|
54
|
+
ParticlePool.global = new ParticlePool();
|
|
55
|
+
export default ParticlePool;
|
|
56
|
+
//# sourceMappingURL=ParticlePool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParticlePool.js","sourceRoot":"","sources":["../../src/lib/ParticlePool.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC;;;GAGG;AACH,MAAqB,YAAY;IAAjC;QAME;;WAEG;QACH,UAAK,GAAoB,IAAI,CAAA;IA0C/B,CAAC;IAxCC;;;;OAIG;IACH,GAAG;QACD,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAA;QAErC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACzB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;QACnB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,QAAQ,EAAE,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,QAAkB;QACrB,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,YAAY,CAAC,MAAM,GAAG,IAAI,YAAY,EAAE,CAAA;IAC1C,CAAC;;AAjDD;;GAEG;AACI,mBAAM,GAAG,IAAI,YAAY,EAAE,AAArB,CAAqB;eAJf,YAAY"}
|