custom-pixi-particles 4.28.0 → 4.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -157,23 +157,35 @@ sprite.y = 300
157
157
  const shatterEffect = new ShatterEffect(sprite, {
158
158
  gridCols: 10, // Number of horizontal grid divisions (default: 8)
159
159
  gridRows: 10, // Number of vertical grid divisions (default: 8)
160
- baseVelocity: 400, // Base velocity magnitude for fragments (default: 300)
161
- velocityVariance: 0.5, // Random variance for velocity (default: 0.5)
162
- rotationSpeed: 2, // Base rotation speed in radians per second (default: 2)
163
- rotationVariance: 1, // Random variance for rotation speed (default: 1)
160
+ mode: 'radial', // 'radial', 'directional', or 'swirl'.
161
+ explosionPower: 1000, // Velocity of the fragments (default: 1000)
162
+ enableRotation: true, // Whether fragments spin (default: true)
163
+ rotationStrength: 1.0, // Multiplier for fragment spin speed (default: 1.0)
164
164
  gravity: 600, // Gravity force applied to fragments (default: 500)
165
+ friction: 0.96, // Velocity air resistance (default: 0.96)
166
+ turbulence: 0.2, // Randomness of fragment angles (default: 0.2)
165
167
  lifetime: 2.5, // Lifetime of fragments in seconds (default: 2)
166
- fadeOutDuration: 0.3 // Fade out duration at the end of lifetime (default: 0.3)
168
+ fadeOutDuration: 0.3, // Fade out duration at the end of lifetime (default: 0.3)
169
+ endTint: 0xFFFFFF // Color to lerp toward as fragments die (default: 0xFFFFFF)
167
170
  })
168
171
 
169
172
  // Add to stage
170
173
  app.stage.addChild(shatterEffect)
171
174
 
172
175
  // Trigger explosion with optional completion callback
