custom-pixi-particles 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ import { Point } from '../util';
2
+ import { Behaviour } from './index';
3
+ import Particle from '../Particle';
4
+ import Model from '../Model';
5
+ export default class SpawnBehaviour extends Behaviour {
6
+ enabled: boolean;
7
+ priority: number;
8
+ spawnType: string;
9
+ word: string;
10
+ lastWord: string;
11
+ fontSize: number;
12
+ fontSpacing: number;
13
+ particleDensity: number;
14
+ fontMaxWidth: number;
15
+ fontMaxHeight: number;
16
+ textAlign: 'center' | 'end' | 'left' | 'right' | 'start';
17
+ textBaseline: 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top';
18
+ radius: number;
19
+ radiusX: number;
20
+ radiusY: number;
21
+ starPoints: number;
22
+ rows: number;
23
+ columns: number;
24
+ cellSize: number;
25
+ center: {
26
+ x: number;
27
+ y: number;
28
+ z: number;
29
+ };
30
+ apex: {
31
+ x: number;
32
+ y: number;
33
+ z: number;
34
+ };
35
+ spread: number;
36
+ baseRadius: number;
37
+ coneDirection: number;
38
+ height: number;
39
+ coneAngle: number;
40
+ position: Point;
41
+ positionVariance: Point;
42
+ perspective: number;
43
+ maxZ: number;
44
+ /**
45
+ * Initialize particle position based on spawn type
46
+ * @param {Particle} particle - The particle to initialize
47
+ */
48
+ init: (particle: Particle) => void;
49
+ calculateCtx: () => void;
50
+ apply: (particle: Particle, deltaTime: number, model: Model) => void;
51
+ /**
52
+ * Adds a random variance to the given value
53
+ * @param {number} value - The value to calculate
54
+ * @param {number} variance - The random variance to add
55
+ * @returns {number} The calculated value
56
+ */
57
+ calculate: (value: number, variance: number) => number;
58
+ /**
59
+ * Gets the name of the behaviour
60
+ * @return {string} The name of the behaviour
61
+ */
62
+ getName(): string;
63
+ /**
64
+ * @description Retrieves the properties of the object.
65
+ * @returns {Object} The properties of the object.
66
+ */
67
+ getProps(): {
68
+ enabled: boolean;
69
+ priority: number;
70
+ position: {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ positionVariance: {
75
+ x: number;
76
+ y: number;
77
+ };
78
+ spawnType: string;
79
+ word: string;
80
+ fontSize: number;
81
+ fontSpacing: number;
82
+ particleDensity: number;
83
+ fontMaxWidth: number;
84
+ fontMaxHeight: number;
85
+ textAlign: "center" | "end" | "left" | "right" | "start";
86
+ textBaseline: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top";
87
+ radius: number;
88
+ radiusX: number;
89
+ radiusY: number;
90
+ starPoints: number;
91
+ rows: number;
92
+ columns: number;
93
+ cellSize: number;
94
+ center: {
95
+ x: number;
96
+ y: number;
97
+ z: number;
98
+ };
99
+ apex: {
100
+ x: number;
101
+ y: number;
102
+ z: number;
103
+ };
104
+ spread: number;
105
+ baseRadius: number;
106
+ coneDirection: number;
107
+ height: number;
108
+ coneAngle: number;
109
+ perspective: number;
110
+ maxZ: number;
111
+ name: string;
112
+ };
113
+ }
@@ -0,0 +1,254 @@
1
+ import { Point } from '../util';
2
+ import { Behaviour, BehaviourNames } from './index';
3
+ let canvas = null;
4
+ let imageData = null;
5
+ let particleCount = 0;
6
+ let pixelPositions = [];
7
+ export default class SpawnBehaviour extends Behaviour {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.enabled = true;
11
+ this.priority = 0;
12
+ this.spawnType = 'Rectangle';
13
+ this.word = 'Hello';
14
+ this.lastWord = '';
15
+ this.fontSize = 50;
16
+ this.fontSpacing = 5;
17
+ this.particleDensity = 1;
18
+ this.fontMaxWidth = 1334;
19
+ this.fontMaxHeight = 750;
20
+ this.textAlign = 'center';
21
+ this.textBaseline = 'middle';
22
+ this.radius = 0;
23
+ this.radiusX = 0;
24
+ this.radiusY = 0;
25
+ this.starPoints = 5;
26
+ this.rows = 10;
27
+ this.columns = 10;
28
+ this.cellSize = 20;
29
+ this.center = { x: 0, y: 0, z: 0 };
30
+ this.apex = { x: 0, y: 0, z: 0 };
31
+ this.spread = 360;
32
+ this.baseRadius = 0;
33
+ this.coneDirection = 0;
34
+ this.height = 0;
35
+ this.coneAngle = 45;
36
+ this.position = new Point();
37
+ this.positionVariance = new Point();
38
+ // Perspective parameters
39
+ this.perspective = 0; // Distance for perspective
40
+ this.maxZ = 0; // Maximum z distance for effects
41
+ /**
42
+ * Initialize particle position based on spawn type
43
+ * @param {Particle} particle - The particle to initialize
44
+ */
45
+ this.init = (particle) => {
46
+ // Reset particles if the word has changed
47
+ if (this.spawnType === 'Word' && this.lastWord !== this.word) {
48
+ this.lastWord = this.word;
49
+ this.calculateCtx();
50
+ particle.reset(); // Reset the particle's position and movement
51
+ }
52
+ // Assign a random z-coordinate within a range
53
+ particle.z = Math.random() * this.maxZ;
54
+ if (this.spawnType === 'Rectangle') {
55
+ particle.movement.x = this.calculate(this.position.x, this.positionVariance.x);
56
+ particle.movement.y = this.calculate(this.position.y, this.positionVariance.y);
57
+ }
58
+ else if (this.spawnType === 'Ring') {
59
+ const angle = Math.random() * Math.PI * 2;
60
+ particle.movement.x = this.calculate(this.position.x, this.positionVariance.x) + Math.cos(angle) * this.radius;
61
+ particle.movement.y = this.calculate(this.position.y, this.positionVariance.y) + Math.sin(angle) * this.radius;
62
+ }
63
+ else if (this.spawnType === 'Star') {
64
+ const points = this.starPoints; // Configurable number of star points
65
+ const angle = (Math.PI * 2 * particle.uid) / points;
66
+ const radius = particle.uid % 2 === 0 ? this.radius : this.radius / 2;
67
+ particle.movement.x = this.calculate(this.position.x, this.positionVariance.x) + Math.cos(angle) * radius;
68
+ particle.movement.y = this.calculate(this.position.y, this.positionVariance.y) + Math.sin(angle) * radius;
69
+ }
70
+ else if (this.spawnType === 'FrameRectangle') {
71
+ const w = this.radiusX;
72
+ const h = this.radiusY;
73
+ if (Math.random() < w / (w + h)) {
74
+ particle.movement.x = Math.random() * w + particle.movement.x;
75
+ particle.movement.y = Math.random() < 0.5 ? particle.movement.y : particle.movement.y + h - 1;
76
+ }
77
+ else {
78
+ particle.movement.y = Math.random() * h + particle.movement.y;
79
+ particle.movement.x = Math.random() < 0.5 ? particle.movement.x : particle.movement.x + w - 1;
80
+ }
81
+ particle.movement.x += this.calculate(this.position.x, this.positionVariance.x);
82
+ particle.movement.y += this.calculate(this.position.y, this.positionVariance.y);
83
+ }
84
+ else if (this.spawnType === 'Frame') {
85
+ const w = this.radius;
86
+ const h = this.radius;
87
+ if (Math.random() < w / (w + h)) {
88
+ particle.movement.x = Math.random() * w + particle.movement.x;
89
+ particle.movement.y = Math.random() < 0.5 ? particle.movement.y : particle.movement.y + h - 1;
90
+ }
91
+ else {
92
+ particle.movement.y = Math.random() * h + particle.movement.y;
93
+ particle.movement.x = Math.random() < 0.5 ? particle.movement.x : particle.movement.x + w - 1;
94
+ }
95
+ particle.movement.x += this.calculate(this.position.x, this.positionVariance.x);
96
+ particle.movement.y += this.calculate(this.position.y, this.positionVariance.y);
97
+ }
98
+ else if (this.spawnType === 'Sphere') {
99
+ const phi = Math.random() * Math.PI * 2; // Random azimuthal angle
100
+ const theta = Math.random() * (this.spread / 180) * Math.PI; // Random polar angle
101
+ particle.movement.x =
102
+ this.calculate(this.position.x, this.positionVariance.x) +
103
+ this.center.x +
104
+ this.radius * Math.sin(theta) * Math.cos(phi);
105
+ particle.movement.y =
106
+ this.calculate(this.position.y, this.positionVariance.y) +
107
+ this.center.y +
108
+ this.radius * Math.sin(theta) * Math.sin(phi);
109
+ particle.z = this.center.z + this.radius * Math.cos(theta);
110
+ }
111
+ else if (this.spawnType === 'Cone') {
112
+ const angle = (Math.random() * this.coneAngle - this.coneAngle / 2) * (Math.PI / 180);
113
+ const distance = Math.random() * this.baseRadius; // Random distance from apex
114
+ const localX = Math.cos(angle) * distance; // Local x position within cone
115
+ const localY = Math.sin(angle) * distance; // Local y position within cone
116
+ // Convert coneDirection to radians
117
+ const coneDirectionRad = (this.coneDirection || 0) * (Math.PI / 180);
118
+ // Apply rotation to align the cone to the specified direction
119
+ particle.movement.x =
120
+ this.calculate(this.position.x, this.positionVariance.x) +
121
+ this.apex.x +
122
+ Math.cos(coneDirectionRad) * localX -
123
+ Math.sin(coneDirectionRad) * localY;
124
+ particle.movement.y =
125
+ this.calculate(this.position.y, this.positionVariance.y) +
126
+ this.apex.y +
127
+ Math.sin(coneDirectionRad) * localX +
128
+ Math.cos(coneDirectionRad) * localY;
129
+ particle.z = this.apex.z + Math.random() * this.height;
130
+ }
131
+ else if (this.spawnType === 'Grid') {
132
+ const row = Math.floor(Math.random() * this.rows);
133
+ const column = Math.floor(Math.random() * this.columns);
134
+ particle.movement.x = this.position.x + column * this.cellSize;
135
+ particle.movement.y = this.position.y + row * this.cellSize;
136
+ }
137
+ else if (this.spawnType === 'Word') {
138
+ if (particleCount > 0 && pixelPositions.length > 0) {
139
+ const selectedPixel = pixelPositions[Math.floor(Math.random() * particleCount)];
140
+ particle.movement.x = this.position.x + selectedPixel.x - canvas.width / 2;
141
+ particle.movement.y = this.position.y + selectedPixel.y - canvas.height / 2;
142
+ // Add a bit of random jitter to make the word more dynamic
143
+ particle.movement.x += Math.random() * this.positionVariance.x - this.positionVariance.x / 2;
144
+ particle.movement.y += Math.random() * this.positionVariance.y - this.positionVariance.y / 2;
145
+ }
146
+ }
147
+ if (this.perspective && this.maxZ) {
148
+ // Apply perspective scaling based on z
149
+ const scale = this.perspective / (this.perspective + particle.z);
150
+ particle.movement.x *= scale;
151
+ particle.movement.y *= scale;
152
+ // Adjust particle opacity based on z
153
+ particle.color.alpha = 1 - particle.z / this.maxZ;
154
+ }
155
+ };
156
+ this.calculateCtx = () => {
157
+ const text = this.word; // The word to render
158
+ const fontSize = this.fontSize; // Font size for rendering
159
+ if (!canvas) {
160
+ canvas = document.createElement('canvas');
161
+ canvas.width = this.fontMaxWidth;
162
+ canvas.height = this.fontMaxHeight;
163
+ }
164
+ const ctx = canvas.getContext('2d');
165
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas
166
+ ctx.font = `${fontSize}px Arial`;
167
+ ctx.textAlign = this.textAlign;
168
+ ctx.textBaseline = this.textBaseline;
169
+ ctx.fillText(text, canvas.width / 2, canvas.height / 2);
170
+ // Get pixel data
171
+ imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
172
+ const { data, width, height } = imageData;
173
+ const spacing = this.fontSpacing; // Spacing between pixels
174
+ // Find all non-transparent pixels
175
+ pixelPositions = [];
176
+ for (let y = 0; y < height; y += spacing) {
177
+ for (let x = 0; x < width; x += spacing) {
178
+ const index = (y * width + x) * 4;
179
+ if (data[index + 3] > 128) {
180
+ // Alpha channel > 128 means this pixel is part of the text
181
+ pixelPositions.push(new Point(x, y));
182
+ }
183
+ }
184
+ }
185
+ pixelPositions = pixelPositions.sort(() => Math.random() - 0.5);
186
+ // Use particleDensity to limit the number of particles
187
+ particleCount = Math.floor(pixelPositions.length * this.particleDensity);
188
+ };
189
+ this.apply = (particle, deltaTime, model) => {
190
+ // No updates here for now
191
+ };
192
+ /**
193
+ * Adds a random variance to the given value
194
+ * @param {number} value - The value to calculate
195
+ * @param {number} variance - The random variance to add
196
+ * @returns {number} The calculated value
197
+ */
198
+ this.calculate = (value, variance) => {
199
+ return value + this.varianceFrom(variance);
200
+ };
201
+ }
202
+ /**
203
+ * Gets the name of the behaviour
204
+ * @return {string} The name of the behaviour
205
+ */
206
+ getName() {
207
+ return BehaviourNames.SPAWN_BEHAVIOUR;
208
+ }
209
+ /**
210
+ * @description Retrieves the properties of the object.
211
+ * @returns {Object} The properties of the object.
212
+ */
213
+ getProps() {
214
+ return {
215
+ enabled: this.enabled,
216
+ priority: this.priority,
217
+ position: {
218
+ x: this.position.x,
219
+ y: this.position.y,
220
+ },
221
+ positionVariance: {
222
+ x: this.positionVariance.x,
223
+ y: this.positionVariance.y,
224
+ },
225
+ spawnType: this.spawnType,
226
+ word: this.word,
227
+ fontSize: this.fontSize,
228
+ fontSpacing: this.fontSpacing,
229
+ particleDensity: this.particleDensity,
230
+ fontMaxWidth: this.fontMaxWidth,
231
+ fontMaxHeight: this.fontMaxHeight,
232
+ textAlign: this.textAlign,
233
+ textBaseline: this.textBaseline,
234
+ radius: this.radius,
235
+ radiusX: this.radiusX,
236
+ radiusY: this.radiusY,
237
+ starPoints: this.starPoints,
238
+ rows: this.rows,
239
+ columns: this.columns,
240
+ cellSize: this.cellSize,
241
+ center: this.center,
242
+ apex: this.apex,
243
+ spread: this.spread,
244
+ baseRadius: this.baseRadius,
245
+ coneDirection: this.coneDirection,
246
+ height: this.height,
247
+ coneAngle: this.coneAngle,
248
+ perspective: this.perspective,
249
+ maxZ: this.maxZ,
250
+ name: this.getName(),
251
+ };
252
+ }
253
+ }
254
+ //# sourceMappingURL=SpawnBehaviour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpawnBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/SpawnBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAInD,IAAI,MAAM,GAAQ,IAAI,CAAA;AACtB,IAAI,SAAS,GAAQ,IAAI,CAAA;AACzB,IAAI,aAAa,GAAQ,CAAC,CAAA;AAC1B,IAAI,cAAc,GAAY,EAAE,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;IAArD;;QACE,YAAO,GAAY,IAAI,CAAA;QACvB,aAAQ,GAAG,CAAC,CAAA;QACZ,cAAS,GAAW,WAAW,CAAA;QAC/B,SAAI,GAAW,OAAO,CAAA;QACtB,aAAQ,GAAW,EAAE,CAAA;QACrB,aAAQ,GAAG,EAAE,CAAA;QACb,gBAAW,GAAG,CAAC,CAAA;QACf,oBAAe,GAAG,CAAC,CAAA;QACnB,iBAAY,GAAG,IAAI,CAAA;QACnB,kBAAa,GAAG,GAAG,CAAA;QACnB,cAAS,GAAkD,QAAQ,CAAA;QACnE,iBAAY,GAA2E,QAAQ,CAAA;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1
+ import Particle from '../Particle';
2
+ import Behaviour from './Behaviour';
3
+ export default class TimelineBehaviour extends Behaviour {
4
+ enabled: boolean;
5
+ priority: number;
6
+ timeline: {
7
+ time: number;
8
+ properties: {
9
+ size?: number;
10
+ color?: {
11
+ r: number;
12
+ g: number;
13
+ b: number;
14
+ alpha: number;
15
+ };
16
+ rotation?: number;
17
+ };
18
+ }[];
19
+ init(particle: Particle): void;
20
+ apply(particle: Particle, deltaTime: number): void;
21
+ interpolateProperties(particle: Particle, before: {
22
+ size?: number;
23
+ color?: {
24
+ r: number;
25
+ g: number;
26
+ b: number;
27
+ alpha: number;
28
+ };
29
+ rotation?: number;
30
+ }, after: {
31
+ size?: number;
32
+ color?: {
33
+ r: number;
34
+ g: number;
35
+ b: number;
36
+ alpha: number;
37
+ };
38
+ rotation?: number;
39
+ }, progress: number): void;
40
+ setProperties(particle: Particle, properties: {
41
+ size?: number;
42
+ color?: {
43
+ r: number;
44
+ g: number;
45
+ b: number;
46
+ alpha: number;
47
+ };
48
+ rotation?: number;
49
+ }): void;
50
+ /**
51
+ * Linear interpolation (lerp) function
52
+ */
53
+ lerp(start: number, end: number, t: number): number;
54
+ getName(): string;
55
+ getProps(): {
56
+ enabled: boolean;
57
+ priority: number;
58
+ timeline: {
59
+ time: number;
60
+ properties: {
61
+ size?: number;
62
+ color?: {
63
+ r: number;
64
+ g: number;
65
+ b: number;
66
+ alpha: number;
67
+ };
68
+ rotation?: number;
69
+ };
70
+ }[];
71
+ name: string;
72
+ };
73
+ }
@@ -0,0 +1,98 @@
1
+ import BehaviourNames from './BehaviourNames';
2
+ import Behaviour from './Behaviour';
3
+ export default class TimelineBehaviour extends Behaviour {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.enabled = true;
7
+ this.priority = 0;
8
+ this.timeline = [];
9
+ }
10
+ init(particle) {
11
+ // Set initial properties based on the first timeline entry
12
+ if (this.timeline.length > 0) {
13
+ const initialProperties = this.timeline[0].properties;
14
+ if (initialProperties.size !== undefined) {
15
+ particle.size.x = particle.size.y = initialProperties.size;
16
+ }
17
+ if (initialProperties.color) {
18
+ particle.color.r = initialProperties.color.r;
19
+ particle.color.g = initialProperties.color.g;
20
+ particle.color.b = initialProperties.color.b;
21
+ particle.color.alpha = initialProperties.color.alpha;
22
+ }
23
+ if (initialProperties.rotation !== undefined) {
24
+ particle.rotation = initialProperties.rotation;
25
+ }
26
+ }
27
+ }
28
+ apply(particle, deltaTime) {
29
+ if (!this.enabled)
30
+ return;
31
+ const { lifeTime, maxLifeTime } = particle;
32
+ if (maxLifeTime <= 0)
33
+ return;
34
+ const normalizedTime = lifeTime / maxLifeTime;
35
+ // Find the timeline entries surrounding the normalizedTime
36
+ const before = this.timeline
37
+ .slice()
38
+ .reverse()
39
+ .find((entry) => entry.time <= normalizedTime);
40
+ const after = this.timeline.find((entry) => entry.time > normalizedTime);
41
+ if (before && after) {
42
+ const progress = (normalizedTime - before.time) / (after.time - before.time);
43
+ this.interpolateProperties(particle, before.properties, after.properties, progress);
44
+ }
45
+ else if (before) {
46
+ this.setProperties(particle, before.properties);
47
+ }
48
+ }
49
+ interpolateProperties(particle, before, after, progress) {
50
+ // Interpolate size
51
+ if (before.size !== undefined && after.size !== undefined) {
52
+ particle.size.x = particle.size.y = this.lerp(before.size, after.size, progress);
53
+ }
54
+ // Interpolate color
55
+ if (before.color && after.color) {
56
+ particle.color.r = this.lerp(before.color.r, after.color.r, progress);
57
+ particle.color.g = this.lerp(before.color.g, after.color.g, progress);
58
+ particle.color.b = this.lerp(before.color.b, after.color.b, progress);
59
+ particle.color.alpha = this.lerp(before.color.alpha, after.color.alpha, progress);
60
+ }
61
+ // Interpolate rotation
62
+ if (before.rotation !== undefined && after.rotation !== undefined) {
63
+ particle.rotation = this.lerp(before.rotation, after.rotation, progress);
64
+ }
65
+ }
66
+ setProperties(particle, properties) {
67
+ if (properties.size !== undefined) {
68
+ particle.size.x = particle.size.y = properties.size;
69
+ }
70
+ if (properties.color) {
71
+ particle.color.r = properties.color.r;
72
+ particle.color.g = properties.color.g;
73
+ particle.color.b = properties.color.b;
74
+ particle.color.alpha = properties.color.alpha;
75
+ }
76
+ if (properties.rotation !== undefined) {
77
+ particle.rotation = properties.rotation;
78
+ }
79
+ }
80
+ /**
81
+ * Linear interpolation (lerp) function
82
+ */
83
+ lerp(start, end, t) {
84
+ return start + (end - start) * t;
85
+ }
86
+ getName() {
87
+ return BehaviourNames.TIMELINE_BEHAVIOUR;
88
+ }
89
+ getProps() {
90
+ return {
91
+ enabled: this.enabled,
92
+ priority: this.priority,
93
+ timeline: this.timeline,
94
+ name: this.getName(),
95
+ };
96
+ }
97
+ }
98
+ //# sourceMappingURL=TimelineBehaviour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimelineBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/TimelineBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,OAAO,SAAS,MAAM,aAAa,CAAA;AAEnC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAS;IAAxD;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,CAAC,CAAA;QAEZ,aAAQ,GAOF,EAAE,CAAA;IA4HV,CAAC;IA1HC,IAAI,CAAC,QAAkB;QACrB,2DAA2D;QAC3D,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;YAErD,IAAI,iBAAiB,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACzC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAA;YAC5D,CAAC;YAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,CAAC;gBAC5B,QAAQ,CAAC,KAAK,CAAC,CA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1C,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
@@ -13,4 +13,8 @@ import TurbulenceBehaviour from './TurbulenceBehaviour';
13
13
  import CollisionBehaviour from './CollisionBehaviour';
