@truelab/truengine 3.0.0 → 4.0.0-rc.1
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/browserAll-chunk.js +7 -0
- package/dist/libs/particles.js +1812 -0
- package/dist/libs/pixi.js +740 -197
- package/dist/pixi-chunk.js +48946 -17692
- package/dist/truengine.js +19051 -15410
- package/dist/types/libs/particles.d.ts +2 -0
- package/dist/types/src/classes/assets.class.d.ts.map +1 -1
- package/dist/types/src/classes/bitmap.text.class.d.ts +8 -3
- package/dist/types/src/classes/bitmap.text.class.d.ts.map +1 -1
- package/dist/types/src/classes/container.class.d.ts +6 -0
- package/dist/types/src/classes/container.class.d.ts.map +1 -1
- package/dist/types/src/classes/engine.class.d.ts +6 -0
- package/dist/types/src/classes/engine.class.d.ts.map +1 -1
- package/dist/types/src/classes/loaders.class.d.ts +19 -2
- package/dist/types/src/classes/loaders.class.d.ts.map +1 -1
- package/dist/types/src/classes/sequence.class.d.ts.map +1 -1
- package/dist/types/src/classes/spine.assets.class.d.ts +16 -1
- package/dist/types/src/classes/spine.assets.class.d.ts.map +1 -1
- package/dist/types/src/classes/tile.class.d.ts.map +1 -1
- package/dist/types/src/components/abstract.component.d.ts +2 -2
- package/dist/types/src/components/abstract.component.d.ts.map +1 -1
- package/dist/types/src/components/bigwin.component.d.ts.map +1 -1
- package/dist/types/src/components/blackout.component.d.ts +4 -4
- package/dist/types/src/components/blackout.component.d.ts.map +1 -1
- package/dist/types/src/components/button.component.d.ts +4 -4
- package/dist/types/src/components/button.component.d.ts.map +1 -1
- package/dist/types/src/components/button.text.component.d.ts.map +1 -1
- package/dist/types/src/components/cheat.component.d.ts +7 -0
- package/dist/types/src/components/cheat.component.d.ts.map +1 -1
- package/dist/types/src/components/fpsmeter.component.d.ts +44 -0
- package/dist/types/src/components/fpsmeter.component.d.ts.map +1 -0
- package/dist/types/src/components/link.component.d.ts +4 -4
- package/dist/types/src/components/link.component.d.ts.map +1 -1
- package/dist/types/src/components/particles.component.d.ts +1 -1
- package/dist/types/src/components/particles.component.d.ts.map +1 -1
- package/dist/types/src/components/retrigger.component.d.ts.map +1 -1
- package/dist/types/src/components/slideshow/slides.reel.component.d.ts +4 -4
- package/dist/types/src/components/slideshow/slides.reel.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/hints/hints.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/lines/lines.static.component.d.ts +3 -3
- package/dist/types/src/components/slot/lines/lines.static.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/payout/payout.base.component.d.ts +2 -2
- package/dist/types/src/components/slot/payout/payout.base.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/reel.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/slot.component.d.ts +1 -1
- package/dist/types/src/components/slot/slot.component.d.ts.map +1 -1
- package/dist/types/src/components/slot/slot.config.d.ts.map +1 -1
- package/dist/types/src/components/slot/symbol/symbol.component.d.ts +1 -1
- package/dist/types/src/components/slot/symbol/symbol.component.d.ts.map +1 -1
- package/dist/types/src/components/switch.component.d.ts +1 -1
- package/dist/types/src/components/switch.component.d.ts.map +1 -1
- package/dist/types/src/components/text.component.d.ts +2 -2
- package/dist/types/src/components/text.component.d.ts.map +1 -1
- package/dist/types/src/extends/events.types.d.ts +1 -1
- package/dist/types/src/extends/events.types.d.ts.map +1 -1
- package/dist/types/src/extends/interfaces.d.ts +3 -2
- package/dist/types/src/extends/interfaces.d.ts.map +1 -1
- package/dist/types/src/extends/short.types.d.ts +2 -2
- package/dist/types/src/extends/short.types.d.ts.map +1 -1
- package/dist/types/src/extends/struct.types.d.ts +2 -2
- package/dist/types/src/extends/struct.types.d.ts.map +1 -1
- package/dist/types/src/functions/convert/textstyle.func.d.ts +15 -0
- package/dist/types/src/functions/convert/textstyle.func.d.ts.map +1 -0
- package/dist/types/src/functions/debug/container.func.d.ts.map +1 -1
- package/dist/types/src/functions/debug/line.func.d.ts.map +1 -1
- package/dist/types/src/functions/demotexture.func.d.ts.map +1 -1
- package/dist/types/src/functions/draw/canvasExtract.func.d.ts +6 -6
- package/dist/types/src/functions/draw/canvasExtract.func.d.ts.map +1 -1
- package/dist/types/src/functions/draw/radialGradient.func.d.ts +2 -2
- package/dist/types/src/functions/draw/radialGradient.func.d.ts.map +1 -1
- package/dist/types/src/functions/draw/rect.func.d.ts.map +1 -1
- package/dist/types/src/functions/is.funcs.d.ts +5 -0
- package/dist/types/src/functions/is.funcs.d.ts.map +1 -1
- package/dist/types/src/functions/object/deepMerge.d.ts +2 -1
- package/dist/types/src/functions/object/deepMerge.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/libs/particles/ContainerParticle.d.ts +123 -0
- package/dist/types/src/libs/particles/ContainerParticle.d.ts.map +1 -0
- package/dist/types/src/libs/particles/Emitter.d.ts +303 -0
- package/dist/types/src/libs/particles/Emitter.d.ts.map +1 -0
- package/dist/types/src/libs/particles/EmitterConfig.d.ts +228 -0
- package/dist/types/src/libs/particles/EmitterConfig.d.ts.map +1 -0
- package/dist/types/src/libs/particles/Particle.d.ts +70 -0
- package/dist/types/src/libs/particles/Particle.d.ts.map +1 -0
- package/dist/types/src/libs/particles/ParticleUtils.d.ts +95 -0
- package/dist/types/src/libs/particles/ParticleUtils.d.ts.map +1 -0
- package/dist/types/src/libs/particles/PropertyList.d.ts +40 -0
- package/dist/types/src/libs/particles/PropertyList.d.ts.map +1 -0
- package/dist/types/src/libs/particles/PropertyNode.d.ts +74 -0
- package/dist/types/src/libs/particles/PropertyNode.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/AccelerationMovement.d.ts +62 -0
- package/dist/types/src/libs/particles/behaviors/AccelerationMovement.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/Alpha.d.ts +60 -0
- package/dist/types/src/libs/particles/behaviors/Alpha.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/AnimatedTexture.d.ts +111 -0
- package/dist/types/src/libs/particles/behaviors/AnimatedTexture.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/Behaviors.d.ts +71 -0
- package/dist/types/src/libs/particles/behaviors/Behaviors.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/BlendMode.d.ts +31 -0
- package/dist/types/src/libs/particles/behaviors/BlendMode.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/BurstSpawn.d.ts +43 -0
- package/dist/types/src/libs/particles/behaviors/BurstSpawn.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/Color.d.ts +60 -0
- package/dist/types/src/libs/particles/behaviors/Color.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/OrderedTexture.d.ts +33 -0
- package/dist/types/src/libs/particles/behaviors/OrderedTexture.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/PathMovement.d.ts +68 -0
- package/dist/types/src/libs/particles/behaviors/PathMovement.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/PointSpawn.d.ts +21 -0
- package/dist/types/src/libs/particles/behaviors/PointSpawn.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/RandomTexture.d.ts +32 -0
- package/dist/types/src/libs/particles/behaviors/RandomTexture.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/Rotation.d.ts +114 -0
- package/dist/types/src/libs/particles/behaviors/Rotation.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/Scale.d.ts +74 -0
- package/dist/types/src/libs/particles/behaviors/Scale.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/ShapeSpawn.d.ts +58 -0
- package/dist/types/src/libs/particles/behaviors/ShapeSpawn.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/SingleTexture.d.ts +32 -0
- package/dist/types/src/libs/particles/behaviors/SingleTexture.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/SpeedMovement.d.ts +76 -0
- package/dist/types/src/libs/particles/behaviors/SpeedMovement.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/editor/Types.d.ts +104 -0
- package/dist/types/src/libs/particles/behaviors/editor/Types.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/index.d.ts +21 -0
- package/dist/types/src/libs/particles/behaviors/index.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/shapes/PolygonalChain.d.ts +57 -0
- package/dist/types/src/libs/particles/behaviors/shapes/PolygonalChain.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/shapes/Rectangle.d.ts +59 -0
- package/dist/types/src/libs/particles/behaviors/shapes/Rectangle.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/shapes/SpawnShape.d.ts +32 -0
- package/dist/types/src/libs/particles/behaviors/shapes/SpawnShape.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/shapes/Torus.d.ts +71 -0
- package/dist/types/src/libs/particles/behaviors/shapes/Torus.d.ts.map +1 -0
- package/dist/types/src/libs/particles/behaviors/shapes/index.d.ts +5 -0
- package/dist/types/src/libs/particles/behaviors/shapes/index.d.ts.map +1 -0
- package/dist/types/src/libs/particles/index.d.ts +9 -0
- package/dist/types/src/libs/particles/index.d.ts.map +1 -0
- package/dist/types/src/scenes/masked.scene.d.ts.map +1 -1
- package/dist/types/vite.config.d.ts.map +1 -1
- package/dist/webworkerAll-chunk.js +3 -0
- package/package.json +11 -8
|
@@ -0,0 +1,1812 @@
|
|
|
1
|
+
var pt = Object.defineProperty;
|
|
2
|
+
var ut = (i, t, e) => t in i ? pt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var s = (i, t, e) => ut(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { T as B, P as C, b as mt, S as dt, c as ft, d as xt } from "../pixi-chunk.js";
|
|
5
|
+
class O {
|
|
6
|
+
/**
|
|
7
|
+
* @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains.
|
|
8
|
+
*/
|
|
9
|
+
constructor(t) {
|
|
10
|
+
/**
|
|
11
|
+
* List of segment objects in the chain.
|
|
12
|
+
*/
|
|
13
|
+
s(this, "segments");
|
|
14
|
+
/**
|
|
15
|
+
* Total length of all segments of the chain.
|
|
16
|
+
*/
|
|
17
|
+
s(this, "totalLength");
|
|
18
|
+
/**
|
|
19
|
+
* Total length of segments up to and including the segment of the same index.
|
|
20
|
+
* Used for weighted random selection of segment.
|
|
21
|
+
*/
|
|
22
|
+
s(this, "countingLengths");
|
|
23
|
+
this.segments = [], this.countingLengths = [], this.totalLength = 0, this.init(t);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains.
|
|
27
|
+
*/
|
|
28
|
+
init(t) {
|
|
29
|
+
if (!t || !t.length)
|
|
30
|
+
this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 });
|
|
31
|
+
else if (Array.isArray(t[0]))
|
|
32
|
+
for (let e = 0; e < t.length; ++e) {
|
|
33
|
+
const a = t[e];
|
|
34
|
+
let r = a[0];
|
|
35
|
+
for (let l = 1; l < a.length; ++l) {
|
|
36
|
+
const n = a[l];
|
|
37
|
+
this.segments.push({ p1: r, p2: n, l: 0 }), r = n;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
let e = t[0];
|
|
42
|
+
for (let a = 1; a < t.length; ++a) {
|
|
43
|
+
const r = t[a];
|
|
44
|
+
this.segments.push({ p1: e, p2: r, l: 0 }), e = r;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for (let e = 0; e < this.segments.length; ++e) {
|
|
48
|
+
const { p1: a, p2: r } = this.segments[e], l = Math.sqrt((r.x - a.x) * (r.x - a.x) + (r.y - a.y) * (r.y - a.y));
|
|
49
|
+
this.segments[e].l = l, this.totalLength += l, this.countingLengths.push(this.totalLength);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets a random point in the chain.
|
|
54
|
+
* @param out The point to store the selected position in.
|
|
55
|
+
*/
|
|
56
|
+
getRandPos(t) {
|
|
57
|
+
const e = Math.random() * this.totalLength;
|
|
58
|
+
let a, r;
|
|
59
|
+
if (this.segments.length === 1)
|
|
60
|
+
a = this.segments[0], r = e;
|
|
61
|
+
else
|
|
62
|
+
for (let o = 0; o < this.countingLengths.length; ++o)
|
|
63
|
+
if (e < this.countingLengths[o]) {
|
|
64
|
+
a = this.segments[o], r = o === 0 ? e : e - this.countingLengths[o - 1];
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
r /= a.l || 1;
|
|
68
|
+
const { p1: l, p2: n } = a;
|
|
69
|
+
t.x = l.x + r * (n.x - l.x), t.y = l.y + r * (n.y - l.y);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
s(O, "type", "polygonalChain"), s(O, "editorConfig", null);
|
|
73
|
+
class A {
|
|
74
|
+
constructor(t) {
|
|
75
|
+
/**
|
|
76
|
+
* X (left) position of the rectangle.
|
|
77
|
+
*/
|
|
78
|
+
s(this, "x");
|
|
79
|
+
/**
|
|
80
|
+
* Y (top) position of the rectangle.
|
|
81
|
+
*/
|
|
82
|
+
s(this, "y");
|
|
83
|
+
/**
|
|
84
|
+
* Width of the rectangle.
|
|
85
|
+
*/
|
|
86
|
+
s(this, "w");
|
|
87
|
+
/**
|
|
88
|
+
* Height of the rectangle.
|
|
89
|
+
*/
|
|
90
|
+
s(this, "h");
|
|
91
|
+
this.x = t.x, this.y = t.y, this.w = t.w, this.h = t.h;
|
|
92
|
+
}
|
|
93
|
+
getRandPos(t) {
|
|
94
|
+
t.x = Math.random() * this.w + this.x, t.y = Math.random() * this.h + this.y;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
s(A, "type", "rect"), s(A, "editorConfig", null);
|
|
98
|
+
class P {
|
|
99
|
+
/**
|
|
100
|
+
* @param value The value for this node
|
|
101
|
+
* @param time The time for this node, between 0-1
|
|
102
|
+
* @param [ease] Custom ease for this list. Only relevant for the first node.
|
|
103
|
+
*/
|
|
104
|
+
constructor(t, e, a) {
|
|
105
|
+
/**
|
|
106
|
+
* Value for the node.
|
|
107
|
+
*/
|
|
108
|
+
s(this, "value");
|
|
109
|
+
/**
|
|
110
|
+
* Time value for the node. Between 0-1.
|
|
111
|
+
*/
|
|
112
|
+
s(this, "time");
|
|
113
|
+
/**
|
|
114
|
+
* The next node in line.
|
|
115
|
+
*/
|
|
116
|
+
s(this, "next");
|
|
117
|
+
/**
|
|
118
|
+
* If this is the first node in the list, controls if the entire list is stepped or not.
|
|
119
|
+
*/
|
|
120
|
+
s(this, "isStepped");
|
|
121
|
+
s(this, "ease");
|
|
122
|
+
this.value = t, this.time = e, this.next = null, this.isStepped = !1, a ? this.ease = typeof a == "function" ? a : nt(a) : this.ease = null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a list of property values from a data object {list, isStepped} with a list of objects in
|
|
126
|
+
* the form {value, time}. Alternatively, the data object can be in the deprecated form of
|
|
127
|
+
* {start, end}.
|
|
128
|
+
* @param data The data for the list.
|
|
129
|
+
* @param data.list The array of value and time objects.
|
|
130
|
+
* @param data.isStepped If the list is stepped rather than interpolated.
|
|
131
|
+
* @param data.ease Custom ease for this list.
|
|
132
|
+
* @return The first node in the list
|
|
133
|
+
*/
|
|
134
|
+
// eslint-disable-next-line max-len
|
|
135
|
+
static createList(t) {
|
|
136
|
+
if ("list" in t) {
|
|
137
|
+
const a = t.list;
|
|
138
|
+
let r;
|
|
139
|
+
const { value: l, time: n } = a[0], o = r = new P(
|
|
140
|
+
typeof l == "string" ? g(l) : l,
|
|
141
|
+
n,
|
|
142
|
+
t.ease
|
|
143
|
+
);
|
|
144
|
+
if (a.length > 2 || a.length === 2 && a[1].value !== l)
|
|
145
|
+
for (let c = 1; c < a.length; ++c) {
|
|
146
|
+
const { value: u, time: d } = a[c];
|
|
147
|
+
r.next = new P(typeof u == "string" ? g(u) : u, d), r = r.next;
|
|
148
|
+
}
|
|
149
|
+
return o.isStepped = !!t.isStepped, o;
|
|
150
|
+
}
|
|
151
|
+
const e = new P(typeof t.start == "string" ? g(t.start) : t.start, 0);
|
|
152
|
+
return t.end !== t.start && (e.next = new P(typeof t.end == "string" ? g(t.end) : t.end, 1)), e;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
let F = B.from;
|
|
156
|
+
const yt = !1, _ = Math.PI / 180;
|
|
157
|
+
function w(i, t) {
|
|
158
|
+
if (!i) return;
|
|
159
|
+
const e = Math.sin(i), a = Math.cos(i), r = t.x * a - t.y * e, l = t.x * e + t.y * a;
|
|
160
|
+
t.x = r, t.y = l;
|
|
161
|
+
}
|
|
162
|
+
function k(i, t, e) {
|
|
163
|
+
return (
|
|
164
|
+
/* a << 24 |*/
|
|
165
|
+
i << 16 | t << 8 | e
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function at(i) {
|
|
169
|
+
return Math.sqrt(i.x * i.x + i.y * i.y);
|
|
170
|
+
}
|
|
171
|
+
function lt(i) {
|
|
172
|
+
let t = 1 / at(i);
|
|
173
|
+
(t !== t || t === 1 / 0) && (t = 0), i.x *= t, i.y *= t;
|
|
174
|
+
}
|
|
175
|
+
function rt(i, t) {
|
|
176
|
+
i.x *= t, i.y *= t;
|
|
177
|
+
}
|
|
178
|
+
function g(i, t) {
|
|
179
|
+
t || (t = {}), i.charAt(0) === "#" ? i = i.substr(1) : i.indexOf("0x") === 0 && (i = i.substr(2));
|
|
180
|
+
let e;
|
|
181
|
+
return i.length === 8 && (e = i.substr(0, 2), i = i.substr(2)), t.r = parseInt(i.substr(0, 2), 16), t.g = parseInt(i.substr(2, 2), 16), t.b = parseInt(i.substr(4, 2), 16), e && (t.a = parseInt(e, 16)), t;
|
|
182
|
+
}
|
|
183
|
+
function nt(i) {
|
|
184
|
+
const t = i.length, e = 1 / t;
|
|
185
|
+
return function(a) {
|
|
186
|
+
const r = t * a | 0, l = (a - r * e) * t, n = i[r] || i[t - 1];
|
|
187
|
+
return n.s + l * (2 * (1 - l) * (n.cp - n.s) + l * (n.e - n.s));
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function ot(i) {
|
|
191
|
+
return i ? i.toLowerCase().replace(/_/g, "-").replace(/ /g, "-") : "normal";
|
|
192
|
+
}
|
|
193
|
+
function vt(i, t = 10) {
|
|
194
|
+
(typeof t != "number" || t <= 0) && (t = 10);
|
|
195
|
+
const e = new P(g(i[0].value), i[0].time);
|
|
196
|
+
e.isStepped = !0;
|
|
197
|
+
let a = e, r = i[0], l = 1, n = i[l];
|
|
198
|
+
for (let o = 1; o < t; ++o) {
|
|
199
|
+
let c = o / t;
|
|
200
|
+
for (; c > n.time; )
|
|
201
|
+
r = n, n = i[++l];
|
|
202
|
+
c = (c - r.time) / (n.time - r.time);
|
|
203
|
+
const u = g(r.value), d = g(n.value), y = {
|
|
204
|
+
r: (d.r - u.r) * c + u.r,
|
|
205
|
+
g: (d.g - u.g) * c + u.g,
|
|
206
|
+
b: (d.b - u.b) * c + u.b
|
|
207
|
+
};
|
|
208
|
+
a.next = new P(y, o / t), a = a.next;
|
|
209
|
+
}
|
|
210
|
+
return e;
|
|
211
|
+
}
|
|
212
|
+
const It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
213
|
+
__proto__: null,
|
|
214
|
+
DEG_TO_RADS: _,
|
|
215
|
+
GetTextureFromString: F,
|
|
216
|
+
combineRGBComponents: k,
|
|
217
|
+
createSteppedGradient: vt,
|
|
218
|
+
generateEase: nt,
|
|
219
|
+
getBlendMode: ot,
|
|
220
|
+
hexToRGB: g,
|
|
221
|
+
length: at,
|
|
222
|
+
normalize: lt,
|
|
223
|
+
rotatePoint: w,
|
|
224
|
+
scaleBy: rt,
|
|
225
|
+
verbose: yt
|
|
226
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
227
|
+
class T {
|
|
228
|
+
constructor(t) {
|
|
229
|
+
/**
|
|
230
|
+
* X position of the center of the shape.
|
|
231
|
+
*/
|
|
232
|
+
s(this, "x");
|
|
233
|
+
/**
|
|
234
|
+
* Y position of the center of the shape.
|
|
235
|
+
*/
|
|
236
|
+
s(this, "y");
|
|
237
|
+
/**
|
|
238
|
+
* Radius of circle, or outer radius of a ring.
|
|
239
|
+
*/
|
|
240
|
+
s(this, "radius");
|
|
241
|
+
/**
|
|
242
|
+
* Inner radius of a ring. Use 0 to have a circle.
|
|
243
|
+
*/
|
|
244
|
+
s(this, "innerRadius");
|
|
245
|
+
/**
|
|
246
|
+
* If rotation should be applied to particles.
|
|
247
|
+
*/
|
|
248
|
+
s(this, "rotation");
|
|
249
|
+
this.x = t.x || 0, this.y = t.y || 0, this.radius = t.radius, this.innerRadius = t.innerRadius || 0, this.rotation = !!t.affectRotation;
|
|
250
|
+
}
|
|
251
|
+
getRandPos(t) {
|
|
252
|
+
this.innerRadius !== this.radius ? t.x = Math.random() * (this.radius - this.innerRadius) + this.innerRadius : t.x = this.radius, t.y = 0;
|
|
253
|
+
const e = Math.random() * Math.PI * 2;
|
|
254
|
+
this.rotation && (t.rotation += e), w(e, t.position), t.position.x += this.x, t.position.y += this.y;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
s(T, "type", "torus"), s(T, "editorConfig", null);
|
|
258
|
+
const Pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
259
|
+
__proto__: null,
|
|
260
|
+
PolygonalChain: O,
|
|
261
|
+
Rectangle: A,
|
|
262
|
+
Torus: T
|
|
263
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
264
|
+
var p = /* @__PURE__ */ ((i) => (i[i.Spawn = 0] = "Spawn", i[i.Normal = 2] = "Normal", i[i.Late = 5] = "Late", i))(p || {});
|
|
265
|
+
const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
266
|
+
__proto__: null
|
|
267
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
268
|
+
class I {
|
|
269
|
+
constructor(t) {
|
|
270
|
+
// doesn't _really_ need to be late, but doing so ensures that we can override any
|
|
271
|
+
// rotation behavior that is mistakenly added
|
|
272
|
+
s(this, "order", p.Late);
|
|
273
|
+
s(this, "minStart");
|
|
274
|
+
s(this, "maxStart");
|
|
275
|
+
s(this, "accel");
|
|
276
|
+
s(this, "rotate");
|
|
277
|
+
s(this, "maxSpeed");
|
|
278
|
+
this.minStart = t.minStart, this.maxStart = t.maxStart, this.accel = t.accel, this.rotate = !!t.rotate, this.maxSpeed = t.maxSpeed ?? 0;
|
|
279
|
+
}
|
|
280
|
+
initParticles(t) {
|
|
281
|
+
let e = t;
|
|
282
|
+
for (; e; ) {
|
|
283
|
+
const a = Math.random() * (this.maxStart - this.minStart) + this.minStart;
|
|
284
|
+
e.config.velocity ? e.config.velocity.set(a, 0) : e.config.velocity = new C(a, 0), w(e.rotation, e.config.velocity), e = e.next;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
updateParticle(t, e) {
|
|
288
|
+
const a = t.config.velocity, r = a.x, l = a.y;
|
|
289
|
+
if (a.x += this.accel.x * e, a.y += this.accel.y * e, this.maxSpeed) {
|
|
290
|
+
const n = at(a);
|
|
291
|
+
n > this.maxSpeed && rt(a, this.maxSpeed / n);
|
|
292
|
+
}
|
|
293
|
+
t.x += (r + a.x) / 2 * e, t.y += (l + a.y) / 2 * e, this.rotate && (t.rotation = Math.atan2(a.y, a.x));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
s(I, "type", "moveAcceleration"), s(I, "editorConfig", null);
|
|
297
|
+
function wt(i) {
|
|
298
|
+
return this.ease && (i = this.ease(i)), (this.first.next.value - this.first.value) * i + this.first.value;
|
|
299
|
+
}
|
|
300
|
+
function gt(i) {
|
|
301
|
+
this.ease && (i = this.ease(i));
|
|
302
|
+
const t = this.first.value, e = this.first.next.value, a = (e.r - t.r) * i + t.r, r = (e.g - t.g) * i + t.g, l = (e.b - t.b) * i + t.b;
|
|
303
|
+
return k(a, r, l);
|
|
304
|
+
}
|
|
305
|
+
function Ct(i) {
|
|
306
|
+
this.ease && (i = this.ease(i));
|
|
307
|
+
let t = this.first, { next: e } = t;
|
|
308
|
+
for (; i > e.time; )
|
|
309
|
+
t = e, e = e.next;
|
|
310
|
+
return i = (i - t.time) / (e.time - t.time), (e.value - t.value) * i + t.value;
|
|
311
|
+
}
|
|
312
|
+
function St(i) {
|
|
313
|
+
this.ease && (i = this.ease(i));
|
|
314
|
+
let t = this.first, { next: e } = t;
|
|
315
|
+
for (; i > e.time; )
|
|
316
|
+
t = e, e = e.next;
|
|
317
|
+
i = (i - t.time) / (e.time - t.time);
|
|
318
|
+
const a = t.value, r = e.value, l = (r.r - a.r) * i + a.r, n = (r.g - a.g) * i + a.g, o = (r.b - a.b) * i + a.b;
|
|
319
|
+
return k(l, n, o);
|
|
320
|
+
}
|
|
321
|
+
function bt(i) {
|
|
322
|
+
this.ease && (i = this.ease(i));
|
|
323
|
+
let t = this.first;
|
|
324
|
+
for (; t.next && i > t.next.time; )
|
|
325
|
+
t = t.next;
|
|
326
|
+
return t.value;
|
|
327
|
+
}
|
|
328
|
+
function Lt(i) {
|
|
329
|
+
this.ease && (i = this.ease(i));
|
|
330
|
+
let t = this.first;
|
|
331
|
+
for (; t.next && i > t.next.time; )
|
|
332
|
+
t = t.next;
|
|
333
|
+
const e = t.value;
|
|
334
|
+
return k(e.r, e.g, e.b);
|
|
335
|
+
}
|
|
336
|
+
class R {
|
|
337
|
+
/**
|
|
338
|
+
* @param isColor If this list handles color values
|
|
339
|
+
*/
|
|
340
|
+
constructor(t = !1) {
|
|
341
|
+
/**
|
|
342
|
+
* The first property node in the linked list.
|
|
343
|
+
*/
|
|
344
|
+
s(this, "first");
|
|
345
|
+
/**
|
|
346
|
+
* Calculates the correct value for the current interpolation value. This method is set in
|
|
347
|
+
* the reset() method.
|
|
348
|
+
* @param lerp The interpolation value from 0-1.
|
|
349
|
+
* @return The interpolated value. Colors are converted to the hex value.
|
|
350
|
+
*/
|
|
351
|
+
s(this, "interpolate");
|
|
352
|
+
/**
|
|
353
|
+
* A custom easing method for this list.
|
|
354
|
+
* @param lerp The interpolation value from 0-1.
|
|
355
|
+
* @return The eased value, also from 0-1.
|
|
356
|
+
*/
|
|
357
|
+
s(this, "ease");
|
|
358
|
+
/**
|
|
359
|
+
* If this list manages colors, which requires a different method for interpolation.
|
|
360
|
+
*/
|
|
361
|
+
s(this, "isColor");
|
|
362
|
+
this.first = null, this.isColor = !!t, this.interpolate = null, this.ease = null;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Resets the list for use.
|
|
366
|
+
* @param first The first node in the list.
|
|
367
|
+
* @param first.isStepped If the values should be stepped instead of interpolated linearly.
|
|
368
|
+
*/
|
|
369
|
+
reset(t) {
|
|
370
|
+
this.first = t, t.next && t.next.time >= 1 ? this.interpolate = this.isColor ? gt : wt : t.isStepped ? this.interpolate = this.isColor ? Lt : bt : this.interpolate = this.isColor ? St : Ct, this.ease = this.first.ease;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class V {
|
|
374
|
+
constructor(t) {
|
|
375
|
+
s(this, "order", p.Normal);
|
|
376
|
+
s(this, "list");
|
|
377
|
+
this.list = new R(!1), this.list.reset(P.createList(t.alpha));
|
|
378
|
+
}
|
|
379
|
+
initParticles(t) {
|
|
380
|
+
let e = t;
|
|
381
|
+
for (; e; )
|
|
382
|
+
e.alpha = this.list.first.value, e = e.next;
|
|
383
|
+
}
|
|
384
|
+
updateParticle(t) {
|
|
385
|
+
t.alpha = this.list.interpolate(t.agePercent);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
s(V, "type", "alpha"), s(V, "editorConfig", null);
|
|
389
|
+
class q {
|
|
390
|
+
constructor(t) {
|
|
391
|
+
s(this, "order", p.Normal);
|
|
392
|
+
s(this, "value");
|
|
393
|
+
this.value = t.alpha;
|
|
394
|
+
}
|
|
395
|
+
initParticles(t) {
|
|
396
|
+
let e = t;
|
|
397
|
+
for (; e; )
|
|
398
|
+
e.alpha = this.value, e = e.next;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
s(q, "type", "alphaStatic"), s(q, "editorConfig", null);
|
|
402
|
+
function ht(i) {
|
|
403
|
+
const t = [];
|
|
404
|
+
for (let e = 0; e < i.length; ++e) {
|
|
405
|
+
let a = i[e];
|
|
406
|
+
if (typeof a == "string")
|
|
407
|
+
t.push(F(a));
|
|
408
|
+
else if (a instanceof B)
|
|
409
|
+
t.push(a);
|
|
410
|
+
else {
|
|
411
|
+
let r = a.count || 1;
|
|
412
|
+
for (typeof a.texture == "string" ? a = F(a.texture) : a = a.texture; r > 0; --r)
|
|
413
|
+
t.push(a);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return t;
|
|
417
|
+
}
|
|
418
|
+
class N {
|
|
419
|
+
constructor(t) {
|
|
420
|
+
s(this, "order", p.Normal);
|
|
421
|
+
s(this, "anims");
|
|
422
|
+
this.anims = [];
|
|
423
|
+
for (let e = 0; e < t.anims.length; ++e) {
|
|
424
|
+
const a = t.anims[e], r = ht(a.textures), l = a.framerate < 0 ? -1 : a.framerate > 0 ? a.framerate : 60, n = {
|
|
425
|
+
textures: r,
|
|
426
|
+
duration: l > 0 ? r.length / l : 0,
|
|
427
|
+
framerate: l,
|
|
428
|
+
loop: l > 0 ? !!a.loop : !1
|
|
429
|
+
};
|
|
430
|
+
this.anims.push(n);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
initParticles(t) {
|
|
434
|
+
let e = t;
|
|
435
|
+
for (; e; ) {
|
|
436
|
+
const a = Math.floor(Math.random() * this.anims.length), r = e.config.anim = this.anims[a];
|
|
437
|
+
e.texture = r.textures[0], e.config.animElapsed = 0, r.framerate === -1 ? (e.config.animDuration = e.maxLife, e.config.animFramerate = r.textures.length / e.maxLife) : (e.config.animDuration = r.duration, e.config.animFramerate = r.framerate), e = e.next;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
updateParticle(t, e) {
|
|
441
|
+
const { config: a } = t, { anim: r } = a;
|
|
442
|
+
a.animElapsed += e, a.animElapsed >= a.animDuration && (a.anim.loop ? a.animElapsed = a.animElapsed % a.animDuration : a.animElapsed = a.animDuration - 1e-6);
|
|
443
|
+
const l = a.animElapsed * a.animFramerate + 1e-7 | 0;
|
|
444
|
+
t.texture = r.textures[l] || r.textures[r.textures.length - 1] || B.EMPTY;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
s(N, "type", "animatedRandom"), s(N, "editorConfig", null);
|
|
448
|
+
class U {
|
|
449
|
+
constructor(t) {
|
|
450
|
+
s(this, "order", p.Normal);
|
|
451
|
+
s(this, "anim");
|
|
452
|
+
const { anim: e } = t, a = ht(e.textures), r = e.framerate < 0 ? -1 : e.framerate > 0 ? e.framerate : 60;
|
|
453
|
+
this.anim = {
|
|
454
|
+
textures: a,
|
|
455
|
+
duration: r > 0 ? a.length / r : 0,
|
|
456
|
+
framerate: r,
|
|
457
|
+
loop: r > 0 ? !!e.loop : !1
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
initParticles(t) {
|
|
461
|
+
let e = t;
|
|
462
|
+
const { anim: a } = this;
|
|
463
|
+
for (; e; )
|
|
464
|
+
e.texture = a.textures[0], e.config.animElapsed = 0, a.framerate === -1 ? (e.config.animDuration = e.maxLife, e.config.animFramerate = a.textures.length / e.maxLife) : (e.config.animDuration = a.duration, e.config.animFramerate = a.framerate), e = e.next;
|
|
465
|
+
}
|
|
466
|
+
updateParticle(t, e) {
|
|
467
|
+
const { anim: a } = this, { config: r } = t;
|
|
468
|
+
r.animElapsed += e, r.animElapsed >= r.animDuration && (a.loop ? r.animElapsed = r.animElapsed % r.animDuration : r.animElapsed = r.animDuration - 1e-6);
|
|
469
|
+
const l = r.animElapsed * r.animFramerate + 1e-7 | 0;
|
|
470
|
+
t.texture = a.textures[l] || a.textures[a.textures.length - 1] || B.EMPTY;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
s(U, "type", "animatedSingle"), s(U, "editorConfig", null);
|
|
474
|
+
class W {
|
|
475
|
+
constructor(t) {
|
|
476
|
+
s(this, "order", p.Normal);
|
|
477
|
+
s(this, "value");
|
|
478
|
+
this.value = t.blendMode;
|
|
479
|
+
}
|
|
480
|
+
initParticles(t) {
|
|
481
|
+
let e = t;
|
|
482
|
+
for (; e; )
|
|
483
|
+
e.blendMode = ot(this.value), e = e.next;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
s(W, "type", "blendMode"), s(W, "editorConfig", null);
|
|
487
|
+
class Y {
|
|
488
|
+
constructor(t) {
|
|
489
|
+
s(this, "order", p.Spawn);
|
|
490
|
+
s(this, "spacing");
|
|
491
|
+
s(this, "start");
|
|
492
|
+
s(this, "distance");
|
|
493
|
+
this.spacing = t.spacing * _, this.start = t.start * _, this.distance = t.distance;
|
|
494
|
+
}
|
|
495
|
+
initParticles(t) {
|
|
496
|
+
let e = 0, a = t;
|
|
497
|
+
for (; a; ) {
|
|
498
|
+
let r;
|
|
499
|
+
this.spacing ? r = this.start + this.spacing * e : r = Math.random() * Math.PI * 2, a.rotation = r, this.distance && (a.position.x = this.distance, w(r, a.position)), a = a.next, ++e;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
s(Y, "type", "spawnBurst"), s(Y, "editorConfig", null);
|
|
504
|
+
class D {
|
|
505
|
+
constructor(t) {
|
|
506
|
+
s(this, "order", p.Normal);
|
|
507
|
+
s(this, "list");
|
|
508
|
+
this.list = new R(!0), this.list.reset(P.createList(t.color));
|
|
509
|
+
}
|
|
510
|
+
initParticles(t) {
|
|
511
|
+
let e = t;
|
|
512
|
+
const a = this.list.first.value, r = k(a.r, a.g, a.b);
|
|
513
|
+
for (; e; )
|
|
514
|
+
e.tint = r, e = e.next;
|
|
515
|
+
}
|
|
516
|
+
updateParticle(t) {
|
|
517
|
+
t.tint = this.list.interpolate(t.agePercent);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
s(D, "type", "color"), s(D, "editorConfig", null);
|
|
521
|
+
class X {
|
|
522
|
+
constructor(t) {
|
|
523
|
+
s(this, "order", p.Normal);
|
|
524
|
+
s(this, "value");
|
|
525
|
+
let { color: e } = t;
|
|
526
|
+
e.charAt(0) === "#" ? e = e.substr(1) : e.indexOf("0x") === 0 && (e = e.substr(2)), this.value = parseInt(e, 16);
|
|
527
|
+
}
|
|
528
|
+
initParticles(t) {
|
|
529
|
+
let e = t;
|
|
530
|
+
for (; e; )
|
|
531
|
+
e.tint = this.value, e = e.next;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
s(X, "type", "colorStatic"), s(X, "editorConfig", null);
|
|
535
|
+
class j {
|
|
536
|
+
constructor(t) {
|
|
537
|
+
s(this, "order", p.Normal);
|
|
538
|
+
s(this, "textures");
|
|
539
|
+
s(this, "index");
|
|
540
|
+
this.index = 0, this.textures = t.textures.map((e) => typeof e == "string" ? F(e) : e);
|
|
541
|
+
}
|
|
542
|
+
initParticles(t) {
|
|
543
|
+
let e = t;
|
|
544
|
+
for (; e; )
|
|
545
|
+
e.texture = this.textures[this.index], ++this.index >= this.textures.length && (this.index = 0), e = e.next;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
s(j, "type", "textureOrdered"), s(j, "editorConfig", null);
|
|
549
|
+
const E = new C(), ct = [
|
|
550
|
+
"E",
|
|
551
|
+
"LN2",
|
|
552
|
+
"LN10",
|
|
553
|
+
"LOG2E",
|
|
554
|
+
"LOG10E",
|
|
555
|
+
"PI",
|
|
556
|
+
"SQRT1_2",
|
|
557
|
+
"SQRT2",
|
|
558
|
+
"abs",
|
|
559
|
+
"acos",
|
|
560
|
+
"acosh",
|
|
561
|
+
"asin",
|
|
562
|
+
"asinh",
|
|
563
|
+
"atan",
|
|
564
|
+
"atanh",
|
|
565
|
+
"atan2",
|
|
566
|
+
"cbrt",
|
|
567
|
+
"ceil",
|
|
568
|
+
"cos",
|
|
569
|
+
"cosh",
|
|
570
|
+
"exp",
|
|
571
|
+
"expm1",
|
|
572
|
+
"floor",
|
|
573
|
+
"fround",
|
|
574
|
+
"hypot",
|
|
575
|
+
"log",
|
|
576
|
+
"log1p",
|
|
577
|
+
"log10",
|
|
578
|
+
"log2",
|
|
579
|
+
"max",
|
|
580
|
+
"min",
|
|
581
|
+
"pow",
|
|
582
|
+
"random",
|
|
583
|
+
"round",
|
|
584
|
+
"sign",
|
|
585
|
+
"sin",
|
|
586
|
+
"sinh",
|
|
587
|
+
"sqrt",
|
|
588
|
+
"tan",
|
|
589
|
+
"tanh"
|
|
590
|
+
], Mt = new RegExp(
|
|
591
|
+
[
|
|
592
|
+
// Allow the 4 basic operations, parentheses and all numbers/decimals, as well
|
|
593
|
+
// as 'x', for the variable usage.
|
|
594
|
+
"[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]"
|
|
595
|
+
].concat(ct).join("|"),
|
|
596
|
+
"g"
|
|
597
|
+
);
|
|
598
|
+
function Et(i) {
|
|
599
|
+
const t = i.match(Mt);
|
|
600
|
+
for (let e = t.length - 1; e >= 0; --e)
|
|
601
|
+
ct.indexOf(t[e]) >= 0 && (t[e] = `Math.${t[e]}`);
|
|
602
|
+
return i = t.join(""), new Function("x", `return ${i};`);
|
|
603
|
+
}
|
|
604
|
+
class G {
|
|
605
|
+
constructor(t) {
|
|
606
|
+
// *MUST* happen after other behaviors do initialization so that we can read initial transformations
|
|
607
|
+
s(this, "order", p.Late);
|
|
608
|
+
/**
|
|
609
|
+
* The function representing the path the particle should take.
|
|
610
|
+
*/
|
|
611
|
+
s(this, "path");
|
|
612
|
+
s(this, "list");
|
|
613
|
+
s(this, "minMult");
|
|
614
|
+
if (t.path)
|
|
615
|
+
if (typeof t.path == "function")
|
|
616
|
+
this.path = t.path;
|
|
617
|
+
else
|
|
618
|
+
try {
|
|
619
|
+
this.path = Et(t.path);
|
|
620
|
+
} catch {
|
|
621
|
+
this.path = null;
|
|
622
|
+
}
|
|
623
|
+
else
|
|
624
|
+
this.path = (e) => e;
|
|
625
|
+
this.list = new R(!1), this.list.reset(P.createList(t.speed)), this.minMult = t.minMult ?? 1;
|
|
626
|
+
}
|
|
627
|
+
initParticles(t) {
|
|
628
|
+
let e = t;
|
|
629
|
+
for (; e; ) {
|
|
630
|
+
e.config.initRotation = e.rotation, e.config.initPosition ? e.config.initPosition.copyFrom(e.position) : e.config.initPosition = new C(e.x, e.y), e.config.movement = 0;
|
|
631
|
+
const a = Math.random() * (1 - this.minMult) + this.minMult;
|
|
632
|
+
e.config.speedMult = a, e = e.next;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
updateParticle(t, e) {
|
|
636
|
+
const a = this.list.interpolate(t.agePercent) * t.config.speedMult;
|
|
637
|
+
t.config.movement += a * e, E.x = t.config.movement, E.y = this.path(E.x), w(t.config.initRotation, E), t.position.x = t.config.initPosition.x + E.x, t.position.y = t.config.initPosition.y + E.y;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
s(G, "type", "movePath"), s(G, "editorConfig", null);
|
|
641
|
+
class z {
|
|
642
|
+
constructor() {
|
|
643
|
+
s(this, "order", p.Spawn);
|
|
644
|
+
}
|
|
645
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
646
|
+
initParticles(t) {
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
s(z, "type", "spawnPoint"), s(z, "editorConfig", null);
|
|
650
|
+
class $ {
|
|
651
|
+
constructor(t) {
|
|
652
|
+
s(this, "order", p.Normal);
|
|
653
|
+
s(this, "textures");
|
|
654
|
+
this.textures = t.textures.map((e) => typeof e == "string" ? F(e) : e);
|
|
655
|
+
}
|
|
656
|
+
initParticles(t) {
|
|
657
|
+
let e = t;
|
|
658
|
+
for (; e; ) {
|
|
659
|
+
const a = Math.floor(Math.random() * this.textures.length);
|
|
660
|
+
e.texture = this.textures[a], e = e.next;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
s($, "type", "textureRandom"), s($, "editorConfig", null);
|
|
665
|
+
class Q {
|
|
666
|
+
constructor(t) {
|
|
667
|
+
s(this, "order", p.Normal);
|
|
668
|
+
s(this, "minStart");
|
|
669
|
+
s(this, "maxStart");
|
|
670
|
+
s(this, "minSpeed");
|
|
671
|
+
s(this, "maxSpeed");
|
|
672
|
+
s(this, "accel");
|
|
673
|
+
this.minStart = t.minStart * _, this.maxStart = t.maxStart * _, this.minSpeed = t.minSpeed * _, this.maxSpeed = t.maxSpeed * _, this.accel = t.accel * _;
|
|
674
|
+
}
|
|
675
|
+
initParticles(t) {
|
|
676
|
+
let e = t;
|
|
677
|
+
for (; e; )
|
|
678
|
+
this.minStart === this.maxStart ? e.rotation += this.maxStart : e.rotation += Math.random() * (this.maxStart - this.minStart) + this.minStart, e.config.rotSpeed = Math.random() * (this.maxSpeed - this.minSpeed) + this.minSpeed, e = e.next;
|
|
679
|
+
}
|
|
680
|
+
updateParticle(t, e) {
|
|
681
|
+
if (this.accel) {
|
|
682
|
+
const a = t.config.rotSpeed;
|
|
683
|
+
t.config.rotSpeed += this.accel * e, t.rotation += (t.config.rotSpeed + a) / 2 * e;
|
|
684
|
+
} else
|
|
685
|
+
t.rotation += t.config.rotSpeed * e;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
s(Q, "type", "rotation"), s(Q, "editorConfig", null);
|
|
689
|
+
class H {
|
|
690
|
+
constructor(t) {
|
|
691
|
+
s(this, "order", p.Normal);
|
|
692
|
+
s(this, "min");
|
|
693
|
+
s(this, "max");
|
|
694
|
+
this.min = t.min * _, this.max = t.max * _;
|
|
695
|
+
}
|
|
696
|
+
initParticles(t) {
|
|
697
|
+
let e = t;
|
|
698
|
+
for (; e; )
|
|
699
|
+
this.min === this.max ? e.rotation += this.max : e.rotation += Math.random() * (this.max - this.min) + this.min, e = e.next;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
s(H, "type", "rotationStatic"), s(H, "editorConfig", null);
|
|
703
|
+
class J {
|
|
704
|
+
constructor(t) {
|
|
705
|
+
s(this, "order", p.Late + 1);
|
|
706
|
+
s(this, "rotation");
|
|
707
|
+
this.rotation = (t.rotation || 0) * _;
|
|
708
|
+
}
|
|
709
|
+
initParticles(t) {
|
|
710
|
+
let e = t;
|
|
711
|
+
for (; e; )
|
|
712
|
+
e.rotation = this.rotation, e = e.next;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
s(J, "type", "noRotation"), s(J, "editorConfig", null);
|
|
716
|
+
class K {
|
|
717
|
+
constructor(t) {
|
|
718
|
+
s(this, "order", p.Normal);
|
|
719
|
+
s(this, "list");
|
|
720
|
+
s(this, "minMult");
|
|
721
|
+
this.list = new R(!1), this.list.reset(P.createList(t.scale)), this.minMult = t.minMult ?? 1;
|
|
722
|
+
}
|
|
723
|
+
initParticles(t) {
|
|
724
|
+
let e = t;
|
|
725
|
+
for (; e; ) {
|
|
726
|
+
const a = Math.random() * (1 - this.minMult) + this.minMult;
|
|
727
|
+
e.config.scaleMult = a, e.scale.x = e.scale.y = this.list.first.value * a, e = e.next;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
updateParticle(t) {
|
|
731
|
+
t.scale.x = t.scale.y = this.list.interpolate(t.agePercent) * t.config.scaleMult;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
s(K, "type", "scale"), s(K, "editorConfig", null);
|
|
735
|
+
class Z {
|
|
736
|
+
constructor(t) {
|
|
737
|
+
s(this, "order", p.Normal);
|
|
738
|
+
s(this, "min");
|
|
739
|
+
s(this, "max");
|
|
740
|
+
this.min = t.min, this.max = t.max;
|
|
741
|
+
}
|
|
742
|
+
initParticles(t) {
|
|
743
|
+
let e = t;
|
|
744
|
+
for (; e; ) {
|
|
745
|
+
const a = Math.random() * (this.max - this.min) + this.min;
|
|
746
|
+
e.scale.x = e.scale.y = a, e = e.next;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
s(Z, "type", "scaleStatic"), s(Z, "editorConfig", null);
|
|
751
|
+
const L = class L {
|
|
752
|
+
constructor(t) {
|
|
753
|
+
s(this, "order", p.Spawn);
|
|
754
|
+
s(this, "shape");
|
|
755
|
+
const e = L.shapes[t.type];
|
|
756
|
+
if (!e)
|
|
757
|
+
throw new Error(`No shape found with type '${t.type}'`);
|
|
758
|
+
this.shape = new e(t.data);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Registers a shape to be used by the ShapeSpawn behavior.
|
|
762
|
+
* @param constructor The shape class constructor to use, with a static `type` property to reference it by.
|
|
763
|
+
* @param typeOverride An optional type override, primarily for registering a shape under multiple names.
|
|
764
|
+
*/
|
|
765
|
+
static registerShape(t, e) {
|
|
766
|
+
L.shapes[e || t.type] = t;
|
|
767
|
+
}
|
|
768
|
+
initParticles(t) {
|
|
769
|
+
let e = t;
|
|
770
|
+
for (; e; )
|
|
771
|
+
this.shape.getRandPos(e), e = e.next;
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
s(L, "type", "spawnShape"), s(L, "editorConfig", null), /**
|
|
775
|
+
* Dictionary of all registered shape classes.
|
|
776
|
+
*/
|
|
777
|
+
s(L, "shapes", {});
|
|
778
|
+
let S = L;
|
|
779
|
+
S.registerShape(O);
|
|
780
|
+
S.registerShape(A);
|
|
781
|
+
S.registerShape(T);
|
|
782
|
+
S.registerShape(T, "circle");
|
|
783
|
+
class tt {
|
|
784
|
+
constructor(t) {
|
|
785
|
+
s(this, "order", p.Normal);
|
|
786
|
+
s(this, "texture");
|
|
787
|
+
this.texture = typeof t.texture == "string" ? F(t.texture) : t.texture;
|
|
788
|
+
}
|
|
789
|
+
initParticles(t) {
|
|
790
|
+
let e = t;
|
|
791
|
+
for (; e; )
|
|
792
|
+
e.texture = this.texture, e = e.next;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
s(tt, "type", "textureSingle"), s(tt, "editorConfig", null);
|
|
796
|
+
class et {
|
|
797
|
+
constructor(t) {
|
|
798
|
+
s(this, "order", p.Late);
|
|
799
|
+
s(this, "list");
|
|
800
|
+
s(this, "minMult");
|
|
801
|
+
this.list = new R(!1), this.list.reset(P.createList(t.speed)), this.minMult = t.minMult ?? 1;
|
|
802
|
+
}
|
|
803
|
+
initParticles(t) {
|
|
804
|
+
let e = t;
|
|
805
|
+
for (; e; ) {
|
|
806
|
+
const a = Math.random() * (1 - this.minMult) + this.minMult;
|
|
807
|
+
e.config.speedMult = a, e.config.velocity ? e.config.velocity.set(this.list.first.value * a, 0) : e.config.velocity = new C(this.list.first.value * a, 0), w(e.rotation, e.config.velocity), e = e.next;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
updateParticle(t, e) {
|
|
811
|
+
const a = this.list.interpolate(t.agePercent) * t.config.speedMult, r = t.config.velocity;
|
|
812
|
+
lt(r), rt(r, a), t.x += r.x * e, t.y += r.y * e;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
s(et, "type", "moveSpeed"), s(et, "editorConfig", null);
|
|
816
|
+
class it {
|
|
817
|
+
constructor(t) {
|
|
818
|
+
s(this, "order", p.Late);
|
|
819
|
+
s(this, "min");
|
|
820
|
+
s(this, "max");
|
|
821
|
+
this.min = t.min, this.max = t.max;
|
|
822
|
+
}
|
|
823
|
+
initParticles(t) {
|
|
824
|
+
let e = t;
|
|
825
|
+
for (; e; ) {
|
|
826
|
+
const a = Math.random() * (this.max - this.min) + this.min;
|
|
827
|
+
e.config.velocity ? e.config.velocity.set(a, 0) : e.config.velocity = new C(a, 0), w(e.rotation, e.config.velocity), e = e.next;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
updateParticle(t, e) {
|
|
831
|
+
const { velocity: a } = t.config;
|
|
832
|
+
t.x += a.x * e, t.y += a.y * e;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
s(it, "type", "moveSpeedStatic"), s(it, "editorConfig", null);
|
|
836
|
+
const Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
837
|
+
__proto__: null,
|
|
838
|
+
AccelerationBehavior: I,
|
|
839
|
+
AlphaBehavior: V,
|
|
840
|
+
BehaviorOrder: p,
|
|
841
|
+
BlendModeBehavior: W,
|
|
842
|
+
BurstSpawnBehavior: Y,
|
|
843
|
+
ColorBehavior: D,
|
|
844
|
+
NoRotationBehavior: J,
|
|
845
|
+
OrderedTextureBehavior: j,
|
|
846
|
+
PathBehavior: G,
|
|
847
|
+
PointSpawnBehavior: z,
|
|
848
|
+
RandomAnimatedTextureBehavior: N,
|
|
849
|
+
RandomTextureBehavior: $,
|
|
850
|
+
RotationBehavior: Q,
|
|
851
|
+
ScaleBehavior: K,
|
|
852
|
+
ShapeSpawnBehavior: S,
|
|
853
|
+
SingleAnimatedTextureBehavior: U,
|
|
854
|
+
SingleTextureBehavior: tt,
|
|
855
|
+
SpeedBehavior: et,
|
|
856
|
+
StaticAlphaBehavior: q,
|
|
857
|
+
StaticColorBehavior: X,
|
|
858
|
+
StaticRotationBehavior: H,
|
|
859
|
+
StaticScaleBehavior: Z,
|
|
860
|
+
StaticSpeedBehavior: it,
|
|
861
|
+
editor: _t,
|
|
862
|
+
spawnShapes: Pt
|
|
863
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
864
|
+
class Ft {
|
|
865
|
+
constructor(t) {
|
|
866
|
+
this.particle = t;
|
|
867
|
+
}
|
|
868
|
+
get x() {
|
|
869
|
+
return this.particle.x;
|
|
870
|
+
}
|
|
871
|
+
set x(t) {
|
|
872
|
+
this.particle.x = t;
|
|
873
|
+
}
|
|
874
|
+
get y() {
|
|
875
|
+
return this.particle.y;
|
|
876
|
+
}
|
|
877
|
+
set y(t) {
|
|
878
|
+
this.particle.y = t;
|
|
879
|
+
}
|
|
880
|
+
set(t = 0, e = t) {
|
|
881
|
+
this.particle.x = t, this.particle.y = e;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
class Tt {
|
|
885
|
+
constructor(t) {
|
|
886
|
+
this.particle = t;
|
|
887
|
+
}
|
|
888
|
+
get x() {
|
|
889
|
+
return this.particle.scaleX;
|
|
890
|
+
}
|
|
891
|
+
set x(t) {
|
|
892
|
+
this.particle.scaleX = t;
|
|
893
|
+
}
|
|
894
|
+
get y() {
|
|
895
|
+
return this.particle.scaleY;
|
|
896
|
+
}
|
|
897
|
+
set y(t) {
|
|
898
|
+
this.particle.scaleY = t;
|
|
899
|
+
}
|
|
900
|
+
set(t = 0, e = t) {
|
|
901
|
+
this.particle.scaleX = t, this.particle.scaleY = e;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
class Bt {
|
|
905
|
+
constructor(t) {
|
|
906
|
+
this.particle = t;
|
|
907
|
+
}
|
|
908
|
+
get x() {
|
|
909
|
+
return this.particle.anchorX;
|
|
910
|
+
}
|
|
911
|
+
set x(t) {
|
|
912
|
+
this.particle.anchorX = t;
|
|
913
|
+
}
|
|
914
|
+
get y() {
|
|
915
|
+
return this.particle.anchorY;
|
|
916
|
+
}
|
|
917
|
+
set y(t) {
|
|
918
|
+
this.particle.anchorY = t;
|
|
919
|
+
}
|
|
920
|
+
set(t = 0, e = t) {
|
|
921
|
+
this.particle.anchorX = t, this.particle.anchorY = e;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
class kt extends mt {
|
|
925
|
+
/**
|
|
926
|
+
* @param emitter The emitter that controls this particle.
|
|
927
|
+
*/
|
|
928
|
+
constructor(e) {
|
|
929
|
+
super({ texture: B.EMPTY, anchorX: 0.5, anchorY: 0.5 });
|
|
930
|
+
/**
|
|
931
|
+
* The emitter that controls this particle.
|
|
932
|
+
*/
|
|
933
|
+
s(this, "emitter");
|
|
934
|
+
/**
|
|
935
|
+
* The maximum lifetime of this particle, in seconds.
|
|
936
|
+
*/
|
|
937
|
+
s(this, "maxLife");
|
|
938
|
+
/**
|
|
939
|
+
* The current age of the particle, in seconds.
|
|
940
|
+
*/
|
|
941
|
+
s(this, "age");
|
|
942
|
+
/**
|
|
943
|
+
* The current age of the particle as a normalized value between 0 and 1.
|
|
944
|
+
*/
|
|
945
|
+
s(this, "agePercent");
|
|
946
|
+
/**
|
|
947
|
+
* One divided by the max life of the particle, saved for slightly faster math.
|
|
948
|
+
*/
|
|
949
|
+
s(this, "oneOverLife");
|
|
950
|
+
/**
|
|
951
|
+
* Reference to the next particle in the list.
|
|
952
|
+
*/
|
|
953
|
+
s(this, "next");
|
|
954
|
+
/**
|
|
955
|
+
* Reference to the previous particle in the list.
|
|
956
|
+
*/
|
|
957
|
+
s(this, "prev");
|
|
958
|
+
s(this, "prevChild");
|
|
959
|
+
s(this, "nextChild");
|
|
960
|
+
/**
|
|
961
|
+
* Static per-particle configuration for behaviors to use. Is not cleared when recycling.
|
|
962
|
+
*/
|
|
963
|
+
s(this, "config");
|
|
964
|
+
/** Принимается от BlendModeBehavior, но ParticleContainer рендерит одним блендом — игнорируется */
|
|
965
|
+
s(this, "blendMode");
|
|
966
|
+
/** Флаг видимости для совместимости с эмиттером; рендер частицы им не управляет */
|
|
967
|
+
s(this, "visible");
|
|
968
|
+
/** ParticleContainer не является родителем в терминах сцен-графа — удаление делает эмиттер */
|
|
969
|
+
s(this, "parent", null);
|
|
970
|
+
s(this, "position");
|
|
971
|
+
s(this, "scale");
|
|
972
|
+
s(this, "anchor");
|
|
973
|
+
this.position = new Ft(this), this.scale = new Tt(this), this.anchor = new Bt(this), this.prevChild = this.nextChild = null, this.emitter = e, this.config = {}, this.visible = !0, this.maxLife = 0, this.age = 0, this.agePercent = 0, this.oneOverLife = 0, this.next = null, this.prev = null;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Initializes the particle for use, based on the properties that have to
|
|
977
|
+
* have been set already on the particle.
|
|
978
|
+
*/
|
|
979
|
+
init(e) {
|
|
980
|
+
this.maxLife = e, this.age = this.agePercent = 0, this.rotation = 0, this.x = this.y = 0, this.scaleX = this.scaleY = 1, this.tint = 16777215, this.alpha = 1, this.oneOverLife = 1 / this.maxLife, this.visible = !0;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Kills the particle, removing it from the display list
|
|
984
|
+
* and telling the emitter to recycle it.
|
|
985
|
+
*/
|
|
986
|
+
kill() {
|
|
987
|
+
this.emitter.recycle(this);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Destroys the particle, removing references and preventing future use.
|
|
991
|
+
*/
|
|
992
|
+
destroy() {
|
|
993
|
+
this.emitter = this.next = this.prev = null;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
class Rt extends dt {
|
|
997
|
+
/**
|
|
998
|
+
* @param emitter The emitter that controls this particle.
|
|
999
|
+
*/
|
|
1000
|
+
constructor(e) {
|
|
1001
|
+
super();
|
|
1002
|
+
/**
|
|
1003
|
+
* The emitter that controls this particle.
|
|
1004
|
+
*/
|
|
1005
|
+
s(this, "emitter");
|
|
1006
|
+
/**
|
|
1007
|
+
* The maximum lifetime of this particle, in seconds.
|
|
1008
|
+
*/
|
|
1009
|
+
s(this, "maxLife");
|
|
1010
|
+
/**
|
|
1011
|
+
* The current age of the particle, in seconds.
|
|
1012
|
+
*/
|
|
1013
|
+
s(this, "age");
|
|
1014
|
+
/**
|
|
1015
|
+
* The current age of the particle as a normalized value between 0 and 1.
|
|
1016
|
+
*/
|
|
1017
|
+
s(this, "agePercent");
|
|
1018
|
+
/**
|
|
1019
|
+
* One divided by the max life of the particle, saved for slightly faster math.
|
|
1020
|
+
*/
|
|
1021
|
+
s(this, "oneOverLife");
|
|
1022
|
+
/**
|
|
1023
|
+
* Reference to the next particle in the list.
|
|
1024
|
+
*/
|
|
1025
|
+
s(this, "next");
|
|
1026
|
+
/**
|
|
1027
|
+
* Reference to the previous particle in the list.
|
|
1028
|
+
*/
|
|
1029
|
+
s(this, "prev");
|
|
1030
|
+
s(this, "prevChild");
|
|
1031
|
+
s(this, "nextChild");
|
|
1032
|
+
/**
|
|
1033
|
+
* Static per-particle configuration for behaviors to use. Is not cleared when recycling.
|
|
1034
|
+
*/
|
|
1035
|
+
s(this, "config");
|
|
1036
|
+
this.prevChild = this.nextChild = null, this.emitter = e, this.config = {}, this.anchor.x = this.anchor.y = 0.5, this.maxLife = 0, this.age = 0, this.agePercent = 0, this.oneOverLife = 0, this.next = null, this.prev = null, this.init = this.init, this.kill = this.kill;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Initializes the particle for use, based on the properties that have to
|
|
1040
|
+
* have been set already on the particle.
|
|
1041
|
+
*/
|
|
1042
|
+
init(e) {
|
|
1043
|
+
this.maxLife = e, this.age = this.agePercent = 0, this.rotation = 0, this.position.x = this.position.y = 0, this.scale.x = this.scale.y = 1, this.tint = 16777215, this.alpha = 1, this.oneOverLife = 1 / this.maxLife, this.visible = !0;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Kills the particle, removing it from the display list
|
|
1047
|
+
* and telling the emitter to recycle it.
|
|
1048
|
+
*/
|
|
1049
|
+
kill() {
|
|
1050
|
+
this.emitter.recycle(this);
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Destroys the particle, removing references and preventing future use.
|
|
1054
|
+
*/
|
|
1055
|
+
destroy() {
|
|
1056
|
+
this.parent && this.parent.removeChild(this), this.emitter = this.next = this.prev = null, super.destroy();
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
const st = ft.shared, b = Symbol("Position particle per emitter position"), M = class M {
|
|
1060
|
+
/**
|
|
1061
|
+
* @param particleParent The container to add the particles to.
|
|
1062
|
+
* @param particleImages A texture or array of textures to use
|
|
1063
|
+
* for the particles. Strings will be turned
|
|
1064
|
+
* into textures via Texture.from().
|
|
1065
|
+
* @param config A configuration object containing settings for the emitter.
|
|
1066
|
+
* @param config.emit If config.emit is explicitly passed as false, the
|
|
1067
|
+
* Emitter will start disabled.
|
|
1068
|
+
* @param config.autoUpdate If config.autoUpdate is explicitly passed as
|
|
1069
|
+
* true, the Emitter will automatically call
|
|
1070
|
+
* update via the PIXI shared ticker.
|
|
1071
|
+
*/
|
|
1072
|
+
constructor(t, e) {
|
|
1073
|
+
/**
|
|
1074
|
+
* Active initialization behaviors for this emitter.
|
|
1075
|
+
*/
|
|
1076
|
+
s(this, "initBehaviors");
|
|
1077
|
+
/**
|
|
1078
|
+
* Active update behaviors for this emitter.
|
|
1079
|
+
*/
|
|
1080
|
+
s(this, "updateBehaviors");
|
|
1081
|
+
/**
|
|
1082
|
+
* Active recycle behaviors for this emitter.
|
|
1083
|
+
*/
|
|
1084
|
+
s(this, "recycleBehaviors");
|
|
1085
|
+
// properties for individual particles
|
|
1086
|
+
/**
|
|
1087
|
+
* The minimum lifetime for a particle, in seconds.
|
|
1088
|
+
*/
|
|
1089
|
+
s(this, "minLifetime");
|
|
1090
|
+
/**
|
|
1091
|
+
* The maximum lifetime for a particle, in seconds.
|
|
1092
|
+
*/
|
|
1093
|
+
s(this, "maxLifetime");
|
|
1094
|
+
/**
|
|
1095
|
+
* An easing function for nonlinear interpolation of values. Accepts a single
|
|
1096
|
+
* parameter of time as a value from 0-1, inclusive. Expected outputs are values
|
|
1097
|
+
* from 0-1, inclusive.
|
|
1098
|
+
*/
|
|
1099
|
+
s(this, "customEase");
|
|
1100
|
+
// properties for spawning particles
|
|
1101
|
+
/**
|
|
1102
|
+
* Time between particle spawns in seconds.
|
|
1103
|
+
*/
|
|
1104
|
+
s(this, "_frequency");
|
|
1105
|
+
/**
|
|
1106
|
+
* Chance that a particle will be spawned on each opportunity to spawn one.
|
|
1107
|
+
* 0 is 0%, 1 is 100%.
|
|
1108
|
+
*/
|
|
1109
|
+
s(this, "spawnChance");
|
|
1110
|
+
/**
|
|
1111
|
+
* Maximum number of particles to keep alive at a time. If this limit
|
|
1112
|
+
* is reached, no more particles will spawn until some have died.
|
|
1113
|
+
*/
|
|
1114
|
+
s(this, "maxParticles");
|
|
1115
|
+
/**
|
|
1116
|
+
* The amount of time in seconds to emit for before setting emit to false.
|
|
1117
|
+
* A value of -1 is an unlimited amount of time.
|
|
1118
|
+
*/
|
|
1119
|
+
s(this, "emitterLifetime");
|
|
1120
|
+
/**
|
|
1121
|
+
* Position at which to spawn particles, relative to the emitter's owner's origin.
|
|
1122
|
+
* For example, the flames of a rocket travelling right might have a spawnPos
|
|
1123
|
+
* of {x:-50, y:0}.
|
|
1124
|
+
* to spawn at the rear of the rocket.
|
|
1125
|
+
* To change this, use updateSpawnPos().
|
|
1126
|
+
*/
|
|
1127
|
+
s(this, "spawnPos");
|
|
1128
|
+
/**
|
|
1129
|
+
* Number of particles to spawn time that the frequency allows for particles to spawn.
|
|
1130
|
+
*/
|
|
1131
|
+
s(this, "particlesPerWave");
|
|
1132
|
+
/**
|
|
1133
|
+
* Rotation of the emitter or emitter's owner in degrees. This is added to
|
|
1134
|
+
* the calculated spawn angle.
|
|
1135
|
+
* To change this, use rotate().
|
|
1136
|
+
*/
|
|
1137
|
+
s(this, "rotation");
|
|
1138
|
+
/**
|
|
1139
|
+
* The world position of the emitter's owner, to add spawnPos to when
|
|
1140
|
+
* spawning particles. To change this, use updateOwnerPos().
|
|
1141
|
+
*/
|
|
1142
|
+
s(this, "ownerPos");
|
|
1143
|
+
/**
|
|
1144
|
+
* The origin + spawnPos in the previous update, so that the spawn position
|
|
1145
|
+
* can be interpolated to space out particles better.
|
|
1146
|
+
*/
|
|
1147
|
+
s(this, "_prevEmitterPos");
|
|
1148
|
+
/**
|
|
1149
|
+
* If _prevEmitterPos is valid, to prevent interpolation on the first update
|
|
1150
|
+
*/
|
|
1151
|
+
s(this, "_prevPosIsValid");
|
|
1152
|
+
/**
|
|
1153
|
+
* If either ownerPos or spawnPos has changed since the previous update.
|
|
1154
|
+
*/
|
|
1155
|
+
s(this, "_posChanged");
|
|
1156
|
+
/**
|
|
1157
|
+
* The container to add particles to.
|
|
1158
|
+
*/
|
|
1159
|
+
s(this, "_parent");
|
|
1160
|
+
/**
|
|
1161
|
+
* If particles should be added at the back of the display list instead of the front.
|
|
1162
|
+
*/
|
|
1163
|
+
s(this, "addAtBack");
|
|
1164
|
+
/**
|
|
1165
|
+
* The current number of active particles.
|
|
1166
|
+
*/
|
|
1167
|
+
s(this, "particleCount");
|
|
1168
|
+
/**
|
|
1169
|
+
* If particles should be emitted during update() calls. Setting this to false
|
|
1170
|
+
* stops new particles from being created, but allows existing ones to die out.
|
|
1171
|
+
*/
|
|
1172
|
+
s(this, "_emit");
|
|
1173
|
+
/**
|
|
1174
|
+
* The timer for when to spawn particles in seconds, where numbers less
|
|
1175
|
+
* than 0 mean that particles should be spawned.
|
|
1176
|
+
*/
|
|
1177
|
+
s(this, "_spawnTimer");
|
|
1178
|
+
/**
|
|
1179
|
+
* The life of the emitter in seconds.
|
|
1180
|
+
*/
|
|
1181
|
+
s(this, "_emitterLife");
|
|
1182
|
+
/**
|
|
1183
|
+
* The particles that are active and on the display list. This is the first particle in a
|
|
1184
|
+
* linked list.
|
|
1185
|
+
*/
|
|
1186
|
+
s(this, "_activeParticlesFirst");
|
|
1187
|
+
/**
|
|
1188
|
+
* The particles that are active and on the display list. This is the last particle in a
|
|
1189
|
+
* linked list.
|
|
1190
|
+
*/
|
|
1191
|
+
s(this, "_activeParticlesLast");
|
|
1192
|
+
/**
|
|
1193
|
+
* The particles that are not currently being used. This is the first particle in a
|
|
1194
|
+
* linked list.
|
|
1195
|
+
*/
|
|
1196
|
+
s(this, "_poolFirst");
|
|
1197
|
+
/**
|
|
1198
|
+
* The original config object that this emitter was initialized with.
|
|
1199
|
+
*/
|
|
1200
|
+
s(this, "_origConfig");
|
|
1201
|
+
/**
|
|
1202
|
+
* If the update function is called automatically from the shared ticker.
|
|
1203
|
+
* Setting this to false requires calling the update function manually.
|
|
1204
|
+
*/
|
|
1205
|
+
s(this, "_autoUpdate");
|
|
1206
|
+
/**
|
|
1207
|
+
* Родитель является PIXI.ParticleContainer (частицы добавляются через addParticle)
|
|
1208
|
+
*/
|
|
1209
|
+
s(this, "_isParticleContainer");
|
|
1210
|
+
/**
|
|
1211
|
+
* If the emitter should destroy itself when all particles have died out. This is set by
|
|
1212
|
+
* playOnceAndDestroy();
|
|
1213
|
+
*/
|
|
1214
|
+
s(this, "_destroyWhenComplete");
|
|
1215
|
+
/**
|
|
1216
|
+
* A callback for when all particles have died out. This is set by
|
|
1217
|
+
* playOnceAndDestroy() or playOnce();
|
|
1218
|
+
*/
|
|
1219
|
+
s(this, "_completeCallback");
|
|
1220
|
+
this.initBehaviors = [], this.updateBehaviors = [], this.recycleBehaviors = [], this.minLifetime = 0, this.maxLifetime = 0, this.customEase = null, this._frequency = 1, this.spawnChance = 1, this.maxParticles = 1e3, this.emitterLifetime = -1, this.spawnPos = new C(), this.particlesPerWave = 1, this.rotation = 0, this.ownerPos = new C(), this._prevEmitterPos = new C(), this._prevPosIsValid = !1, this._posChanged = !1, this._parent = null, this._isParticleContainer = !1, this.addAtBack = !1, this.particleCount = 0, this._emit = !1, this._spawnTimer = 0, this._emitterLife = -1, this._activeParticlesFirst = null, this._activeParticlesLast = null, this._poolFirst = null, this._origConfig = null, this._autoUpdate = !1, this._destroyWhenComplete = !1, this._completeCallback = null, this.parent = t, e && this.init(e), this.recycle = this.recycle, this.update = this.update, this.rotate = this.rotate, this.updateSpawnPos = this.updateSpawnPos, this.updateOwnerPos = this.updateOwnerPos;
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Registers a new behavior, so that it will be recognized when initializing emitters.
|
|
1224
|
+
* Behaviors registered later with duplicate types will override older ones, although there is no limit on
|
|
1225
|
+
* the allowed types.
|
|
1226
|
+
* @param constructor The behavior class to register.
|
|
1227
|
+
*/
|
|
1228
|
+
static registerBehavior(t) {
|
|
1229
|
+
M.knownBehaviors[t.type] = t;
|
|
1230
|
+
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Time between particle spawns in seconds. If this value is not a number greater than 0,
|
|
1233
|
+
* it will be set to 1 (particle per second) to prevent infinite loops.
|
|
1234
|
+
*/
|
|
1235
|
+
get frequency() {
|
|
1236
|
+
return this._frequency;
|
|
1237
|
+
}
|
|
1238
|
+
set frequency(t) {
|
|
1239
|
+
typeof t == "number" && t > 0 ? this._frequency = t : this._frequency = 1;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* The container to add particles to. Settings this will dump any active particles.
|
|
1243
|
+
*/
|
|
1244
|
+
get parent() {
|
|
1245
|
+
return this._parent;
|
|
1246
|
+
}
|
|
1247
|
+
set parent(t) {
|
|
1248
|
+
this.cleanup();
|
|
1249
|
+
const e = t instanceof xt;
|
|
1250
|
+
e !== this._isParticleContainer && (this._poolFirst = null), this._isParticleContainer = e, this._parent = t;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* Создать частицу подходящего класса: лёгкую для ParticleContainer или спрайтовую для обычного контейнера
|
|
1254
|
+
*/
|
|
1255
|
+
_createParticle() {
|
|
1256
|
+
return this._isParticleContainer ? new kt(this) : new Rt(this);
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Добавить частицу в контейнер (addParticle для ParticleContainer, addChild для обычного)
|
|
1260
|
+
*/
|
|
1261
|
+
_addParticleToParent(t) {
|
|
1262
|
+
this._isParticleContainer ? this._parent.addParticle(t) : this.addAtBack ? this._parent.addChildAt(t, 0) : this._parent.addChild(t);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Sets up the emitter based on the config settings.
|
|
1266
|
+
* @param config A configuration object containing settings for the emitter.
|
|
1267
|
+
*/
|
|
1268
|
+
init(t) {
|
|
1269
|
+
if (!t)
|
|
1270
|
+
return;
|
|
1271
|
+
this.cleanup(), this._origConfig = t, this.minLifetime = t.lifetime.min, this.maxLifetime = t.lifetime.max, t.ease ? this.customEase = typeof t.ease == "function" ? t.ease : nt(t.ease) : this.customEase = null, this.particlesPerWave = 1, t.particlesPerWave && t.particlesPerWave > 1 && (this.particlesPerWave = t.particlesPerWave), this.frequency = t.frequency, this.spawnChance = typeof t.spawnChance == "number" && t.spawnChance > 0 ? t.spawnChance : 1, this.emitterLifetime = t.emitterLifetime || -1, this.maxParticles = t.maxParticles > 0 ? t.maxParticles : 1e3, this.addAtBack = !!t.addAtBack, this.rotation = 0, this.ownerPos.set(0), t.pos ? this.spawnPos.copyFrom(t.pos) : this.spawnPos.set(0), this._prevEmitterPos.copyFrom(this.spawnPos), this._prevPosIsValid = !1, this._spawnTimer = 0, this.emit = t.emit === void 0 ? !0 : !!t.emit, this.autoUpdate = !!t.autoUpdate;
|
|
1272
|
+
const e = t.behaviors.map((a) => {
|
|
1273
|
+
const r = M.knownBehaviors[a.type];
|
|
1274
|
+
return r ? new r(a.config) : (console.error(`Unknown behavior: ${a.type}`), null);
|
|
1275
|
+
}).filter((a) => !!a);
|
|
1276
|
+
e.push(b), e.sort((a, r) => a === b ? r.order === p.Spawn ? 1 : -1 : r === b ? a.order === p.Spawn ? -1 : 1 : a.order - r.order), this.initBehaviors = e.slice(), this.updateBehaviors = e.filter((a) => a !== b && a.updateParticle), this.recycleBehaviors = e.filter(
|
|
1277
|
+
(a) => a !== b && a.recycleParticle
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Gets the instantiated behavior of the specified type, if it is present on this emitter.
|
|
1282
|
+
* @param type The behavior type to find.
|
|
1283
|
+
*/
|
|
1284
|
+
getBehavior(t) {
|
|
1285
|
+
return M.knownBehaviors[t] && this.initBehaviors.find((e) => e instanceof M.knownBehaviors[t]) || null;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Fills the pool with the specified number of particles, so that they don't have to be instantiated later.
|
|
1289
|
+
* @param count The number of particles to create.
|
|
1290
|
+
*/
|
|
1291
|
+
fillPool(t) {
|
|
1292
|
+
for (; t > 0; --t) {
|
|
1293
|
+
const e = this._createParticle();
|
|
1294
|
+
e.next = this._poolFirst, this._poolFirst = e;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Recycles an individual particle. For internal use only.
|
|
1299
|
+
* @param particle The particle to recycle.
|
|
1300
|
+
* @param fromCleanup If this is being called to manually clean up all particles.
|
|
1301
|
+
* @internal
|
|
1302
|
+
*/
|
|
1303
|
+
recycle(t, e = !1) {
|
|
1304
|
+
var a;
|
|
1305
|
+
for (let r = 0; r < this.recycleBehaviors.length; ++r)
|
|
1306
|
+
this.recycleBehaviors[r].recycleParticle(t, !e);
|
|
1307
|
+
t.next && (t.next.prev = t.prev), t.prev && (t.prev.next = t.next), t === this._activeParticlesLast && (this._activeParticlesLast = t.prev), t === this._activeParticlesFirst && (this._activeParticlesFirst = t.next), t.prev = null, t.next = this._poolFirst, this._poolFirst = t, this._isParticleContainer ? (a = this._parent) == null || a.removeParticle(t) : t.parent && t.parent.removeChild(t), --this.particleCount;
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Sets the rotation of the emitter to a new value. This rotates the spawn position in addition
|
|
1311
|
+
* to particle direction.
|
|
1312
|
+
* @param newRot The new rotation, in degrees.
|
|
1313
|
+
*/
|
|
1314
|
+
rotate(t) {
|
|
1315
|
+
if (this.rotation === t) return;
|
|
1316
|
+
const e = t - this.rotation;
|
|
1317
|
+
this.rotation = t, w(e, this.spawnPos), this._posChanged = !0;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Changes the spawn position of the emitter.
|
|
1321
|
+
* @param x The new x value of the spawn position for the emitter.
|
|
1322
|
+
* @param y The new y value of the spawn position for the emitter.
|
|
1323
|
+
*/
|
|
1324
|
+
updateSpawnPos(t, e) {
|
|
1325
|
+
this._posChanged = !0, this.spawnPos.x = t, this.spawnPos.y = e;
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Changes the position of the emitter's owner. You should call this if you are adding
|
|
1329
|
+
* particles to the world container that your emitter's owner is moving around in.
|
|
1330
|
+
* @param x The new x value of the emitter's owner.
|
|
1331
|
+
* @param y The new y value of the emitter's owner.
|
|
1332
|
+
*/
|
|
1333
|
+
updateOwnerPos(t, e) {
|
|
1334
|
+
this._posChanged = !0, this.ownerPos.x = t, this.ownerPos.y = e;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Prevents emitter position interpolation in the next update.
|
|
1338
|
+
* This should be used if you made a major position change of your emitter's owner
|
|
1339
|
+
* that was not normal movement.
|
|
1340
|
+
*/
|
|
1341
|
+
resetPositionTracking() {
|
|
1342
|
+
this._prevPosIsValid = !1;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* If particles should be emitted during update() calls. Setting this to false
|
|
1346
|
+
* stops new particles from being created, but allows existing ones to die out.
|
|
1347
|
+
*/
|
|
1348
|
+
get emit() {
|
|
1349
|
+
return this._emit;
|
|
1350
|
+
}
|
|
1351
|
+
set emit(t) {
|
|
1352
|
+
this._emit = !!t, this._emitterLife = this.emitterLifetime;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* If the update function is called automatically from the shared ticker.
|
|
1356
|
+
* Setting this to false requires calling the update function manually.
|
|
1357
|
+
*/
|
|
1358
|
+
get autoUpdate() {
|
|
1359
|
+
return this._autoUpdate;
|
|
1360
|
+
}
|
|
1361
|
+
set autoUpdate(t) {
|
|
1362
|
+
this._autoUpdate && !t ? st.remove(this.update, this) : !this._autoUpdate && t && st.add(this.update, this), this._autoUpdate = !!t;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself
|
|
1366
|
+
* when particle emission is complete.
|
|
1367
|
+
* @param callback Callback for when emission is complete (all particles have died off)
|
|
1368
|
+
*/
|
|
1369
|
+
playOnceAndDestroy(t) {
|
|
1370
|
+
this.autoUpdate = !0, this.emit = !0, this._destroyWhenComplete = !0, this._completeCallback = t;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Starts emitting particles and optionally calls a callback when particle emission is complete.
|
|
1374
|
+
* @param callback Callback for when emission is complete (all particles have died off)
|
|
1375
|
+
*/
|
|
1376
|
+
playOnce(t) {
|
|
1377
|
+
this.emit = !0, this._completeCallback = t;
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Updates all particles spawned by this emitter and emits new ones.
|
|
1381
|
+
* @param delta Time elapsed since the previous frame, in __seconds__.
|
|
1382
|
+
*/
|
|
1383
|
+
update(t) {
|
|
1384
|
+
if (typeof t != "number" && (t = t.deltaMS * 1e-3), this._autoUpdate && (t = st.elapsedMS * 1e-3), !this._parent) return;
|
|
1385
|
+
for (let n = this._activeParticlesFirst, o; n; n = o)
|
|
1386
|
+
if (o = n.next, n.age += t, n.age > n.maxLife || n.age < 0)
|
|
1387
|
+
this.recycle(n);
|
|
1388
|
+
else {
|
|
1389
|
+
let c = n.age * n.oneOverLife;
|
|
1390
|
+
this.customEase && (this.customEase.length === 4 ? c = this.customEase(c, 0, 1, 1) : c = this.customEase(c)), n.agePercent = c;
|
|
1391
|
+
for (let u = 0; u < this.updateBehaviors.length; ++u)
|
|
1392
|
+
if (this.updateBehaviors[u].updateParticle(n, t)) {
|
|
1393
|
+
this.recycle(n);
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
let e, a;
|
|
1398
|
+
this._prevPosIsValid && (e = this._prevEmitterPos.x, a = this._prevEmitterPos.y);
|
|
1399
|
+
const r = this.ownerPos.x + this.spawnPos.x, l = this.ownerPos.y + this.spawnPos.y;
|
|
1400
|
+
if (this._emit)
|
|
1401
|
+
for (this._spawnTimer -= t < 0 ? 0 : t; this._spawnTimer <= 0; ) {
|
|
1402
|
+
if (this._emitterLife >= 0 && (this._emitterLife -= this._frequency, this._emitterLife <= 0)) {
|
|
1403
|
+
this._spawnTimer = 0, this._emitterLife = 0, this.emit = !1;
|
|
1404
|
+
break;
|
|
1405
|
+
}
|
|
1406
|
+
if (this.particleCount >= this.maxParticles) {
|
|
1407
|
+
this._spawnTimer += this._frequency;
|
|
1408
|
+
continue;
|
|
1409
|
+
}
|
|
1410
|
+
let n, o;
|
|
1411
|
+
if (this._prevPosIsValid && this._posChanged) {
|
|
1412
|
+
const d = 1 + this._spawnTimer / t;
|
|
1413
|
+
n = (r - e) * d + e, o = (l - a) * d + a;
|
|
1414
|
+
} else
|
|
1415
|
+
n = r, o = l;
|
|
1416
|
+
let c = null, u = null;
|
|
1417
|
+
for (let d = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount), y = 0; y < d; ++y) {
|
|
1418
|
+
if (this.spawnChance < 1 && Math.random() >= this.spawnChance)
|
|
1419
|
+
continue;
|
|
1420
|
+
let f;
|
|
1421
|
+
if (this.minLifetime === this.maxLifetime ? f = this.minLifetime : f = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime, -this._spawnTimer >= f)
|
|
1422
|
+
continue;
|
|
1423
|
+
let x;
|
|
1424
|
+
this._poolFirst ? (x = this._poolFirst, this._poolFirst = this._poolFirst.next, x.next = null) : x = this._createParticle(), x.init(f), this._addParticleToParent(x), c ? (u.next = x, x.prev = u, u = x) : u = c = x, ++this.particleCount;
|
|
1425
|
+
}
|
|
1426
|
+
if (c) {
|
|
1427
|
+
this._activeParticlesLast ? (this._activeParticlesLast.next = c, c.prev = this._activeParticlesLast, this._activeParticlesLast = u) : (this._activeParticlesFirst = c, this._activeParticlesLast = u);
|
|
1428
|
+
for (let d = 0; d < this.initBehaviors.length; ++d) {
|
|
1429
|
+
const y = this.initBehaviors[d];
|
|
1430
|
+
if (y === b)
|
|
1431
|
+
for (let f = c, x; f; f = x) {
|
|
1432
|
+
x = f.next, this.rotation !== 0 && (w(this.rotation, f.position), f.rotation += this.rotation), f.position.x += n, f.position.y += o, f.age += -this._spawnTimer;
|
|
1433
|
+
let h = f.age * f.oneOverLife;
|
|
1434
|
+
this.customEase && (this.customEase.length === 4 ? h = this.customEase(h, 0, 1, 1) : h = this.customEase(h)), f.agePercent = h;
|
|
1435
|
+
}
|
|
1436
|
+
else
|
|
1437
|
+
y.initParticles(c);
|
|
1438
|
+
}
|
|
1439
|
+
for (let d = c, y; d; d = y) {
|
|
1440
|
+
y = d.next;
|
|
1441
|
+
for (let f = 0; f < this.updateBehaviors.length; ++f)
|
|
1442
|
+
if (this.updateBehaviors[f].updateParticle(d, -this._spawnTimer)) {
|
|
1443
|
+
this.recycle(d);
|
|
1444
|
+
break;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
this._spawnTimer += this._frequency;
|
|
1449
|
+
}
|
|
1450
|
+
if (this._posChanged && (this._prevEmitterPos.x = r, this._prevEmitterPos.y = l, this._prevPosIsValid = !0, this._posChanged = !1), !this._emit && !this._activeParticlesFirst) {
|
|
1451
|
+
if (this._completeCallback) {
|
|
1452
|
+
const n = this._completeCallback;
|
|
1453
|
+
this._completeCallback = null, n();
|
|
1454
|
+
}
|
|
1455
|
+
this._destroyWhenComplete && this.destroy();
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Emits a single wave of particles, using standard spawnChance & particlesPerWave settings. Does not affect
|
|
1460
|
+
* regular spawning through the frequency, and ignores the emit property. The max particle count is respected, however,
|
|
1461
|
+
* so if there are already too many particles then nothing will happen.
|
|
1462
|
+
*/
|
|
1463
|
+
emitNow() {
|
|
1464
|
+
const t = this.ownerPos.x + this.spawnPos.x, e = this.ownerPos.y + this.spawnPos.y;
|
|
1465
|
+
let a = null, r = null;
|
|
1466
|
+
for (let l = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount), n = 0; n < l; ++n) {
|
|
1467
|
+
if (this.spawnChance < 1 && Math.random() >= this.spawnChance)
|
|
1468
|
+
continue;
|
|
1469
|
+
let o;
|
|
1470
|
+
this._poolFirst ? (o = this._poolFirst, this._poolFirst = this._poolFirst.next, o.next = null) : o = this._createParticle();
|
|
1471
|
+
let c;
|
|
1472
|
+
this.minLifetime === this.maxLifetime ? c = this.minLifetime : c = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime, o.init(c), this._addParticleToParent(o), a ? (r.next = o, o.prev = r, r = o) : r = a = o, ++this.particleCount;
|
|
1473
|
+
}
|
|
1474
|
+
if (a) {
|
|
1475
|
+
this._activeParticlesLast ? (this._activeParticlesLast.next = a, a.prev = this._activeParticlesLast, this._activeParticlesLast = r) : (this._activeParticlesFirst = a, this._activeParticlesLast = r);
|
|
1476
|
+
for (let l = 0; l < this.initBehaviors.length; ++l) {
|
|
1477
|
+
const n = this.initBehaviors[l];
|
|
1478
|
+
if (n === b)
|
|
1479
|
+
for (let o = a, c; o; o = c)
|
|
1480
|
+
c = o.next, this.rotation !== 0 && (w(this.rotation, o.position), o.rotation += this.rotation), o.position.x += t, o.position.y += e;
|
|
1481
|
+
else
|
|
1482
|
+
n.initParticles(a);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Kills all active particles immediately.
|
|
1488
|
+
*/
|
|
1489
|
+
cleanup() {
|
|
1490
|
+
let t, e;
|
|
1491
|
+
for (t = this._activeParticlesFirst; t; t = e)
|
|
1492
|
+
e = t.next, this.recycle(t, !0);
|
|
1493
|
+
this._activeParticlesFirst = this._activeParticlesLast = null, this.particleCount = 0;
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* If this emitter has been destroyed. Note that a destroyed emitter can still be reused, after
|
|
1497
|
+
* having a new parent set and being reinitialized.
|
|
1498
|
+
*/
|
|
1499
|
+
get destroyed() {
|
|
1500
|
+
return !(this._parent && this.initBehaviors.length);
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Destroys the emitter and all of its particles.
|
|
1504
|
+
*/
|
|
1505
|
+
destroy() {
|
|
1506
|
+
this.autoUpdate = !1, this.cleanup();
|
|
1507
|
+
let t;
|
|
1508
|
+
for (let e = this._poolFirst; e; e = t)
|
|
1509
|
+
t = e.next, e.destroy();
|
|
1510
|
+
this._poolFirst = this._parent = this.spawnPos = this.ownerPos = this.customEase = this._completeCallback = null, this.initBehaviors.length = this.updateBehaviors.length = this.recycleBehaviors.length = 0;
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
s(M, "knownBehaviors", {});
|
|
1514
|
+
let m = M;
|
|
1515
|
+
function qt(i, t) {
|
|
1516
|
+
var a, r, l, n, o, c, u, d, y, f, x;
|
|
1517
|
+
if ("behaviors" in i)
|
|
1518
|
+
return i;
|
|
1519
|
+
const e = {
|
|
1520
|
+
lifetime: i.lifetime,
|
|
1521
|
+
ease: i.ease,
|
|
1522
|
+
particlesPerWave: i.particlesPerWave,
|
|
1523
|
+
frequency: i.frequency,
|
|
1524
|
+
spawnChance: i.spawnChance,
|
|
1525
|
+
emitterLifetime: i.emitterLifetime,
|
|
1526
|
+
maxParticles: i.maxParticles,
|
|
1527
|
+
addAtBack: i.addAtBack,
|
|
1528
|
+
pos: i.pos,
|
|
1529
|
+
emit: i.emit,
|
|
1530
|
+
autoUpdate: i.autoUpdate,
|
|
1531
|
+
behaviors: []
|
|
1532
|
+
};
|
|
1533
|
+
if (i.alpha)
|
|
1534
|
+
if ("start" in i.alpha)
|
|
1535
|
+
if (i.alpha.start === i.alpha.end)
|
|
1536
|
+
i.alpha.start !== 1 && e.behaviors.push({
|
|
1537
|
+
type: "alphaStatic",
|
|
1538
|
+
config: { alpha: i.alpha.start }
|
|
1539
|
+
});
|
|
1540
|
+
else {
|
|
1541
|
+
const h = {
|
|
1542
|
+
list: [
|
|
1543
|
+
{ time: 0, value: i.alpha.start },
|
|
1544
|
+
{ time: 1, value: i.alpha.end }
|
|
1545
|
+
]
|
|
1546
|
+
};
|
|
1547
|
+
e.behaviors.push({
|
|
1548
|
+
type: "alpha",
|
|
1549
|
+
config: { alpha: h }
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
else i.alpha.list.length === 1 ? i.alpha.list[0].value !== 1 && e.behaviors.push({
|
|
1553
|
+
type: "alphaStatic",
|
|
1554
|
+
config: { alpha: i.alpha.list[0].value }
|
|
1555
|
+
}) : e.behaviors.push({
|
|
1556
|
+
type: "alpha",
|
|
1557
|
+
config: { alpha: i.alpha }
|
|
1558
|
+
});
|
|
1559
|
+
if (i.acceleration && (i.acceleration.x || i.acceleration.y)) {
|
|
1560
|
+
let h, v;
|
|
1561
|
+
"start" in i.speed ? (h = i.speed.start * (i.speed.minimumSpeedMultiplier ?? 1), v = i.speed.start) : (h = i.speed.list[0].value * (i.minimumSpeedMultiplier ?? 1), v = i.speed.list[0].value), e.behaviors.push({
|
|
1562
|
+
type: "moveAcceleration",
|
|
1563
|
+
config: {
|
|
1564
|
+
accel: i.acceleration,
|
|
1565
|
+
minStart: h,
|
|
1566
|
+
maxStart: v,
|
|
1567
|
+
rotate: !i.noRotation,
|
|
1568
|
+
maxSpeed: i.maxSpeed
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
} else if ((a = i.extraData) != null && a.path) {
|
|
1572
|
+
let h, v;
|
|
1573
|
+
"start" in i.speed ? (v = i.speed.minimumSpeedMultiplier ?? 1, i.speed.start === i.speed.end ? h = {
|
|
1574
|
+
list: [{ time: 0, value: i.speed.start }]
|
|
1575
|
+
} : h = {
|
|
1576
|
+
list: [
|
|
1577
|
+
{ time: 0, value: i.speed.start },
|
|
1578
|
+
{ time: 1, value: i.speed.end }
|
|
1579
|
+
]
|
|
1580
|
+
}) : (h = i.speed, v = i.minimumSpeedMultiplier ?? 1), e.behaviors.push({
|
|
1581
|
+
type: "movePath",
|
|
1582
|
+
config: {
|
|
1583
|
+
path: i.extraData.path,
|
|
1584
|
+
speed: h,
|
|
1585
|
+
minMult: v
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
} else if (i.speed)
|
|
1589
|
+
if ("start" in i.speed)
|
|
1590
|
+
if (i.speed.start === i.speed.end)
|
|
1591
|
+
e.behaviors.push({
|
|
1592
|
+
type: "moveSpeedStatic",
|
|
1593
|
+
config: {
|
|
1594
|
+
min: i.speed.start * (i.speed.minimumSpeedMultiplier ?? 1),
|
|
1595
|
+
max: i.speed.start
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
else {
|
|
1599
|
+
const h = {
|
|
1600
|
+
list: [
|
|
1601
|
+
{ time: 0, value: i.speed.start },
|
|
1602
|
+
{ time: 1, value: i.speed.end }
|
|
1603
|
+
]
|
|
1604
|
+
};
|
|
1605
|
+
e.behaviors.push({
|
|
1606
|
+
type: "moveSpeed",
|
|
1607
|
+
config: { speed: h, minMult: i.speed.minimumSpeedMultiplier }
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
else i.speed.list.length === 1 ? e.behaviors.push({
|
|
1611
|
+
type: "moveSpeedStatic",
|
|
1612
|
+
config: {
|
|
1613
|
+
min: i.speed.list[0].value * (i.minimumSpeedMultiplier ?? 1),
|
|
1614
|
+
max: i.speed.list[0].value
|
|
1615
|
+
}
|
|
1616
|
+
}) : e.behaviors.push({
|
|
1617
|
+
type: "moveSpeed",
|
|
1618
|
+
config: { speed: i.speed, minMult: i.minimumSpeedMultiplier ?? 1 }
|
|
1619
|
+
});
|
|
1620
|
+
if (i.scale)
|
|
1621
|
+
if ("start" in i.scale) {
|
|
1622
|
+
const h = i.scale.minimumScaleMultiplier ?? 1;
|
|
1623
|
+
if (i.scale.start === i.scale.end)
|
|
1624
|
+
e.behaviors.push({
|
|
1625
|
+
type: "scaleStatic",
|
|
1626
|
+
config: {
|
|
1627
|
+
min: i.scale.start * h,
|
|
1628
|
+
max: i.scale.start
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
else {
|
|
1632
|
+
const v = {
|
|
1633
|
+
list: [
|
|
1634
|
+
{ time: 0, value: i.scale.start },
|
|
1635
|
+
{ time: 1, value: i.scale.end }
|
|
1636
|
+
]
|
|
1637
|
+
};
|
|
1638
|
+
e.behaviors.push({
|
|
1639
|
+
type: "scale",
|
|
1640
|
+
config: { scale: v, minMult: h }
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
} else if (i.scale.list.length === 1) {
|
|
1644
|
+
const h = i.minimumScaleMultiplier ?? 1, v = i.scale.list[0].value;
|
|
1645
|
+
e.behaviors.push({
|
|
1646
|
+
type: "scaleStatic",
|
|
1647
|
+
config: { min: v * h, max: v }
|
|
1648
|
+
});
|
|
1649
|
+
} else
|
|
1650
|
+
e.behaviors.push({
|
|
1651
|
+
type: "scale",
|
|
1652
|
+
config: { scale: i.scale, minMult: i.minimumScaleMultiplier ?? 1 }
|
|
1653
|
+
});
|
|
1654
|
+
if (i.color)
|
|
1655
|
+
if ("start" in i.color)
|
|
1656
|
+
if (i.color.start === i.color.end)
|
|
1657
|
+
i.color.start !== "ffffff" && e.behaviors.push({
|
|
1658
|
+
type: "colorStatic",
|
|
1659
|
+
config: { color: i.color.start }
|
|
1660
|
+
});
|
|
1661
|
+
else {
|
|
1662
|
+
const h = {
|
|
1663
|
+
list: [
|
|
1664
|
+
{ time: 0, value: i.color.start },
|
|
1665
|
+
{ time: 1, value: i.color.end }
|
|
1666
|
+
]
|
|
1667
|
+
};
|
|
1668
|
+
e.behaviors.push({
|
|
1669
|
+
type: "color",
|
|
1670
|
+
config: { color: h }
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
else i.color.list.length === 1 ? i.color.list[0].value !== "ffffff" && e.behaviors.push({
|
|
1674
|
+
type: "colorStatic",
|
|
1675
|
+
config: { color: i.color.list[0].value }
|
|
1676
|
+
}) : e.behaviors.push({
|
|
1677
|
+
type: "color",
|
|
1678
|
+
config: { color: i.color }
|
|
1679
|
+
});
|
|
1680
|
+
if (i.rotationAcceleration || (r = i.rotationSpeed) != null && r.min || (l = i.rotationSpeed) != null && l.max ? e.behaviors.push({
|
|
1681
|
+
type: "rotation",
|
|
1682
|
+
config: {
|
|
1683
|
+
accel: i.rotationAcceleration || 0,
|
|
1684
|
+
minSpeed: ((n = i.rotationSpeed) == null ? void 0 : n.min) || 0,
|
|
1685
|
+
maxSpeed: ((o = i.rotationSpeed) == null ? void 0 : o.max) || 0,
|
|
1686
|
+
minStart: ((c = i.startRotation) == null ? void 0 : c.min) || 0,
|
|
1687
|
+
maxStart: ((u = i.startRotation) == null ? void 0 : u.max) || 0
|
|
1688
|
+
}
|
|
1689
|
+
}) : ((d = i.startRotation) != null && d.min || (y = i.startRotation) != null && y.max) && e.behaviors.push({
|
|
1690
|
+
type: "rotationStatic",
|
|
1691
|
+
config: {
|
|
1692
|
+
min: ((f = i.startRotation) == null ? void 0 : f.min) || 0,
|
|
1693
|
+
max: ((x = i.startRotation) == null ? void 0 : x.max) || 0
|
|
1694
|
+
}
|
|
1695
|
+
}), i.noRotation && e.behaviors.push({
|
|
1696
|
+
type: "noRotation",
|
|
1697
|
+
config: {}
|
|
1698
|
+
}), i.blendMode && i.blendMode !== "normal" && e.behaviors.push({
|
|
1699
|
+
type: "blendMode",
|
|
1700
|
+
config: {
|
|
1701
|
+
blendMode: i.blendMode
|
|
1702
|
+
}
|
|
1703
|
+
}), Array.isArray(t) && typeof t[0] != "string" && "framerate" in t[0]) {
|
|
1704
|
+
for (let h = 0; h < t.length; ++h)
|
|
1705
|
+
t[h].framerate === "matchLife" && (t[h].framerate = -1);
|
|
1706
|
+
e.behaviors.push({
|
|
1707
|
+
type: "animatedRandom",
|
|
1708
|
+
config: {
|
|
1709
|
+
anims: t
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
} else typeof t != "string" && "framerate" in t ? (t.framerate === "matchLife" && (t.framerate = -1), e.behaviors.push({
|
|
1713
|
+
type: "animatedSingle",
|
|
1714
|
+
config: {
|
|
1715
|
+
anim: t
|
|
1716
|
+
}
|
|
1717
|
+
})) : i.orderedArt && Array.isArray(t) ? e.behaviors.push({
|
|
1718
|
+
type: "textureOrdered",
|
|
1719
|
+
config: {
|
|
1720
|
+
textures: t
|
|
1721
|
+
}
|
|
1722
|
+
}) : Array.isArray(t) ? e.behaviors.push({
|
|
1723
|
+
type: "textureRandom",
|
|
1724
|
+
config: {
|
|
1725
|
+
textures: t
|
|
1726
|
+
}
|
|
1727
|
+
}) : e.behaviors.push({
|
|
1728
|
+
type: "textureSingle",
|
|
1729
|
+
config: {
|
|
1730
|
+
texture: t
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
if (i.spawnType === "burst")
|
|
1734
|
+
e.behaviors.push({
|
|
1735
|
+
type: "spawnBurst",
|
|
1736
|
+
config: {
|
|
1737
|
+
start: i.angleStart || 0,
|
|
1738
|
+
spacing: i.particleSpacing,
|
|
1739
|
+
// older formats bursted from a single point
|
|
1740
|
+
distance: 0
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
else if (i.spawnType === "point")
|
|
1744
|
+
e.behaviors.push({
|
|
1745
|
+
type: "spawnPoint",
|
|
1746
|
+
config: {}
|
|
1747
|
+
});
|
|
1748
|
+
else {
|
|
1749
|
+
let h;
|
|
1750
|
+
i.spawnType === "ring" ? h = {
|
|
1751
|
+
type: "torus",
|
|
1752
|
+
data: {
|
|
1753
|
+
x: i.spawnCircle.x,
|
|
1754
|
+
y: i.spawnCircle.y,
|
|
1755
|
+
radius: i.spawnCircle.r,
|
|
1756
|
+
innerRadius: i.spawnCircle.minR,
|
|
1757
|
+
affectRotation: !0
|
|
1758
|
+
}
|
|
1759
|
+
} : i.spawnType === "circle" ? h = {
|
|
1760
|
+
type: "torus",
|
|
1761
|
+
data: {
|
|
1762
|
+
x: i.spawnCircle.x,
|
|
1763
|
+
y: i.spawnCircle.y,
|
|
1764
|
+
radius: i.spawnCircle.r,
|
|
1765
|
+
innerRadius: 0,
|
|
1766
|
+
affectRotation: !1
|
|
1767
|
+
}
|
|
1768
|
+
} : i.spawnType === "rect" ? h = {
|
|
1769
|
+
type: "rect",
|
|
1770
|
+
data: i.spawnRect
|
|
1771
|
+
} : i.spawnType === "polygonalChain" && (h = {
|
|
1772
|
+
type: "polygonalChain",
|
|
1773
|
+
data: i.spawnPolygon
|
|
1774
|
+
}), h && e.behaviors.push({
|
|
1775
|
+
type: "spawnShape",
|
|
1776
|
+
config: h
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
return e;
|
|
1780
|
+
}
|
|
1781
|
+
m.registerBehavior(I);
|
|
1782
|
+
m.registerBehavior(V);
|
|
1783
|
+
m.registerBehavior(q);
|
|
1784
|
+
m.registerBehavior(N);
|
|
1785
|
+
m.registerBehavior(U);
|
|
1786
|
+
m.registerBehavior(W);
|
|
1787
|
+
m.registerBehavior(Y);
|
|
1788
|
+
m.registerBehavior(D);
|
|
1789
|
+
m.registerBehavior(X);
|
|
1790
|
+
m.registerBehavior(j);
|
|
1791
|
+
m.registerBehavior(G);
|
|
1792
|
+
m.registerBehavior(z);
|
|
1793
|
+
m.registerBehavior($);
|
|
1794
|
+
m.registerBehavior(Q);
|
|
1795
|
+
m.registerBehavior(H);
|
|
1796
|
+
m.registerBehavior(J);
|
|
1797
|
+
m.registerBehavior(K);
|
|
1798
|
+
m.registerBehavior(Z);
|
|
1799
|
+
m.registerBehavior(S);
|
|
1800
|
+
m.registerBehavior(tt);
|
|
1801
|
+
m.registerBehavior(et);
|
|
1802
|
+
m.registerBehavior(it);
|
|
1803
|
+
export {
|
|
1804
|
+
kt as ContainerParticle,
|
|
1805
|
+
m as Emitter,
|
|
1806
|
+
Rt as Particle,
|
|
1807
|
+
It as ParticleUtils,
|
|
1808
|
+
R as PropertyList,
|
|
1809
|
+
P as PropertyNode,
|
|
1810
|
+
Vt as behaviors,
|
|
1811
|
+
qt as upgradeConfig
|
|
1812
|
+
};
|