custom-pixi-particles 4.34.0 → 4.36.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 +346 -73
- package/dist/index.d.ts +14 -6
- package/dist/index.js +40 -34
- package/dist/index.js.map +1 -1
- package/dist/lib/Model.d.ts +61 -0
- package/dist/lib/Model.js +71 -0
- package/dist/lib/Model.js.map +1 -1
- package/dist/lib/Particle.d.ts +70 -1
- package/dist/lib/Particle.js +88 -0
- package/dist/lib/Particle.js.map +1 -1
- package/dist/lib/behaviour/AizawaAttractorBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/AizawaAttractorBehaviour.js +2 -1
- package/dist/lib/behaviour/AizawaAttractorBehaviour.js.map +1 -1
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +2 -1
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/BeatPhaseLockBehaviour.d.ts +26 -0
- package/dist/lib/behaviour/BeatPhaseLockBehaviour.js +68 -0
- package/dist/lib/behaviour/BeatPhaseLockBehaviour.js.map +1 -0
- package/dist/lib/behaviour/BehaviourNames.d.ts +12 -1
- package/dist/lib/behaviour/BehaviourNames.js +12 -1
- package/dist/lib/behaviour/BehaviourNames.js.map +1 -1
- package/dist/lib/behaviour/BezierFlowTubeBehaviour.d.ts +33 -0
- package/dist/lib/behaviour/BezierFlowTubeBehaviour.js +90 -0
- package/dist/lib/behaviour/BezierFlowTubeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/BoidsFlockingBehaviour.d.ts +11 -2
- package/dist/lib/behaviour/BoidsFlockingBehaviour.js +75 -9
- package/dist/lib/behaviour/BoidsFlockingBehaviour.js.map +1 -1
- package/dist/lib/behaviour/BounceBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/BounceBehaviour.js +2 -1
- package/dist/lib/behaviour/BounceBehaviour.js.map +1 -1
- package/dist/lib/behaviour/CollisionBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/CollisionBehaviour.js +2 -1
- package/dist/lib/behaviour/CollisionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ColorCycleBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ColorCycleBehaviour.js +2 -1
- package/dist/lib/behaviour/ColorCycleBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ConstrainToShapeBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ConstrainToShapeBehaviour.js +2 -1
- package/dist/lib/behaviour/ConstrainToShapeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ConversionCascadeBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ConversionCascadeBehaviour.js +2 -1
- package/dist/lib/behaviour/ConversionCascadeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/CurvatureFlowBehaviour.d.ts +6 -2
- package/dist/lib/behaviour/CurvatureFlowBehaviour.js +27 -8
- package/dist/lib/behaviour/CurvatureFlowBehaviour.js.map +1 -1
- package/dist/lib/behaviour/DamageFlashRippleBehaviour.d.ts +27 -0
- package/dist/lib/behaviour/DamageFlashRippleBehaviour.js +77 -0
- package/dist/lib/behaviour/DamageFlashRippleBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitterAttractorLinkBehaviour.d.ts +23 -0
- package/dist/lib/behaviour/EmitterAttractorLinkBehaviour.js +58 -0
- package/dist/lib/behaviour/EmitterAttractorLinkBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +41 -2
- package/dist/lib/behaviour/EmitterBehaviours.js +404 -21
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
- package/dist/lib/behaviour/FlickerBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/FlickerBehaviour.js +2 -1
- package/dist/lib/behaviour/FlickerBehaviour.js.map +1 -1
- package/dist/lib/behaviour/FloatUpBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/FloatUpBehaviour.js +2 -1
- package/dist/lib/behaviour/FloatUpBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ForceFieldsBehaviour.js +2 -1
- package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +1 -1
- package/dist/lib/behaviour/FormPatternBehaviour.d.ts +497 -0
- package/dist/lib/behaviour/FormPatternBehaviour.js +2148 -0
- package/dist/lib/behaviour/FormPatternBehaviour.js.map +1 -0
- package/dist/lib/behaviour/GravityWellBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/GravityWellBehaviour.js +2 -1
- package/dist/lib/behaviour/GravityWellBehaviour.js.map +1 -1
- package/dist/lib/behaviour/GroupingBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/GroupingBehaviour.js +2 -1
- package/dist/lib/behaviour/GroupingBehaviour.js.map +1 -1
- package/dist/lib/behaviour/HomingBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/HomingBehaviour.js +2 -1
- package/dist/lib/behaviour/HomingBehaviour.js.map +1 -1
- package/dist/lib/behaviour/IBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/JacobianCurlFieldBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/JacobianCurlFieldBehaviour.js +2 -1
- package/dist/lib/behaviour/JacobianCurlFieldBehaviour.js.map +1 -1
- package/dist/lib/behaviour/KelvinWakeBehaviour.d.ts +27 -0
- package/dist/lib/behaviour/KelvinWakeBehaviour.js +76 -0
- package/dist/lib/behaviour/KelvinWakeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/LifeBehaviour.d.ts +8 -1
- package/dist/lib/behaviour/LifeBehaviour.js +24 -3
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/LightEffectBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/LightEffectBehaviour.js +2 -1
- package/dist/lib/behaviour/LightEffectBehaviour.js.map +1 -1
- package/dist/lib/behaviour/LimitCycleBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/LimitCycleBehaviour.js +2 -1
- package/dist/lib/behaviour/LimitCycleBehaviour.js.map +1 -1
- package/dist/lib/behaviour/LissajousHarmonicLatticeBehaviour.d.ts +3 -3
- package/dist/lib/behaviour/LissajousHarmonicLatticeBehaviour.js +6 -5
- package/dist/lib/behaviour/LissajousHarmonicLatticeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/MagnetBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/MagnetBehaviour.js +2 -1
- package/dist/lib/behaviour/MagnetBehaviour.js.map +1 -1
- package/dist/lib/behaviour/MoveToPointBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/MoveToPointBehaviour.js +2 -1
- package/dist/lib/behaviour/MoveToPointBehaviour.js.map +1 -1
- package/dist/lib/behaviour/NearMissDispersionBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/NearMissDispersionBehaviour.js +2 -1
- package/dist/lib/behaviour/NearMissDispersionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ObstacleSDFSteerBehaviour.d.ts +35 -0
- package/dist/lib/behaviour/ObstacleSDFSteerBehaviour.js +90 -0
- package/dist/lib/behaviour/ObstacleSDFSteerBehaviour.js.map +1 -0
- package/dist/lib/behaviour/OrbitBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/OrbitBehaviour.js +2 -1
- package/dist/lib/behaviour/OrbitBehaviour.js.map +1 -1
- package/dist/lib/behaviour/PhaseCoherenceBehaviour.d.ts +11 -2
- package/dist/lib/behaviour/PhaseCoherenceBehaviour.js +71 -5
- package/dist/lib/behaviour/PhaseCoherenceBehaviour.js.map +1 -1
- package/dist/lib/behaviour/PhaseFieldFlowBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/PhaseFieldFlowBehaviour.js +2 -1
- package/dist/lib/behaviour/PhaseFieldFlowBehaviour.js.map +1 -1
- package/dist/lib/behaviour/PositionBehaviour.d.ts +2 -1
- package/dist/lib/behaviour/PositionBehaviour.js +5 -3
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ProximityStateBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ProximityStateBehaviour.js +2 -1
- package/dist/lib/behaviour/ProximityStateBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ProximityTriggeredPhaseBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ProximityTriggeredPhaseBehaviour.js +2 -1
- package/dist/lib/behaviour/ProximityTriggeredPhaseBehaviour.js.map +1 -1
- package/dist/lib/behaviour/PulseBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/PulseBehaviour.js +2 -1
- package/dist/lib/behaviour/PulseBehaviour.js.map +1 -1
- package/dist/lib/behaviour/RVOAvoidanceBehaviour.d.ts +34 -0
- package/dist/lib/behaviour/RVOAvoidanceBehaviour.js +160 -0
- package/dist/lib/behaviour/RVOAvoidanceBehaviour.js.map +1 -0
- package/dist/lib/behaviour/RecursiveFireworkBehaviour.d.ts +932 -0
- package/dist/lib/behaviour/RecursiveFireworkBehaviour.js +3034 -0
- package/dist/lib/behaviour/RecursiveFireworkBehaviour.js.map +1 -0
- package/dist/lib/behaviour/RippleBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/RippleBehaviour.js +2 -1
- package/dist/lib/behaviour/RippleBehaviour.js.map +1 -1
- package/dist/lib/behaviour/RotationBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/RotationBehaviour.js +2 -1
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ScreenSpaceFlowMapBehaviour.d.ts +27 -0
- package/dist/lib/behaviour/ScreenSpaceFlowMapBehaviour.js +90 -0
- package/dist/lib/behaviour/ScreenSpaceFlowMapBehaviour.js.map +1 -0
- package/dist/lib/behaviour/ShearFlowBehaviour.d.ts +28 -0
- package/dist/lib/behaviour/ShearFlowBehaviour.js +69 -0
- package/dist/lib/behaviour/ShearFlowBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SizeBehaviour.d.ts +4 -1
- package/dist/lib/behaviour/SizeBehaviour.js +23 -8
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +6 -3
- package/dist/lib/behaviour/SoundReactiveBehaviour.js +58 -15
- package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SpawnBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/SpawnBehaviour.js +3 -3
- package/dist/lib/behaviour/SpawnBehaviour.js.map +1 -1
- package/dist/lib/behaviour/StretchBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/StretchBehaviour.js +2 -1
- package/dist/lib/behaviour/StretchBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SubEmitterBehaviour.js +1 -0
- package/dist/lib/behaviour/TemperatureBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/TemperatureBehaviour.js +1 -1
- package/dist/lib/behaviour/TemperatureBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ToroidalFlowBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ToroidalFlowBehaviour.js +2 -1
- package/dist/lib/behaviour/ToroidalFlowBehaviour.js.map +1 -1
- package/dist/lib/behaviour/ToroidalWrapBehaviour.d.ts +43 -0
- package/dist/lib/behaviour/ToroidalWrapBehaviour.js +94 -0
- package/dist/lib/behaviour/ToroidalWrapBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TrailBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/TrailBehaviour.js +2 -1
- package/dist/lib/behaviour/TrailBehaviour.js.map +1 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +12 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.js +147 -42
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
- package/dist/lib/behaviour/VortexBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/VortexBehaviour.js +2 -1
- package/dist/lib/behaviour/VortexBehaviour.js.map +1 -1
- package/dist/lib/behaviour/WobbleBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/WobbleBehaviour.js +2 -1
- package/dist/lib/behaviour/WobbleBehaviour.js.map +1 -1
- package/dist/lib/behaviour/index.d.ts +15 -2
- package/dist/lib/behaviour/index.js +13 -2
- package/dist/lib/behaviour/index.js.map +1 -1
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +12 -0
- package/dist/lib/effects/MetaballPass.d.ts +67 -0
- package/dist/lib/effects/MetaballPass.js +126 -0
- package/dist/lib/effects/MetaballPass.js.map +1 -0
- package/dist/lib/effects/index.d.ts +2 -0
- package/dist/lib/effects/index.js +2 -0
- package/dist/lib/effects/index.js.map +1 -1
- package/dist/lib/emission/EmissionTypes.d.ts +2 -0
- package/dist/lib/emission/EmissionTypes.js +2 -0
- package/dist/lib/emission/EmissionTypes.js.map +1 -1
- package/dist/lib/emission/PersistentFillEmission.d.ts +20 -0
- package/dist/lib/emission/PersistentFillEmission.js +43 -0
- package/dist/lib/emission/PersistentFillEmission.js.map +1 -0
- package/dist/lib/emission/index.d.ts +2 -1
- package/dist/lib/emission/index.js +2 -1
- package/dist/lib/emission/index.js.map +1 -1
- package/dist/lib/emitter/Emitter.d.ts +30 -2
- package/dist/lib/emitter/Emitter.js +51 -27
- package/dist/lib/emitter/Emitter.js.map +1 -1
- package/dist/lib/emitter/PersistentWrapEmitter.d.ts +13 -0
- package/dist/lib/emitter/PersistentWrapEmitter.js +21 -0
- package/dist/lib/emitter/PersistentWrapEmitter.js.map +1 -0
- package/dist/lib/emitter/index.d.ts +2 -1
- package/dist/lib/emitter/index.js +2 -1
- package/dist/lib/emitter/index.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/inferParticleContainerFeatures.d.ts +26 -0
- package/dist/lib/inferParticleContainerFeatures.js +102 -0
- package/dist/lib/inferParticleContainerFeatures.js.map +1 -0
- package/dist/lib/parser/CompatibilityHelper.js +1 -1
- package/dist/lib/parser/CompatibilityHelper.js.map +1 -1
- package/dist/lib/parser/EmitControllerParser.d.ts +5 -0
- package/dist/lib/parser/EmitControllerParser.js +15 -2
- package/dist/lib/parser/EmitControllerParser.js.map +1 -1
- package/dist/lib/parser/EmitterParser.d.ts +1 -1
- package/dist/lib/parser/EmitterParser.js +47 -2
- package/dist/lib/parser/EmitterParser.js.map +1 -1
- package/dist/lib/pixi/Renderer.d.ts +35 -6
- package/dist/lib/pixi/Renderer.js +347 -66
- package/dist/lib/pixi/Renderer.js.map +1 -1
- package/dist/lib/pixi/SpriteContainerRenderer.d.ts +159 -0
- package/dist/lib/pixi/SpriteContainerRenderer.js +923 -0
- package/dist/lib/pixi/SpriteContainerRenderer.js.map +1 -0
- package/dist/lib/pixi/TestRenderer.d.ts +34 -11
- package/dist/lib/pixi/TestRenderer.js +351 -80
- package/dist/lib/pixi/TestRenderer.js.map +1 -1
- package/dist/lib/pixi/particleLinkLayer.d.ts +31 -0
- package/dist/lib/pixi/particleLinkLayer.js +130 -0
- package/dist/lib/pixi/particleLinkLayer.js.map +1 -0
- package/dist/lib/textureVariants.d.ts +27 -0
- package/dist/lib/textureVariants.js +70 -0
- package/dist/lib/textureVariants.js.map +1 -0
- package/dist/lib/util/formPatternSampling.d.ts +171 -0
- package/dist/lib/util/formPatternSampling.js +1165 -0
- package/dist/lib/util/formPatternSampling.js.map +1 -0
- package/dist/lib/util/resolveBlendMode.d.ts +6 -0
- package/dist/lib/util/resolveBlendMode.js +57 -0
- package/dist/lib/util/resolveBlendMode.js.map +1 -0
- package/dist/lib/util/spatialCellKey.d.ts +8 -0
- package/dist/lib/util/spatialCellKey.js +11 -0
- package/dist/lib/util/spatialCellKey.js.map +1 -0
- package/package.json +10 -7
- package/dist/lib/behaviour/Wireframe3DBehaviour.d.ts +0 -140
- package/dist/lib/behaviour/Wireframe3DBehaviour.js +0 -572
- package/dist/lib/behaviour/Wireframe3DBehaviour.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,12 +9,15 @@
|
|
|
9
9
|
- [Installation](#️-installation)
|
|
10
10
|
- [Quick Start](#-quick-start)
|
|
11
11
|
- [API Reference](#-api-reference)
|
|
12
|
+
- [Textures: static, animated, and mixed](#textures-static-animated-and-mixed)
|
|
12
13
|
- [Configuration Guide](#-configuration-guide)
|
|
13
14
|
- [Emission Types](#emission-types)
|
|
14
15
|
- [Behaviours](#behaviours)
|
|
15
16
|
- [Examples](#-examples)
|
|
16
17
|
- [Performance Tips](#-performance-tips)
|
|
17
18
|
- [Troubleshooting](#-troubleshooting)
|
|
19
|
+
- [Common Use Cases](#-common-use-cases)
|
|
20
|
+
- [Best Practices](#-best-practices)
|
|
18
21
|
- [Special Effects](#special-effects)
|
|
19
22
|
- [Shatter Effect](#shatter-effect)
|
|
20
23
|
- [Dissolve Effect](#dissolve-effect)
|
|
@@ -22,8 +25,15 @@
|
|
|
22
25
|
- [Ghost Effect](#ghost-effect)
|
|
23
26
|
- [Glitch Effect](#glitch-effect)
|
|
24
27
|
- [Melt Effect](#melt-effect)
|
|
28
|
+
- [Pixel Sort Effect](#pixel-sort-effect)
|
|
29
|
+
- [Prism Refraction Effect](#prism-refraction-effect)
|
|
30
|
+
- [Crystallize Effect](#crystallize-effect)
|
|
31
|
+
- [Slit-Scan Effect](#slit-scan-effect)
|
|
32
|
+
- [Granular Erosion Effect](#granular-erosion-effect)
|
|
33
|
+
- [Liquid Mercury Effect](#liquid-mercury-effect)
|
|
25
34
|
- [Versions Compatibility](#️-versions-compatibility)
|
|
26
35
|
- [Advanced Editor](#️-advanced-editor)
|
|
36
|
+
- [License](#-license)
|
|
27
37
|
- [Contributing](#-contributing)
|
|
28
38
|
|
|
29
39
|
---
|
|
@@ -39,8 +49,9 @@ If you find **custom-pixi-particles** useful and would like to support my work,
|
|
|
39
49
|
- **Simple API**: Effortlessly create particle emitters with minimal code.
|
|
40
50
|
- **Highly Configurable**: Adjust particle behavior, appearance, animation, and more.
|
|
41
51
|
- **Performance Optimized**: Handle thousands of particles with minimal performance overhead.
|
|
42
|
-
- **PIXI.js Compatibility**:
|
|
52
|
+
- **PIXI.js Compatibility**: Current releases target **PIXI.js v8**. For legacy **v5/v6** projects, use `custom-pixi-particles@4.x`.
|
|
43
53
|
- **Real-Time Customization**: Dynamically update textures, positions, configurations, and emitters on the fly.
|
|
54
|
+
- **Static and animated textures**: Use single-frame textures, frame sequences (`prefix00.png`, `prefix01.png`, …), or **mix both** per particle via `textureVariants` and optional `variantWeights`.
|
|
44
55
|
- **Shatter Effect**: Create dramatic sprite shattering effects with realistic physics and automatic cleanup.
|
|
45
56
|
|
|
46
57
|
---
|
|
@@ -58,17 +69,25 @@ Install via npm:
|
|
|
58
69
|
npm install custom-pixi-particles
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
This package targets modern PixiJS and includes `pixi.js` in its dependencies by default.
|
|
73
|
+
For legacy PixiJS v5/v6 compatibility, use `custom-pixi-particles@4.x` with `pixi.js-legacy`.
|
|
62
74
|
|
|
63
75
|
```bash
|
|
64
|
-
# For PIXI.js v8
|
|
65
|
-
npm install pixi.js
|
|
76
|
+
# For PIXI.js v8 (current)
|
|
77
|
+
npm install custom-pixi-particles pixi.js
|
|
66
78
|
|
|
67
|
-
# For PIXI.js
|
|
68
|
-
npm install pixi.js
|
|
79
|
+
# For PIXI.js v5/v6 (legacy line)
|
|
80
|
+
npm install custom-pixi-particles@4 pixi.js-legacy
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If you need prebuilt browser bundles from this repo, run:
|
|
69
84
|
|
|
70
|
-
|
|
71
|
-
npm
|
|
85
|
+
```bash
|
|
86
|
+
npm run build
|
|
87
|
+
npm run build:browser:v8
|
|
88
|
+
# optional:
|
|
89
|
+
# npm run build:browser:v7
|
|
90
|
+
# npm run build:browser:v6
|
|
72
91
|
```
|
|
73
92
|
|
|
74
93
|
---
|
|
@@ -77,17 +96,22 @@ npm install pixi.js-legacy
|
|
|
77
96
|
|
|
78
97
|
### Import or Require
|
|
79
98
|
```javascript
|
|
80
|
-
//
|
|
81
|
-
import customPixiParticles from 'custom-pixi-particles'
|
|
99
|
+
// ES modules
|
|
100
|
+
import { customPixiParticles } from 'custom-pixi-particles'
|
|
82
101
|
|
|
83
102
|
// CommonJS
|
|
84
|
-
const customPixiParticles = require('custom-pixi-particles')
|
|
103
|
+
const { customPixiParticles } = require('custom-pixi-particles')
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
You can also import Pixi helpers directly from this package:
|
|
107
|
+
```javascript
|
|
108
|
+
import { Application, Assets } from 'custom-pixi-particles'
|
|
85
109
|
```
|
|
86
110
|
|
|
87
111
|
### Basic Example
|
|
88
112
|
```javascript
|
|
89
113
|
import { Application } from 'pixi.js'
|
|
90
|
-
import customPixiParticles from 'custom-pixi-particles'
|
|
114
|
+
import { customPixiParticles } from 'custom-pixi-particles'
|
|
91
115
|
|
|
92
116
|
// Create PIXI application
|
|
93
117
|
const app = new Application()
|
|
@@ -172,7 +196,7 @@ Initializes a particle emitter with the specified configuration.
|
|
|
172
196
|
|
|
173
197
|
```javascript
|
|
174
198
|
const particles = customPixiParticles.create({
|
|
175
|
-
textures: [String], // Array of particle texture paths
|
|
199
|
+
textures: [String], // Array of particle texture paths
|
|
176
200
|
emitterConfig: Object, // Configuration object for the emitter (see Configuration section)
|
|
177
201
|
animatedSpriteZeroPad: Number, // Zero-padding for animated sprite names (default: 2)
|
|
178
202
|
animatedSpriteIndexToStart: Number, // Initial frame index for animated sprites (default: 0)
|
|
@@ -186,9 +210,13 @@ const particles = customPixiParticles.create({
|
|
|
186
210
|
maxFPS: Number, // Cap emitter update frequency (default: 60)
|
|
187
211
|
minFPS: Number, // Minimum FPS threshold (default: 30)
|
|
188
212
|
tickerSpeed: Number, // Speed of the PIXI ticker (default: 0.02)
|
|
213
|
+
particleLinks: Object, // Optional proximity-line mesh between particles
|
|
214
|
+
canvasSizeProvider: Function, // Optional callback returning { width, height } for canvas-aware bounds
|
|
189
215
|
})
|
|
190
216
|
```
|
|
191
217
|
|
|
218
|
+
`create(...)` returns a `Renderer`.
|
|
219
|
+
|
|
192
220
|
### Configuration Object Structure
|
|
193
221
|
|
|
194
222
|
The `emitterConfig` object contains all the settings for your particle system:
|
|
@@ -208,14 +236,79 @@ const emitterConfig = {
|
|
|
208
236
|
duration: -1, // Emitter duration in seconds (-1 = infinite)
|
|
209
237
|
alpha: 1, // Global alpha (0-1)
|
|
210
238
|
blendMode: 0, // PIXI.js blend mode
|
|
239
|
+
anchor: { x: 0.5, y: 0.5 }, // Particle anchor point (default: center)
|
|
211
240
|
|
|
212
241
|
// Behaviours Array
|
|
213
242
|
behaviours: [
|
|
214
243
|
// See Behaviours section for details
|
|
215
244
|
],
|
|
245
|
+
|
|
246
|
+
// Optional — see "Textures: static, animated, and mixed" below
|
|
247
|
+
// animatedSprite: { enabled: true, frameRate: 0.25, loop: true, randomFrameStart: false },
|
|
248
|
+
// textureVariants: [ /* mix static + animated */ ],
|
|
249
|
+
// variantWeights: [0.5, 0.5],
|
|
216
250
|
}
|
|
217
251
|
```
|
|
218
252
|
|
|
253
|
+
### Textures: static, animated, and mixed
|
|
254
|
+
|
|
255
|
+
Particle visuals come from the `textures` array you pass to `customPixiParticles.create({ textures, emitterConfig, ... })` **plus** texture-related fields on **`emitterConfig`**. All asset keys must be loaded with Pixi’s **`Assets`** (or equivalent) before particles spawn.
|
|
256
|
+
|
|
257
|
+
#### 1. Static textures only (default)
|
|
258
|
+
|
|
259
|
+
If animated sprites are **not** enabled, each entry in `textures` is treated as a **full texture id** (e.g. `'spark.png'`). Each new particle picks one at random.
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
const textures = ['a.png', 'b.png', 'c.png']
|
|
263
|
+
// emitterConfig without animatedSprite.enabled / without textureVariants
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### 2. Animated sprites (legacy mode, all entries are sequences)
|
|
267
|
+
|
|
268
|
+
Set **`emitterConfig.animatedSprite.enabled: true`**. Then each string in `textures` is a **filename prefix** (no extension). The renderer loads consecutive frames:
|
|
269
|
+
|
|
270
|
+
`{prefix}{index}.png` — e.g. `fire00.png`, `fire01.png`, … until a frame is missing.
|
|
271
|
+
|
|
272
|
+
- **Padding**: use `animatedSpriteZeroPad` / `animatedSpriteIndexToStart` on `create({ ... })` (defaults: pad `2`, start index `0`). Per-sequence overrides exist on each `frames` variant when using `textureVariants` (below).
|
|
273
|
+
- **Playback**: `emitterConfig.animatedSprite` typically includes `frameRate`, `loop`, and optional `randomFrameStart` (see the live editor’s General → Animated sprite for the exact shape your JSON uses).
|
|
274
|
+
|
|
275
|
+
```javascript
|
|
276
|
+
customPixiParticles.create({
|
|
277
|
+
textures: ['explosion_', 'smoke_'], // two different frame sequences
|
|
278
|
+
animatedSpriteZeroPad: 2,
|
|
279
|
+
emitterConfig: {
|
|
280
|
+
animatedSprite: { enabled: true, frameRate: 0.25, loop: true },
|
|
281
|
+
// ...behaviours, emitController, etc.
|
|
282
|
+
},
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### 3. Mix static and animated (`textureVariants`)
|
|
287
|
+
|
|
288
|
+
For **some particles static and some animated**, set a non-empty **`emitterConfig.textureVariants`** array. Each item is either:
|
|
289
|
+
|
|
290
|
+
| Type | Meaning |
|
|
291
|
+
|------|--------|
|
|
292
|
+
| `{ type: 'staticRandom', textures: ['x.png', 'y.png'] }` | Pick one static texture at random for that variant. |
|
|
293
|
+
| `{ type: 'frames', prefix: 'boom_', frameRate?, loop?, randomFrameStart?, animatedSpriteZeroPad?, animatedSpriteIndexToStart? }` | Load `boom_00.png`, `boom_01.png`, … (PNG, same rules as legacy animated). |
|
|
294
|
+
|
|
295
|
+
Optional **`emitterConfig.variantWeights`**: same length as `textureVariants`, relative probabilities (normalized internally). If omitted, variants are equally likely.
|
|
296
|
+
|
|
297
|
+
```javascript
|
|
298
|
+
emitterConfig: {
|
|
299
|
+
textureVariants: [
|
|
300
|
+
{ type: 'staticRandom', textures: ['spark.png', 'glow.png'] },
|
|
301
|
+
{ type: 'frames', prefix: 'fire_', frameRate: 0.3, loop: true },
|
|
302
|
+
],
|
|
303
|
+
variantWeights: [0.6, 0.4], // 60% static pool, 40% fire_ sequence
|
|
304
|
+
// ...
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
When `textureVariants` is set, it **replaces** the simple “all static” / “all prefixes” derivation from `textures` alone. You still pass `textures` to `create()` for updates like `setTextures` / defaults where the code falls back to the legacy list.
|
|
309
|
+
|
|
310
|
+
**Note:** `finishingTextures` apply to **static** particles when a particle enters finishing state; animated display uses `AnimatedSprite` and does not swap to finishing textures the same way.
|
|
311
|
+
|
|
219
312
|
### Event Callbacks
|
|
220
313
|
Triggered when the particle animation completes.
|
|
221
314
|
```javascript
|
|
@@ -233,14 +326,23 @@ particles.setTextures(['texture3.png', 'texture4.png'])
|
|
|
233
326
|
### Configuration Updates
|
|
234
327
|
Dynamically update emitter configurations.
|
|
235
328
|
```javascript
|
|
236
|
-
particles.updateConfig({ /* New configuration properties */ })
|
|
329
|
+
particles.updateConfig({ /* New configuration properties */ }, resetDuration = false)
|
|
237
330
|
```
|
|
331
|
+
`resetDuration` — when `true`, resets the emitter duration timer.
|
|
238
332
|
|
|
239
333
|
### State Control
|
|
240
|
-
Starts
|
|
334
|
+
Starts the emitter and turbulence emitter (when applicable).
|
|
335
|
+
```javascript
|
|
336
|
+
particles.start()
|
|
337
|
+
```
|
|
338
|
+
Starts or resumes emission.
|
|
241
339
|
```javascript
|
|
242
340
|
particles.play()
|
|
243
341
|
```
|
|
342
|
+
Resumes after pause.
|
|
343
|
+
```javascript
|
|
344
|
+
particles.resume()
|
|
345
|
+
```
|
|
244
346
|
Toggles the paused state.
|
|
245
347
|
```javascript
|
|
246
348
|
particles.pause(isPaused)
|
|
@@ -257,12 +359,25 @@ Resets the emitter to its initial state.
|
|
|
257
359
|
```javascript
|
|
258
360
|
particles.resetEmitter()
|
|
259
361
|
```
|
|
362
|
+
Sets the PIXI ticker speed multiplier (affects animation speed).
|
|
363
|
+
```javascript
|
|
364
|
+
particles.setTickerSpeed(0.02)
|
|
365
|
+
```
|
|
366
|
+
Refreshes the particle texture (e.g. after changing texture source).
|
|
367
|
+
```javascript
|
|
368
|
+
particles.updateTexture()
|
|
369
|
+
```
|
|
370
|
+
Updates particle-link settings at runtime.
|
|
371
|
+
```javascript
|
|
372
|
+
particles.setParticleLinks({ enabled: true, maxDistance: 100 })
|
|
373
|
+
```
|
|
260
374
|
|
|
261
375
|
### Position Updates
|
|
262
376
|
Dynamically adjust the emitter's position.
|
|
263
377
|
```javascript
|
|
264
|
-
particles.updatePosition({ x: 100, y: 200 })
|
|
378
|
+
particles.updatePosition({ x: 100, y: 200 }, resetDuration = true)
|
|
265
379
|
```
|
|
380
|
+
`resetDuration` — when `true`, resets the emitter duration timer.
|
|
266
381
|
|
|
267
382
|
### Pool Management
|
|
268
383
|
Clears internal object pools to free memory.
|
|
@@ -309,7 +424,7 @@ app.stage.addChild(shatterEffect)
|
|
|
309
424
|
// Trigger explosion with optional completion callback
|
|
310
425
|
shatterEffect.Explode().then(() => {
|
|
311
426
|
console.log("Boom! Animation complete.");
|
|
312
|
-
|
|
427
|
+
shatterEffect.destroy();
|
|
313
428
|
});
|
|
314
429
|
|
|
315
430
|
// Or Simple Usage (Static Method)
|
|
@@ -519,6 +634,210 @@ meltEffect.melt().then(() => {
|
|
|
519
634
|
- `reset()` - Resets the effect to its initial state.
|
|
520
635
|
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
521
636
|
|
|
637
|
+
### Pixel Sort Effect
|
|
638
|
+
Creates a glitch-art style distortion by sorting pixels within rows or columns by luminance, hue, saturation, or RGB channel. Pixels within a threshold range are reordered, producing characteristic stretchy bands.
|
|
639
|
+
|
|
640
|
+
```javascript
|
|
641
|
+
import { PixelSortEffect } from 'custom-pixi-particles'
|
|
642
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
643
|
+
|
|
644
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
645
|
+
sprite.anchor.set(0.5, 0.5)
|
|
646
|
+
sprite.x = 400
|
|
647
|
+
sprite.y = 300
|
|
648
|
+
|
|
649
|
+
const pixelSortEffect = new PixelSortEffect(sprite, {
|
|
650
|
+
direction: 'horizontal', // 'horizontal' | 'vertical' (default: 'horizontal')
|
|
651
|
+
sortMode: 'luminance', // 'luminance' | 'hue' | 'saturation' | 'red' | 'green' | 'blue' (default: 'luminance')
|
|
652
|
+
sortOrder: 'ascending', // 'ascending' | 'descending' (default: 'ascending')
|
|
653
|
+
thresholdLow: 0.2, // 0-1, min key to sort (default: 0.2)
|
|
654
|
+
thresholdHigh: 0.8, // 0-1, max key to sort (default: 0.8)
|
|
655
|
+
duration: 1.5, // Effect duration in seconds (default: 1.5)
|
|
656
|
+
refreshRate: 0.016, // How often to refresh the effect (default: 0.016)
|
|
657
|
+
rowStep: 1, // Process every Nth row for performance (default: 1)
|
|
658
|
+
intensity: 1 // 0-1, fraction of line affected (default: 1)
|
|
659
|
+
})
|
|
660
|
+
|
|
661
|
+
app.stage.addChild(pixelSortEffect)
|
|
662
|
+
|
|
663
|
+
pixelSortEffect.play().then(() => {
|
|
664
|
+
console.log("Pixel sort complete!")
|
|
665
|
+
pixelSortEffect.destroy()
|
|
666
|
+
})
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
**PixelSortEffect Methods:**
|
|
670
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
671
|
+
- `reset()` - Resets the effect to its initial state.
|
|
672
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
673
|
+
|
|
674
|
+
### Prism Refraction Effect
|
|
675
|
+
Creates a holographic prism effect with chromatic dispersion—RGB channels are offset to produce rainbow fringing and a spectral/hologram feel.
|
|
676
|
+
|
|
677
|
+
```javascript
|
|
678
|
+
import { PrismRefractionEffect } from 'custom-pixi-particles'
|
|
679
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
680
|
+
|
|
681
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
682
|
+
sprite.anchor.set(0.5, 0.5)
|
|
683
|
+
sprite.x = 400
|
|
684
|
+
sprite.y = 300
|
|
685
|
+
|
|
686
|
+
const prismEffect = new PrismRefractionEffect(sprite, {
|
|
687
|
+
dispersionStrength: 8, // Pixels of R/B offset (default: 8)
|
|
688
|
+
dispersionAngle: 0, // Radians, 0 = horizontal (default: 0)
|
|
689
|
+
duration: 1.5, // Effect duration (default: 1.5)
|
|
690
|
+
scanSpeed: 0, // Optional scan line speed, 0 = no scan (default: 0)
|
|
691
|
+
fresnelPower: 0 // 0 = no fresnel, higher = edge-only (default: 0)
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
app.stage.addChild(prismEffect)
|
|
695
|
+
|
|
696
|
+
prismEffect.play().then(() => {
|
|
697
|
+
console.log("Prism effect complete!")
|
|
698
|
+
prismEffect.destroy()
|
|
699
|
+
})
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
**PrismRefractionEffect Methods:**
|
|
703
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
704
|
+
- `reset()` - Resets the effect to its initial state.
|
|
705
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
706
|
+
|
|
707
|
+
### Crystallize Effect
|
|
708
|
+
Transforms sprites into crystal/gem-like facets using Voronoi-style cells. Each cell gets an averaged color with optional facet highlights and tint variation.
|
|
709
|
+
|
|
710
|
+
```javascript
|
|
711
|
+
import { CrystallizeEffect } from 'custom-pixi-particles'
|
|
712
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
713
|
+
|
|
714
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
715
|
+
sprite.anchor.set(0.5, 0.5)
|
|
716
|
+
sprite.x = 400
|
|
717
|
+
sprite.y = 300
|
|
718
|
+
|
|
719
|
+
const crystallizeEffect = new CrystallizeEffect(sprite, {
|
|
720
|
+
cellScale: 16, // Approximate cell size in pixels (default: 16)
|
|
721
|
+
jitter: 0.5, // 0-1, random offset of cell centers (default: 0.5)
|
|
722
|
+
highlightStrength: 0.3, // 0-1, facet sheen (default: 0.3)
|
|
723
|
+
edgeSoftness: 0.2, // 0-1, smooth cell edges (default: 0.2)
|
|
724
|
+
tintByCell: false, // Slight tint variation per cell (default: false)
|
|
725
|
+
duration: 1 // Blend from original to crystallize (default: 1)
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
app.stage.addChild(crystallizeEffect)
|
|
729
|
+
|
|
730
|
+
crystallizeEffect.play().then(() => {
|
|
731
|
+
console.log("Crystallize complete!")
|
|
732
|
+
crystallizeEffect.destroy()
|
|
733
|
+
})
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
**CrystallizeEffect Methods:**
|
|
737
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
738
|
+
- `reset()` - Resets the effect to its initial state.
|
|
739
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
740
|
+
|
|
741
|
+
### Slit-Scan Effect
|
|
742
|
+
Creates temporal/slit-scan distortion where each row (or column) samples a different offset over time, producing wave-like or ribbon distortion effects.
|
|
743
|
+
|
|
744
|
+
```javascript
|
|
745
|
+
import { SlitScanEffect } from 'custom-pixi-particles'
|
|
746
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
747
|
+
|
|
748
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
749
|
+
sprite.anchor.set(0.5, 0.5)
|
|
750
|
+
sprite.x = 400
|
|
751
|
+
sprite.y = 300
|
|
752
|
+
|
|
753
|
+
const slitScanEffect = new SlitScanEffect(sprite, {
|
|
754
|
+
mode: 'wave', // 'wave' | 'slit-scan' (default: 'wave')
|
|
755
|
+
speed: 2, // Phase/offset speed (default: 2)
|
|
756
|
+
amplitude: 20, // Pixel displacement for wave mode (default: 20)
|
|
757
|
+
frequency: 0.02, // Rows per wave cycle (default: 0.02)
|
|
758
|
+
direction: 'horizontal', // 'horizontal' | 'vertical' (default: 'horizontal')
|
|
759
|
+
duration: 2 // Effect duration (default: 2)
|
|
760
|
+
})
|
|
761
|
+
|
|
762
|
+
app.stage.addChild(slitScanEffect)
|
|
763
|
+
|
|
764
|
+
slitScanEffect.play().then(() => {
|
|
765
|
+
console.log("Slit-scan complete!")
|
|
766
|
+
slitScanEffect.destroy()
|
|
767
|
+
})
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
**SlitScanEffect Methods:**
|
|
771
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
772
|
+
- `reset()` - Resets the effect to its initial state.
|
|
773
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
774
|
+
|
|
775
|
+
### Granular Erosion Effect
|
|
776
|
+
Simulates granular erosion where the sprite appears to break apart into falling grains with gravity and wind turbulence.
|
|
777
|
+
|
|
778
|
+
```javascript
|
|
779
|
+
import { GranularErosionEffect } from 'custom-pixi-particles'
|
|
780
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
781
|
+
|
|
782
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
783
|
+
sprite.anchor.set(0.5, 0.5)
|
|
784
|
+
sprite.x = 400
|
|
785
|
+
sprite.y = 300
|
|
786
|
+
|
|
787
|
+
const erosionEffect = new GranularErosionEffect(sprite, {
|
|
788
|
+
erosionProgress: 0.5, // 0-1, how much has broken loose (default: 0.5)
|
|
789
|
+
gravityScale: 80, // Vertical fall speed (default: 80)
|
|
790
|
+
windTurbulence: 15, // Horizontal sine amplitude (default: 15)
|
|
791
|
+
grainSize: 0.08, // Noise frequency, higher = finer grains (default: 0.08)
|
|
792
|
+
duration: 2 // Effect duration (default: 2)
|
|
793
|
+
})
|
|
794
|
+
|
|
795
|
+
app.stage.addChild(erosionEffect)
|
|
796
|
+
|
|
797
|
+
erosionEffect.play().then(() => {
|
|
798
|
+
console.log("Erosion complete!")
|
|
799
|
+
erosionEffect.destroy()
|
|
800
|
+
})
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
**GranularErosionEffect Methods:**
|
|
804
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
805
|
+
- `reset()` - Resets the effect to its initial state.
|
|
806
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
807
|
+
|
|
808
|
+
### Liquid Mercury Effect
|
|
809
|
+
Creates a liquid metal look with viscosity, reflectivity, and rippling. Sprites appear to morph into blobby mercury-like shapes.
|
|
810
|
+
|
|
811
|
+
```javascript
|
|
812
|
+
import { LiquidMercuryEffect } from 'custom-pixi-particles'
|
|
813
|
+
import { Sprite, Texture } from 'pixi.js'
|
|
814
|
+
|
|
815
|
+
const sprite = new Sprite(Texture.from('my-image.png'))
|
|
816
|
+
sprite.anchor.set(0.5, 0.5)
|
|
817
|
+
sprite.x = 400
|
|
818
|
+
sprite.y = 300
|
|
819
|
+
|
|
820
|
+
const mercuryEffect = new LiquidMercuryEffect(sprite, {
|
|
821
|
+
viscosity: 0.3, // 0-1, blur/smooth (default: 0.3)
|
|
822
|
+
reflectivity: 0.6, // 0-1, MatCap strength (default: 0.6)
|
|
823
|
+
rippleSpeed: 2, // Scroll speed (default: 2)
|
|
824
|
+
edgeRoundness: 2, // Smooth-step power for blobby edges (default: 2)
|
|
825
|
+
duration: 2 // Effect duration (default: 2)
|
|
826
|
+
})
|
|
827
|
+
|
|
828
|
+
app.stage.addChild(mercuryEffect)
|
|
829
|
+
|
|
830
|
+
mercuryEffect.play().then(() => {
|
|
831
|
+
console.log("Liquid mercury complete!")
|
|
832
|
+
mercuryEffect.destroy()
|
|
833
|
+
})
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
**LiquidMercuryEffect Methods:**
|
|
837
|
+
- `play(onComplete?)` - Triggers the effect. Returns a Promise that resolves when complete.
|
|
838
|
+
- `reset()` - Resets the effect to its initial state.
|
|
839
|
+
- `destroy()` - Destroys the effect and cleans up all resources.
|
|
840
|
+
|
|
522
841
|
---
|
|
523
842
|
|
|
524
843
|
## 📚 Configuration Guide
|
|
@@ -602,7 +921,7 @@ particles.emitter.behaviours.add(myCustomBehaviour)
|
|
|
602
921
|
// New and existing particles will use the new behaviour on the next update
|
|
603
922
|
```
|
|
604
923
|
|
|
605
|
-
**Extending built-in behaviours:**
|
|
924
|
+
**Extending built-in behaviours:** Core behaviour classes are exported directly from the package (for example `SpawnBehaviour`, `LifeBehaviour`, `PositionBehaviour`, `ColorBehaviour`, `SizeBehaviour`, `FormPatternBehaviour`, `ToroidalWrapBehaviour`, plus `Behaviour`, `BehaviourRegistry`, `EmitterBehaviours`, `BehaviourNames`). Advanced behaviours are available by name in emitter configs/editor presets; if you need class-level inheritance for one that is not exported at top-level, import from the package source in this repo.
|
|
606
925
|
|
|
607
926
|
**Replacing a built-in behaviour:** Register your class under the same name as a built-in (e.g. `SpawnBehaviour`) **before** creating the renderer or loading config. The registry is checked first, so your implementation is used instead. Use this for customizations like multiple trails on one shape, different trailing logic (e.g. CCV-style), or any variant of spawn/trail/position without changing the library.
|
|
608
927
|
|
|
@@ -696,7 +1015,7 @@ Defines where and how particles spawn. Supports multiple spawn types.
|
|
|
696
1015
|
- `Path` - Custom path defined by points
|
|
697
1016
|
- `Oval` - Elliptical distributions
|
|
698
1017
|
|
|
699
|
-
**Additional behaviours** (see the [editor](https://okuniewicz.eu/) for full documentation): Aizawa Attractor, Boids Flocking, Bounce, Color Cycle, Constrain To Shape, Conversion Cascade, Curvature Flow, Flicker, Float Up, Gravity Well, Homing, Jacobian Curl-Field, Lissajous Harmonic Lattice, Limit Cycle, Magnet, Near Miss Dispersion, Orbit, Phase Coherence, Phase Field Flow, Proximity State, Proximity Triggered Phase, Pulse, Ripple, Trail, Toroidal Flow, Vortex, Wobble
|
|
1018
|
+
**Additional behaviours** (see the [editor](https://okuniewicz.eu/) for full documentation): Aizawa Attractor, Beat Phase Lock, Bezier Flow Tube, Boids Flocking, Bounce, Color Cycle, Constrain To Shape, Conversion Cascade, Curvature Flow, Damage Flash Ripple, Emitter Attractor Link, Flicker, Float Up, Form Pattern, Gravity Well, Homing, Jacobian Curl-Field, Kelvin Wake, Lissajous Harmonic Lattice, Limit Cycle, Magnet, Near Miss Dispersion, Obstacle SDF Steer, Orbit, Phase Coherence, Phase Field Flow, Proximity State, Proximity Triggered Phase, Pulse, Ripple, RVO Avoidance, Screen Space Flow Map, Shear Flow, Toroidal Wrap, Trail, Toroidal Flow, Vortex, Wobble.
|
|
700
1019
|
|
|
701
1020
|
#### Size Behaviour
|
|
702
1021
|
Controls particle size over time.
|
|
@@ -961,60 +1280,6 @@ Moves particles toward specific points.
|
|
|
961
1280
|
}
|
|
962
1281
|
```
|
|
963
1282
|
|
|
964
|
-
#### Wireframe3D Behaviour
|
|
965
|
-
Renders 3D wireframe shapes (cube, sphere, pyramid, torus, cylinder, etc.) with optional orbit, pulsate, path motion, dashed lines, and depth styling. When this behaviour is present, the emitter is wrapped in a container that provides a Graphics object for the wireframe; use it for 3D-style particle backdrops or decorative shapes.
|
|
966
|
-
|
|
967
|
-
```javascript
|
|
968
|
-
{
|
|
969
|
-
priority: 50,
|
|
970
|
-
enabled: true,
|
|
971
|
-
shapeType: 'cube', // 'cube' | 'sphere' | 'pyramid' | 'torus' | 'cylinder' | 'tetrahedron' | 'octahedron' | 'grid' | 'lattice' | 'custom'
|
|
972
|
-
size: 100,
|
|
973
|
-
rotationSpeedX: 0.5,
|
|
974
|
-
rotationSpeedY: 0.3,
|
|
975
|
-
rotationSpeedZ: 0.2,
|
|
976
|
-
lineColor: 0xffffff,
|
|
977
|
-
lineWidth: 1,
|
|
978
|
-
perspective: 400,
|
|
979
|
-
cameraZ: 500,
|
|
980
|
-
depthStyle: 'none', // 'none' | 'fade' | 'thickness' | 'both'
|
|
981
|
-
sortByDepth: false,
|
|
982
|
-
orbitEnabled: false,
|
|
983
|
-
orbitRadius: 50,
|
|
984
|
-
orbitSpeed: 1,
|
|
985
|
-
pulsateEnabled: false,
|
|
986
|
-
pulsateMin: 80,
|
|
987
|
-
pulsateMax: 120,
|
|
988
|
-
pulsateSpeed: 2,
|
|
989
|
-
pathType: 'none',
|
|
990
|
-
pathSpeed: 1,
|
|
991
|
-
pathScale: 50,
|
|
992
|
-
dashedEnabled: false,
|
|
993
|
-
dashLength: 10,
|
|
994
|
-
gapLength: 5,
|
|
995
|
-
colorOverTimeEnabled: false,
|
|
996
|
-
colorOverTimeSpeed: 1,
|
|
997
|
-
perVertexColor: false,
|
|
998
|
-
noiseWobbleEnabled: false,
|
|
999
|
-
noiseWobbleAmount: 10,
|
|
1000
|
-
noiseWobbleSpeed: 1,
|
|
1001
|
-
attractParticlesEnabled: false,
|
|
1002
|
-
attractStrength: 0,
|
|
1003
|
-
latticeSegmentsX: 4,
|
|
1004
|
-
latticeSegmentsY: 4,
|
|
1005
|
-
latticeSegmentsZ: 4,
|
|
1006
|
-
gridSegments: 4,
|
|
1007
|
-
torusInnerRadius: 0.5,
|
|
1008
|
-
cylinderHeight: 1,
|
|
1009
|
-
customVertices: [],
|
|
1010
|
-
customEdges: [],
|
|
1011
|
-
wireframes: [],
|
|
1012
|
-
name: 'Wireframe3DBehaviour',
|
|
1013
|
-
}
|
|
1014
|
-
```
|
|
1015
|
-
|
|
1016
|
-
---
|
|
1017
|
-
|
|
1018
1283
|
## 💡 Examples
|
|
1019
1284
|
|
|
1020
1285
|
### Fire Effect
|
|
@@ -1189,6 +1454,14 @@ const textConfig = {
|
|
|
1189
1454
|
5. **FPS Capping**: Use `maxFPS` and `minFPS` to control update frequency
|
|
1190
1455
|
6. **Batch Updates**: Update multiple emitters in a single frame when possible
|
|
1191
1456
|
7. **Clean Up**: Call `destroy()` and `clearPool()` when done with emitters
|
|
1457
|
+
8. **Runtime `behaviour.enabled` toggles**: If you flip `enabled` on an existing behaviour instance without re-running the emitter parser (add/remove), call `emitter.behaviours.invalidateEnabledApplySnapshot()` before particle simulation runs, or rely on the next full `emitter.update()` after toggling in the same frame as other code paths that only call `apply`/`init` without going through `update()`.
|
|
1458
|
+
|
|
1459
|
+
### Profiling checklist (Chrome / Chromium)
|
|
1460
|
+
|
|
1461
|
+
1. Open **Performance** (or **JavaScript Profiler**), record while your effect runs at target particle count.
|
|
1462
|
+
2. In the flame chart, look for **`Emitter.update`**, **`EmitterBehaviours.apply`**, and behaviour names in hot frames.
|
|
1463
|
+
3. Confirm **GC** time: high allocation rates often come from per-frame object creation outside this library; spatial grids here use numeric cell keys to avoid string churn on neighbor queries.
|
|
1464
|
+
4. Compare **GPU** vs **CPU**: if the bottleneck is upload/draw, reduce `ParticleContainer` feature flags (`rotation`, `tint`, `uvs`) and particle count before micro-optimizing simulation.
|
|
1192
1465
|
|
|
1193
1466
|
---
|
|
1194
1467
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import Renderer from './lib/pixi/Renderer';
|
|
2
|
+
import SpriteContainerRenderer from './lib/pixi/SpriteContainerRenderer';
|
|
2
3
|
import { ICustomPixiParticlesSettings } from './lib/customPixiParticlesSettingsInterface';
|
|
3
4
|
import TestRenderer from './lib/pixi/TestRenderer';
|
|
4
|
-
import {
|
|
5
|
-
export type { IShatterEffectOptions, ShatterMode, IDissolveEffectOptions, DissolveDirection, IMagneticAssemblyOptions, AssemblyMode, IGhostEffectOptions, IGlitchEffectOptions, IMeltEffectOptions, IPixelSortEffectOptions, PixelSortDirection, PixelSortMode, PixelSortOrder, IPrismRefractionEffectOptions, ICrystallizeEffectOptions, ISlitScanEffectOptions, SlitScanMode, IGranularErosionEffectOptions, ILiquidMercuryEffectOptions } from './lib/effects';
|
|
5
|
+
import { CrystallizeEffect, DissolveEffect, GhostEffect, GlitchEffect, GranularErosionEffect, LiquidMercuryEffect, MagneticAssemblyEffect, MetaballPass, MeltEffect, PixelSortEffect, PrismRefractionEffect, ShatterEffect, SlitScanEffect } from './lib/effects';
|
|
6
|
+
export type { IShatterEffectOptions, ShatterMode, IDissolveEffectOptions, DissolveDirection, IMagneticAssemblyOptions, AssemblyMode, IGhostEffectOptions, IGlitchEffectOptions, IMeltEffectOptions, IPixelSortEffectOptions, PixelSortDirection, PixelSortMode, PixelSortOrder, IPrismRefractionEffectOptions, ICrystallizeEffectOptions, ISlitScanEffectOptions, SlitScanMode, IGranularErosionEffectOptions, ILiquidMercuryEffectOptions, IMetaballPassOptions, } from './lib/effects';
|
|
6
7
|
/**
|
|
7
8
|
* Constructs a renderer for custom pixi particles
|
|
8
9
|
* @class Renderer
|
|
9
10
|
* @param {ICustomPixiParticlesSettings} settings The settings for the renderer
|
|
10
11
|
*/
|
|
11
12
|
declare const customPixiParticles: {
|
|
12
|
-
create(settings: ICustomPixiParticlesSettings):
|
|
13
|
+
create(settings: ICustomPixiParticlesSettings): Renderer | SpriteContainerRenderer;
|
|
13
14
|
};
|
|
14
15
|
declare const _customPixiParticlesEditorOnly: {
|
|
15
16
|
create(settings: ICustomPixiParticlesSettings): TestRenderer;
|
|
16
17
|
};
|
|
18
|
+
export type { TextureVariant, TextureVariantFrames, TextureVariantStaticRandom } from './lib/textureVariants';
|
|
19
|
+
export type { IParticleLinkSettings } from './lib/pixi/particleLinkLayer';
|
|
20
|
+
export { drawParticleLinks, mergeParticleLinkSettings, PARTICLE_LINK_DEFAULTS, } from './lib/pixi/particleLinkLayer';
|
|
17
21
|
export type { IBehaviour } from './lib/behaviour';
|
|
18
|
-
export { Behaviour, BehaviourRegistry, EmitterBehaviours, SpawnBehaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, TimelineBehaviour, GroupingBehaviour, SoundReactiveBehaviour, LightEffectBehaviour, StretchBehaviour, TemperatureBehaviour, MoveToPointBehaviour,
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
22
|
+
export { Behaviour, BehaviourRegistry, EmitterBehaviours, SpawnBehaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, CollisionBehaviour, AttractionRepulsionBehaviour, NoiseBasedMotionBehaviour, ForceFieldsBehaviour, TimelineBehaviour, GroupingBehaviour, SoundReactiveBehaviour, LightEffectBehaviour, StretchBehaviour, TemperatureBehaviour, MoveToPointBehaviour, FormPatternBehaviour, type FormPatternMode, type FormPatternProgressMode, type FormPatternAssignmentMode, type FormPatternBakedPolylineMode, type FormPatternPathKind, type FormPatternSinePhaseMode, type FormPatternStaggerOrder, type FormPatternPathVarietySeedMode, type FormPatternVisualModulation, ToroidalWrapBehaviour, BehaviourNames, } from './lib/behaviour';
|
|
23
|
+
export { rasterizeTextToPoints, buildPresetShape, matchPointsToCount, resampleToCount, flattenSvgPathToPoints, assignGreedyNearest, assignByPolarAngle, assignHungarian, hungarianMinAssignment, assignHungarianTargetIndices, assignGreedyNearestTargetIndices, assignByPolarAngleTargetIndices, sortTargetIndicesByAngle, blendMorphedPresets, rasterizeOpaquePixelsToPoints, rasterizeOpaquePixelsToPointsWithColors, matchSamplesToCount, sortPointsByAngle, shuffledIndices, seededUnit, extractSvgPathDFromMarkup, parseSvgViewBox, normalizePointsToBounds, replicatePointsByWeights, sampleMorphKeyframes, assignPathOrderTargetIndices, rasterizeOpaquePixelsToPointsWeighted, rasterizeOpaquePixelsToPointsWithColorsWeighted, } from './lib/util/formPatternSampling';
|
|
24
|
+
export type { PresetShapeType, PresetShapeParams, TextRasterMode, RasterizeTextOptions, PointRgb, MorphKeyframe, IParticleXYWithUid, } from './lib/util/formPatternSampling';
|
|
25
|
+
export { PersistentFillEmission } from './lib/emission';
|
|
26
|
+
export { PersistentWrapEmitter } from './lib/emitter';
|
|
27
|
+
export { Application, Loader } from 'pixi.js-legacy';
|
|
28
|
+
export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ICustomPixiParticlesSettings, ShatterEffect, DissolveEffect, MagneticAssemblyEffect, GhostEffect, GlitchEffect, MeltEffect, PixelSortEffect, PrismRefractionEffect, CrystallizeEffect, SlitScanEffect, GranularErosionEffect, LiquidMercuryEffect, MetaballPass, };
|