14
14
  import NoiseBasedMotionBehaviour from './NoiseBasedMotionBehaviour';
15
15
  import ForceFieldsBehaviour from './ForceFieldsBehaviour';
16
- export { EmitterBehaviours, Behaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, BehaviourNames, };
16
+ import SpawnBehaviour from './SpawnBehaviour';
17
+ import TimelineBehaviour from './TimelineBehaviour';
18
+ import GroupingBehaviour from './GroupingBehaviour';
19
+ import SoundReactiveBehaviour from './SoundReactiveBehaviour';
20
+ export { EmitterBehaviours, Behaviour, SpawnBehaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, TimelineBehaviour, GroupingBehaviour, SoundReactiveBehaviour, BehaviourNames, };
@@ -13,5 +13,9 @@ import TurbulenceBehaviour from './TurbulenceBehaviour';
13
13
  import CollisionBehaviour from './CollisionBehaviour';
14
14
  import NoiseBasedMotionBehaviour from './NoiseBasedMotionBehaviour';
15
15
  import ForceFieldsBehaviour from './ForceFieldsBehaviour';
16
- export { EmitterBehaviours, Behaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, BehaviourNames, };
16
+ import SpawnBehaviour from './SpawnBehaviour';
17
+ import TimelineBehaviour from './TimelineBehaviour';
18
+ import GroupingBehaviour from './GroupingBehaviour';
19
+ import SoundReactiveBehaviour from './SoundReactiveBehaviour';
20
+ export { EmitterBehaviours, Behaviour, SpawnBehaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, TimelineBehaviour, GroupingBehaviour, SoundReactiveBehaviour, BehaviourNames, };
17
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/behaviour/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,4BAA4B,MAAM,gCAAgC,CAAA;AACzE,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,wBAAwB,MAAM,4BAA4B,CAAA;AACjE,OAAO,sBAAsB,MAAM,0BAA0B,CAAA;AAC7D,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,kBAAkB,MAAM,sBAAsB,CAAA;AACrD,OAAO,yBAAyB,MAAM,6BAA6B,CAAA;AACnE,OAAO,oBAAoB,MAAM,wBAAw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