173
- shatterEffect.Explode(() => {
174
- console.log('Shatter animation complete!')
175
- shatterEffect.destroy()
176
- })
176
+ shatterEffect.Explode().then(() => {
177
+ console.log("Boom! Animation complete.");
178
+ effect.destroy();
179
+ });
180
+
181
+ // Or Simple Usage (Static Method)
182
+ await ShatterEffect.shatter(mySprite, {
183
+ gridCols: 10,
184
+ gridRows: 10,
185
+ explosionPower: 1200,
186
+ enableRotation: true,
187
+ rotationStrength: 1.5
188
+ });
177
189
  ```
178
190
 
179
191
  **ShatterEffect Methods:**
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import Renderer from './lib/pixi/Renderer';
2
2
  import { ICustomPixiParticlesSettings } from './lib/customPixiParticlesSettingsInterface';
3
3
  import TestRenderer from './lib/pixi/TestRenderer';
4
- import { ShatterEffect } from './lib/effects';
5
- export type { IShatterEffectOptions, ShatterMode } from './lib/effects';
4
+ import { ShatterEffect, DissolveEffect, MagneticAssemblyEffect, GhostEffect, GlitchEffect, MeltEffect } from './lib/effects';
5
+ export type { IShatterEffectOptions, ShatterMode, IDissolveEffectOptions, DissolveDirection, IMagneticAssemblyOptions, AssemblyMode, IGhostEffectOptions, IGlitchEffectOptions, IMeltEffectOptions } from './lib/effects';
6
6
  /**
7
7
  * Constructs a renderer for custom pixi particles
8
8
  * @class Renderer
@@ -14,4 +14,4 @@ declare const customPixiParticles: {
14
14
  declare const _customPixiParticlesEditorOnly: {
15
15
  create(settings: ICustomPixiParticlesSettings): TestRenderer;
16
16
  };
17
- export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ICustomPixiParticlesSettings, ShatterEffect };
17
+ export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ICustomPixiParticlesSettings, ShatterEffect, DissolveEffect, MagneticAssemblyEffect, GhostEffect, GlitchEffect, MeltEffect, };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Renderer from './lib/pixi/Renderer';
2
2
  import TestRenderer from './lib/pixi/TestRenderer';
3
- import { ShatterEffect } from './lib/effects';
3
+ import { ShatterEffect, DissolveEffect, MagneticAssemblyEffect, GhostEffect, GlitchEffect, MeltEffect } from './lib/effects';
4
4
  /**
5
5
  * Constructs a renderer for custom pixi particles
6
6
  * @class Renderer
@@ -42,5 +42,5 @@ const _customPixiParticlesEditorOnly = {
42
42
  });
43
43
  },
44
44
  };
45
- export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ShatterEffect };
45
+ export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ShatterEffect, DissolveEffect, MagneticAssemblyEffect, GhostEffect, GlitchEffect, MeltEffect, };
46
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAE1C,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAG7C;;;;GAIG;AACH,MAAM,mBAAmB,GAAG;IAC1B,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,GAAG,GAAG,IAAI,EACV,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,QAAQ,CAAC;YAClB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,MAAM,8BAA8B,GAAG;IACrC,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,MAAM,GAAG,EAAE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CACF,CAAA;AAED,MAAM,8BAA8B,GAAG;IACrC,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,YAAY,CAAC;YACtB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,8BAA8B,EAE9B,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,UAAU,GACX,CAAA"}
File without changes
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=SubEmitterBehaviour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubEmitterBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/SubEmitterBehaviour.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ import { Sprite, ParticleContainer } from 'pixi.js-legacy';
2
+ export type DissolveDirection = 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top' | 'center-out';
3
+ export interface IDissolveEffectOptions {
4
+ pixelSize?: number;
5
+ edgeSoftness?: number;
6
+ driftStrength?: number;
7
+ noiseIntensity?: number;
8
+ lifetime?: number;
9
+ fadeOutDuration?: number;
10
+ direction?: DissolveDirection;
11
+ windAngle?: number;
12
+ }
13
+ export default class DissolveEffect extends ParticleContainer {
14
+ private sourceSprite;
15
+ private fragments;
16
+ private isProcessing;
17
+ private options;
18
+ private progress;
19
+ private dissolveResolve?;
20
+ constructor(sourceSprite: Sprite, options?: IDissolveEffectOptions);
21
+ private prepare;
22
+ start(): Promise<void>;
23
+ private update;
24
+ private removeFragment;
25
+ private finish;
26
+ destroy(options?: any): void;
27
+ static dissolve(sprite: Sprite, options?: IDissolveEffectOptions): Promise<void>;
28
+ }
@@ -0,0 +1,202 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Sprite, Texture, Ticker, ParticleContainer } from 'pixi.js-legacy';
11
+ import ParticlePool from '../ParticlePool';
12
+ export default class DissolveEffect extends ParticleContainer {
13
+ constructor(sourceSprite, options = {}) {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h;
15
+ // Determine bounds to set container size
16
+ const bounds = sourceSprite.getLocalBounds();
17
+ const pixelSize = (_a = options.pixelSize) !== null && _a !== void 0 ? _a : 2;
18
+ const maxParticles = Math.ceil((bounds.width * bounds.height) / (pixelSize * pixelSize));
19
+ super(maxParticles, {
20
+ vertices: true,
21
+ position: true,
22
+ uvs: true,
23
+ alpha: true,
24
+ tint: true,
25
+ });
26
+ this.sourceSprite = sourceSprite;
27
+ this.fragments = [];
28
+ this.isProcessing = false;
29
+ this.progress = 0;
30
+ this.options = {
31
+ pixelSize: pixelSize,
32
+ edgeSoftness: (_b = options.edgeSoftness) !== null && _b !== void 0 ? _b : 0.2,
33
+ driftStrength: (_c = options.driftStrength) !== null && _c !== void 0 ? _c : 200,
34
+ noiseIntensity: (_d = options.noiseIntensity) !== null && _d !== void 0 ? _d : 50,
35
+ lifetime: (_e = options.lifetime) !== null && _e !== void 0 ? _e : 1.5,
36
+ fadeOutDuration: (_f = options.fadeOutDuration) !== null && _f !== void 0 ? _f : 0.5,
37
+ direction: (_g = options.direction) !== null && _g !== void 0 ? _g : 'left-to-right',
38
+ windAngle: ((_h = options.windAngle) !== null && _h !== void 0 ? _h : -45) * (Math.PI / 180), // Support degrees from UI
39
+ };
40
+ this.x = sourceSprite.x;
41
+ this.y = sourceSprite.y;
42
+ this.rotation = sourceSprite.rotation;
43
+ }
44
+ prepare() {
45
+ const texture = this.sourceSprite.texture;
46
+ if (!texture || !texture.valid)
47
+ return;
48
+ const canvas = document.createElement('canvas');
49
+ const { width, height } = texture.frame;
50
+ canvas.width = width;
51
+ canvas.height = height;
52
+ const ctx = canvas.getContext('2d');
53
+ const baseTex = texture.baseTexture.resource;
54
+ if (baseTex && (baseTex.source || baseTex.data)) {
55
+ ctx.drawImage(baseTex.source || baseTex.data, texture.frame.x, texture.frame.y, width, height, 0, 0, width, height);
56
+ }
57
+ const imgData = ctx.getImageData(0, 0, width, height).data;
58
+ const { pixelSize, edgeSoftness, direction } = this.options;
59
+ const anchorX = this.sourceSprite.anchor.x;
60
+ const anchorY = this.sourceSprite.anchor.y;
61
+ const scale = this.sourceSprite.scale.x;
62
+ for (let py = 0; py < height; py += pixelSize) {
63
+ for (let px = 0; px < width; px += pixelSize) {
64
+ const i = (py * width + px) * 4;
65
+ if (imgData[i + 3] < 10)
66
+ continue;
67
+ let spatialFactor = 0;
68
+ switch (direction) {
69
+ case 'left-to-right':
70
+ spatialFactor = px / width;
71
+ break;
72
+ case 'right-to-left':
73
+ spatialFactor = 1 - (px / width);
74
+ break;
75
+ case 'top-to-bottom':
76
+ spatialFactor = py / height;
77
+ break;
78
+ case 'bottom-to-top':
79
+ spatialFactor = 1 - (py / height);
80
+ break;
81
+ case 'center-out':
82
+ const dx = px - width / 2;
83
+ const dy = py - height / 2;
84
+ spatialFactor = Math.sqrt(dx * dx + dy * dy) / (width / 2);
85
+ break;
86
+ }
87
+ const activationThreshold = spatialFactor * (1 - edgeSoftness) + (Math.random() * edgeSoftness);
88
+ const sprite = new Sprite(Texture.WHITE);
89
+ sprite.width = sprite.height = pixelSize * scale;
90
+ sprite.tint = (imgData[i] << 16) | (imgData[i + 1] << 8) | imgData[i + 2];
91
+ const lx = (px - width * anchorX) * scale;
92
+ const ly = (py - height * anchorY) * scale;
93
+ const p = ParticlePool.global.pop();
94
+ p.reset();
95
+ p.x = lx;
96
+ p.y = ly;
97
+ p.maxLifeTime = this.options.lifetime;
98
+ this.fragments.push({
99
+ sprite,
100
+ particle: p,
101
+ activationThreshold,
102
+ isActive: false,
103
+ initialX: lx,
104
+ initialY: ly
105
+ });
106
+ this.addChild(sprite);
107
+ }
108
+ }
109
+ this.sourceSprite.visible = false;
110
+ }
111
+ start() {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ this.prepare();
114
+ this.isProcessing = true;
115
+ return new Promise((resolve) => {
116
+ this.dissolveResolve = resolve;
117
+ Ticker.shared.add(this.update, this);
118
+ });
119
+ });
120
+ }
121
+ update() {
122
+ if (!this.isProcessing)
123
+ return;
124
+ const dt = Ticker.shared.deltaMS / 1000;
125
+ // progress moves from 0 to 1.2 to ensure all thresholds are met
126
+ this.progress += dt * 0.6;
127
+ // Iterate backwards so we can safely splice the array
128
+ for (let i = this.fragments.length - 1; i >= 0; i--) {
129
+ const f = this.fragments[i];
130
+ const p = f.particle;
131
+ if (!f.isActive && this.progress >= f.activationThreshold) {
132
+ f.isActive = true;
133
+ }
134
+ if (f.isActive) {
135
+ p.lifeTime += dt;
136
+ // Movement
137
+ const windX = Math.cos(this.options.windAngle) * this.options.driftStrength;
138
+ const windY = Math.sin(this.options.windAngle) * this.options.driftStrength;
139
+ const noiseX = (Math.random() - 0.5) * this.options.noiseIntensity;
140
+ const noiseY = (Math.random() - 0.5) * this.options.noiseIntensity;
141
+ p.x += (windX + noiseX) * dt;
142
+ p.y += (windY + noiseY) * dt;
143
+ f.sprite.x = p.x;
144
+ f.sprite.y = p.y;
145
+ // Alpha Fade
146
+ const lifeProg = p.lifeTime / p.maxLifeTime;
147
+ const fadeThreshold = 1 - (this.options.fadeOutDuration / p.maxLifeTime);
148
+ if (lifeProg > fadeThreshold) {
149
+ f.sprite.alpha = Math.max(0, 1 - ((lifeProg - fadeThreshold) / (1 - fadeThreshold)));
150
+ }
151
+ // REMOVAL LOGIC: Check if lifetime ended
152
+ if (p.lifeTime >= p.maxLifeTime || f.sprite.alpha <= 0) {
153
+ this.removeFragment(i);
154
+ }
155
+ }
156
+ else {
157
+ f.sprite.x = f.initialX;
158
+ f.sprite.y = f.initialY;
159
+ }
160
+ }
161
+ if (this.fragments.length === 0) {
162
+ this.finish();
163
+ }
164
+ }
165
+ removeFragment(index) {
166
+ const f = this.fragments[index];
167
+ if (f.particle)
168
+ ParticlePool.global.push(f.particle);
169
+ if (f.sprite) {
170
+ this.removeChild(f.sprite);
171
+ f.sprite.destroy();
172
+ }
173
+ this.fragments.splice(index, 1);
174
+ }
175
+ finish() {
176
+ var _a;
177
+ this.isProcessing = false;
178
+ Ticker.shared.remove(this.update, this);
179
+ (_a = this.dissolveResolve) === null || _a === void 0 ? void 0 : _a.call(this);
180
+ }
181
+ destroy(options) {
182
+ Ticker.shared.remove(this.update, this);
183
+ this.fragments.forEach((f, i) => {
184
+ if (f.particle)
185
+ ParticlePool.global.push(f.particle);
186
+ });
187
+ this.fragments = [];
188
+ super.destroy(options);
189
+ }
190
+ static dissolve(sprite_1) {
191
+ return __awaiter(this, arguments, void 0, function* (sprite, options = {}) {
192
+ if (!sprite.parent)
193
+ return;
194
+ const effect = new DissolveEffect(sprite, options);
195
+ const index = sprite.parent.getChildIndex(sprite);
196
+ sprite.parent.addChildAt(effect, index);
197
+ yield effect.start();
198
+ effect.destroy({ children: true });
199
+ });
200
+ }
201
+ }
202
+ //# sourceMappingURL=DissolveEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DissolveEffect.js","sourceRoot":"","sources":["../../../src/lib/effects/DissolveEffect.ts"],"names":[],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QACxC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,CAAC,QAAQ;gBAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAEM,MAAM,CAAO,QAAQ;6DAAC,MAAc,EAAE,UAAkC,EAAE;YAC/E,IAAI,CAAC,MAAM,CAAC,MAAM;gBAAE,OAAO;YAC3B,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAClD,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACxC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACrC,CAAC;KAAA;CACF"}
@@ -0,0 +1,32 @@
1
+ import { Sprite, Container, BLEND_MODES } from 'pixi.js-legacy';
2
+ export interface IGhostEffectOptions {
3
+ spawnInterval?: number;
4
+ ghostLifetime?: number;
5
+ startAlpha?: number;
6
+ endAlpha?: number;
7
+ startTint?: number;
8
+ endTint?: number;
9
+ blendMode?: BLEND_MODES;
10
+ maxGhosts?: number;
11
+ }
12
+ export default class GhostEffect extends Container {
13
+ private target;
14
+ private instances;
15
+ private spawnTimer;
16
+ private options;
17
+ private isTracking;
18
+ constructor(target: Sprite, options?: IGhostEffectOptions);
19
+ /**
20
+ * Start generating echoes.
21
+ */
22
+ start(): void;
23
+ /**
24
+ * Stop generating new echoes (existing ones will finish fading).
25
+ */
26
+ stop(): void;
27
+ private update;
28
+ private createGhost;
29
+ private lerpColor;
30
+ private removeGhost;
31
+ destroy(options?: any): void;
32
+ }
@@ -0,0 +1,119 @@
1
+ import { Sprite, Ticker, Container, BLEND_MODES } from 'pixi.js-legacy';
2
+ import ParticlePool from '../ParticlePool';
3
+ export default class GhostEffect extends Container {
4
+ constructor(target, options = {}) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
+ super();
7
+ this.target = target;
8
+ this.instances = [];
9
+ this.spawnTimer = 0;
10
+ this.isTracking = false;
11
+ this.options = {
12
+ spawnInterval: (_a = options.spawnInterval) !== null && _a !== void 0 ? _a : 0.05,
13
+ ghostLifetime: (_b = options.ghostLifetime) !== null && _b !== void 0 ? _b : 0.5,
14
+ startAlpha: (_c = options.startAlpha) !== null && _c !== void 0 ? _c : 0.6,
15
+ endAlpha: (_d = options.endAlpha) !== null && _d !== void 0 ? _d : 0,
16
+ startTint: (_e = options.startTint) !== null && _e !== void 0 ? _e : 0xFFFFFF,
17
+ endTint: (_f = options.endTint) !== null && _f !== void 0 ? _f : 0x00FFFF,
18
+ blendMode: (_g = options.blendMode) !== null && _g !== void 0 ? _g : BLEND_MODES.NORMAL,
19
+ maxGhosts: (_h = options.maxGhosts) !== null && _h !== void 0 ? _h : 20,
20
+ };
21
+ }
22
+ /**
23
+ * Start generating echoes.
24
+ */
25
+ start() {
26
+ if (this.isTracking)
27
+ return;
28
+ this.isTracking = true;
29
+ Ticker.shared.add(this.update, this);
30
+ }
31
+ /**
32
+ * Stop generating new echoes (existing ones will finish fading).
33
+ */
34
+ stop() {
35
+ this.isTracking = false;
36
+ }
37
+ update() {
38
+ const dt = Ticker.shared.deltaMS / 1000;
39
+ // 1. Spawn logic
40
+ if (this.isTracking) {
41
+ this.spawnTimer += dt;
42
+ if (this.spawnTimer >= this.options.spawnInterval) {
43
+ this.createGhost();
44
+ this.spawnTimer = 0;
45
+ }
46
+ }
47
+ // 2. Update existing ghosts
48
+ for (let i = this.instances.length - 1; i >= 0; i--) {
49
+ const g = this.instances[i];
50
+ const p = g.particle;
51
+ p.lifeTime += dt;
52
+ const progress = Math.min(1, p.lifeTime / p.maxLifeTime);
53
+ // Apply Fading
54
+ g.sprite.alpha = this.options.startAlpha + (this.options.endAlpha - this.options.startAlpha) * progress;
55
+ // Apply Color Shifting
56
+ if (this.options.startTint !== this.options.endTint || this.options.startTint !== 0xFFFFFF) {
57
+ g.sprite.tint = this.lerpColor(this.options.startTint, this.options.endTint, progress);
58
+ }
59
+ // Removal logic
60
+ if (progress >= 1 || g.sprite.alpha <= 0) {
61
+ this.removeGhost(i);
62
+ }
63
+ }
64
+ // Auto-destroy effect container if stopped and no ghosts remain
65
+ if (!this.isTracking && this.instances.length === 0) {
66
+ this.destroy();
67
+ }
68
+ }
69
+ createGhost() {
70
+ if (this.instances.length >= this.options.maxGhosts)
71
+ return;
72
+ if (!this.target.texture || !this.target.texture.valid)
73
+ return;
74
+ const sprite = new Sprite(this.target.texture);
75
+ sprite.anchor.copyFrom(this.target.anchor);
76
+ sprite.scale.copyFrom(this.target.scale);
77
+ sprite.rotation = this.target.rotation;
78
+ sprite.blendMode = this.options.blendMode;
79
+ // Convert target global position to local position of this container
80
+ const globalPos = this.target.getGlobalPosition();
81
+ const localPos = this.parent.toLocal(globalPos);
82
+ sprite.x = localPos.x;
83
+ sprite.y = localPos.y;
84
+ const p = ParticlePool.global.pop();
85
+ p.reset();
86
+ p.maxLifeTime = this.options.ghostLifetime;
87
+ p.lifeTime = 0;
88
+ this.instances.push({
89
+ sprite,
90
+ particle: p,
91
+ initialX: sprite.x,
92
+ initialY: sprite.y,
93
+ initialRotation: sprite.rotation,
94
+ initialScaleX: sprite.scale.x,
95
+ initialScaleY: sprite.scale.y
96
+ });
97
+ this.addChild(sprite);
98
+ }
99
+ lerpColor(start, end, t) {
100
+ const r1 = (start >> 16) & 0xff, g1 = (start >> 8) & 0xff, b1 = start & 0xff;
101
+ const r2 = (end >> 16) & 0xff, g2 = (end >> 8) & 0xff, b2 = end & 0xff;
102
+ const r = r1 + (r2 - r1) * t, g = g1 + (g2 - g1) * t, b = b1 + (b2 - b1) * t;
103
+ return (r << 16) | (g << 8) | b;
104
+ }
105
+ removeGhost(index) {
106
+ const g = this.instances[index];
107
+ if (g.particle)
108
+ ParticlePool.global.push(g.particle);
109
+ this.removeChild(g.sprite);
110
+ g.sprite.destroy();
111
+ this.instances.splice(index, 1);
112
+ }
113
+ destroy(options) {
114
+ Ticker.shared.remove(this.update, this);
115
+ this.instances.forEach((_, i) => this.removeGhost(i));
116
+ super.destroy(options);
117
+ }
118
+ }
119
+ //# sourceMappingURL=GhostEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GhostEffect.js","sourceRoot":"","sources":["../../../src/lib/effects/GhostEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAChF,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAwB1C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IAMhD,YAAoB,MAAc,EAAE,UAA+B,EAAE;;QACnE,KAAK,EAAE,CAAA;QADW,WAAM,GAAN,MAAM,CAAQ;QAL1B,cAAS,GAAoB,EAAE,CAAA;QAC/B,eAAU,GAAW,CAAC,CAAA;QAEtB,eAAU,GAAY,KAAK,CAAA;QAIjC,IAAI,CAAC,OAAO,GAAG;YACb,aAAa,EAAE,MAAA,OAAO,CAAC,aAAa,mCAAI,IAAI;YAC5C,aAAa,EAAE,MAAA,OAAO,CAAC,aAAa,mCAAI,GAAG;YAC3C,UAAU,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,GAAG;YACrC,QAAQ,EAAE,MAAA,OAAO,CAAC,QAAQ,mCAAI,CAAC;YAC/B,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,QAAQ;YACxC,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,mC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CAAC,OAAO,CAAC,CAAA;IACxB,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ import { Sprite, ParticleContainer } from 'pixi.js-legacy';
2
+ export interface IGlitchEffectOptions {
3
+ slices?: number;
4
+ offsetRange?: number;
5
+ flickerIntensity?: number;
6
+ rgbSplit?: boolean;
7
+ rgbOffset?: number;
8
+ duration?: number;
9
+ refreshRate?: number;
10
+ }
11
+ export default class GlitchEffect extends ParticleContainer {
12
+ private sourceSprite;
13
+ private fragments;
14
+ private options;
15
+ private currentTime;
16
+ private lastRefreshTime;
17
+ private glitchResolve?;
18
+ private isProcessing;
19
+ constructor(sourceSprite: Sprite, options?: IGlitchEffectOptions);
20
+ private prepare;
21
+ play(): Promise<void>;
22
+ private update;
23
+ private finish;
24
+ static glitch(sprite: Sprite, options?: IGlitchEffectOptions): Promise<void>;
25
+ }