@tsparticles/preset-triangles 4.5.0 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
2
|
(function (g) {
|
|
3
|
-
/* Preset v4.5.
|
|
3
|
+
/* Preset v4.5.2 */
|
|
4
4
|
g.__tsParticlesInternals = g.__tsParticlesInternals || {};
|
|
5
5
|
g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
6
6
|
(function (exports) {
|
|
@@ -120,7 +120,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
120
120
|
}
|
|
121
121
|
normalize() {
|
|
122
122
|
const length = this.length;
|
|
123
|
-
if (length
|
|
123
|
+
if (length !== none) {
|
|
124
124
|
this.multTo(inverseFactorNumerator / length);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -657,12 +657,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
657
657
|
}
|
|
658
658
|
addEventListener(type, listener) {
|
|
659
659
|
this.removeEventListener(type, listener);
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
arr = [];
|
|
663
|
-
this.#listeners.set(type, arr);
|
|
664
|
-
}
|
|
665
|
-
arr.push(listener);
|
|
660
|
+
const arr = this.#listeners.get(type);
|
|
661
|
+
this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
|
|
666
662
|
}
|
|
667
663
|
dispatchEvent(type, args) {
|
|
668
664
|
const listeners = this.#listeners.get(type);
|
|
@@ -694,7 +690,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
694
690
|
this.#listeners.delete(type);
|
|
695
691
|
}
|
|
696
692
|
else {
|
|
697
|
-
arr.
|
|
693
|
+
this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
|
|
698
694
|
}
|
|
699
695
|
}
|
|
700
696
|
}
|
|
@@ -871,11 +867,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
871
867
|
#domArray = [];
|
|
872
868
|
#eventDispatcher = new EventDispatcher();
|
|
873
869
|
#initialized = false;
|
|
870
|
+
#loadSequence = 0;
|
|
871
|
+
#loadSequences = new Map();
|
|
874
872
|
get items() {
|
|
875
873
|
return this.#domArray;
|
|
876
874
|
}
|
|
877
875
|
get version() {
|
|
878
|
-
return "4.5.
|
|
876
|
+
return "4.5.2";
|
|
879
877
|
}
|
|
880
878
|
addEventListener(type, listener) {
|
|
881
879
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -905,44 +903,60 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
905
903
|
return item;
|
|
906
904
|
}
|
|
907
905
|
async load(params) {
|
|
908
|
-
await this.init();
|
|
909
906
|
let domSourceElement;
|
|
910
907
|
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
911
908
|
domSourceElement = params.element;
|
|
912
909
|
}
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
910
|
+
const id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, loadSequence = ++this.#loadSequence;
|
|
911
|
+
this.#loadSequences.set(id, loadSequence);
|
|
912
|
+
try {
|
|
913
|
+
await this.init();
|
|
914
|
+
const { Container } = await Promise.resolve().then(function () { return Container$1; }), { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
|
|
915
|
+
if (this.#loadSequences.get(id) !== loadSequence) {
|
|
916
|
+
return undefined;
|
|
917
|
+
}
|
|
918
|
+
const currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
919
|
+
dispatchCallback: (eventType, args) => {
|
|
920
|
+
this.dispatchEvent(eventType, args);
|
|
921
|
+
},
|
|
922
|
+
id,
|
|
923
|
+
onDestroy: (remove) => {
|
|
924
|
+
if (!remove) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const mainArr = this.items, idx = mainArr.indexOf(newItem);
|
|
928
|
+
if (idx >= removeMinIndex) {
|
|
929
|
+
mainArr.splice(idx, removeDeleteCount);
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
pluginManager: this.pluginManager,
|
|
933
|
+
sourceOptions: currentOptions,
|
|
934
|
+
});
|
|
935
|
+
if (oldIndex >= loadMinIndex) {
|
|
936
|
+
const old = this.item(oldIndex), deleteCount = old ? one : none;
|
|
937
|
+
if (old && !old.destroyed) {
|
|
938
|
+
old.destroy(false);
|
|
925
939
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
940
|
+
items.splice(oldIndex, deleteCount, newItem);
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
items.push(newItem);
|
|
944
|
+
}
|
|
945
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
946
|
+
? params.element
|
|
947
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
948
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
949
|
+
await newItem.start();
|
|
950
|
+
if (newItem.destroyed) {
|
|
951
|
+
return undefined;
|
|
934
952
|
}
|
|
935
|
-
|
|
953
|
+
return newItem;
|
|
936
954
|
}
|
|
937
|
-
|
|
938
|
-
|
|
955
|
+
finally {
|
|
956
|
+
if (this.#loadSequences.get(id) === loadSequence) {
|
|
957
|
+
this.#loadSequences.delete(id);
|
|
958
|
+
}
|
|
939
959
|
}
|
|
940
|
-
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
941
|
-
? params.element
|
|
942
|
-
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
943
|
-
newItem.canvas.loadCanvas(sourceCanvas);
|
|
944
|
-
await newItem.start();
|
|
945
|
-
return newItem;
|
|
946
960
|
}
|
|
947
961
|
async refresh(refresh = true) {
|
|
948
962
|
if (!refresh) {
|
|
@@ -2329,6 +2343,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2329
2343
|
}
|
|
2330
2344
|
}
|
|
2331
2345
|
|
|
2346
|
+
function hasEnabledBlend(particleOptions) {
|
|
2347
|
+
if (!particleOptions || typeof particleOptions !== "object" || !("blend" in particleOptions)) {
|
|
2348
|
+
return false;
|
|
2349
|
+
}
|
|
2350
|
+
const blend = particleOptions.blend;
|
|
2351
|
+
return !!blend && typeof blend === "object" && "enable" in blend && !!blend.enable;
|
|
2352
|
+
}
|
|
2332
2353
|
class BlendPlugin {
|
|
2333
2354
|
id = "blend";
|
|
2334
2355
|
async getPlugin(container) {
|
|
@@ -2350,12 +2371,31 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2350
2371
|
options.blend.load(source?.blend);
|
|
2351
2372
|
}
|
|
2352
2373
|
needsPlugin(options) {
|
|
2353
|
-
|
|
2374
|
+
if (options?.blend?.enable ||
|
|
2375
|
+
options?.particles?.blend?.enable ||
|
|
2376
|
+
Object.values(options?.particles?.groups ?? {}).some(hasEnabledBlend)) {
|
|
2377
|
+
return true;
|
|
2378
|
+
}
|
|
2379
|
+
const emitters = options?.["emitters"];
|
|
2380
|
+
let emitterList = [];
|
|
2381
|
+
if (Array.isArray(emitters)) {
|
|
2382
|
+
emitterList = emitters;
|
|
2383
|
+
}
|
|
2384
|
+
else if (emitters) {
|
|
2385
|
+
emitterList = [emitters];
|
|
2386
|
+
}
|
|
2387
|
+
return emitterList.some(emitter => {
|
|
2388
|
+
if (!emitter || typeof emitter !== "object" || !("particles" in emitter)) {
|
|
2389
|
+
return false;
|
|
2390
|
+
}
|
|
2391
|
+
const particles = emitter.particles;
|
|
2392
|
+
return Array.isArray(particles) ? particles.some(hasEnabledBlend) : hasEnabledBlend(particles);
|
|
2393
|
+
});
|
|
2354
2394
|
}
|
|
2355
2395
|
}
|
|
2356
2396
|
|
|
2357
2397
|
async function loadBlendPlugin(engine) {
|
|
2358
|
-
engine.checkVersion("4.5.
|
|
2398
|
+
engine.checkVersion("4.5.2");
|
|
2359
2399
|
await engine.pluginManager.register(e => {
|
|
2360
2400
|
e.pluginManager.addPlugin(new BlendPlugin());
|
|
2361
2401
|
});
|
|
@@ -2392,7 +2432,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2392
2432
|
}
|
|
2393
2433
|
|
|
2394
2434
|
async function loadCircleShape(engine) {
|
|
2395
|
-
engine.checkVersion("4.5.
|
|
2435
|
+
engine.checkVersion("4.5.2");
|
|
2396
2436
|
await engine.pluginManager.register(e => {
|
|
2397
2437
|
e.pluginManager.addShape(["circle"], () => {
|
|
2398
2438
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2440,7 +2480,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2440
2480
|
}
|
|
2441
2481
|
|
|
2442
2482
|
async function loadHexColorPlugin(engine) {
|
|
2443
|
-
engine.checkVersion("4.5.
|
|
2483
|
+
engine.checkVersion("4.5.2");
|
|
2444
2484
|
await engine.pluginManager.register(e => {
|
|
2445
2485
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2446
2486
|
});
|
|
@@ -2493,7 +2533,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2493
2533
|
}
|
|
2494
2534
|
|
|
2495
2535
|
async function loadHslColorPlugin(engine) {
|
|
2496
|
-
engine.checkVersion("4.5.
|
|
2536
|
+
engine.checkVersion("4.5.2");
|
|
2497
2537
|
await engine.pluginManager.register(e => {
|
|
2498
2538
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2499
2539
|
});
|
|
@@ -2525,7 +2565,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2525
2565
|
}
|
|
2526
2566
|
|
|
2527
2567
|
async function loadMovePlugin(engine) {
|
|
2528
|
-
engine.checkVersion("4.5.
|
|
2568
|
+
engine.checkVersion("4.5.2");
|
|
2529
2569
|
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
2530
2570
|
addErrorMessages(ErrorMessages$1);
|
|
2531
2571
|
}
|
|
@@ -2735,7 +2775,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
2735
2775
|
}
|
|
2736
2776
|
|
|
2737
2777
|
async function loadOpacityUpdater(engine) {
|
|
2738
|
-
engine.checkVersion("4.5.
|
|
2778
|
+
engine.checkVersion("4.5.2");
|
|
2739
2779
|
await engine.pluginManager.register(e => {
|
|
2740
2780
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
2741
2781
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3064,7 +3104,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3064
3104
|
}
|
|
3065
3105
|
|
|
3066
3106
|
async function loadOutModesUpdater(engine) {
|
|
3067
|
-
engine.checkVersion("4.5.
|
|
3107
|
+
engine.checkVersion("4.5.2");
|
|
3068
3108
|
await engine.pluginManager.register(e => {
|
|
3069
3109
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3070
3110
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3143,7 +3183,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3143
3183
|
}
|
|
3144
3184
|
|
|
3145
3185
|
async function loadPaintUpdater(engine) {
|
|
3146
|
-
engine.checkVersion("4.5.
|
|
3186
|
+
engine.checkVersion("4.5.2");
|
|
3147
3187
|
await engine.pluginManager.register(e => {
|
|
3148
3188
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3149
3189
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3198,7 +3238,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3198
3238
|
}
|
|
3199
3239
|
|
|
3200
3240
|
async function loadRgbColorPlugin(engine) {
|
|
3201
|
-
engine.checkVersion("4.5.
|
|
3241
|
+
engine.checkVersion("4.5.2");
|
|
3202
3242
|
await engine.pluginManager.register(e => {
|
|
3203
3243
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3204
3244
|
});
|
|
@@ -3283,7 +3323,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3283
3323
|
}
|
|
3284
3324
|
|
|
3285
3325
|
async function loadSizeUpdater(engine) {
|
|
3286
|
-
engine.checkVersion("4.5.
|
|
3326
|
+
engine.checkVersion("4.5.2");
|
|
3287
3327
|
await engine.pluginManager.register(e => {
|
|
3288
3328
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3289
3329
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3292,7 +3332,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3292
3332
|
}
|
|
3293
3333
|
|
|
3294
3334
|
async function loadBasic(engine) {
|
|
3295
|
-
engine.checkVersion("4.5.
|
|
3335
|
+
engine.checkVersion("4.5.2");
|
|
3296
3336
|
await engine.pluginManager.register(async (e) => {
|
|
3297
3337
|
await Promise.all([
|
|
3298
3338
|
loadBlendPlugin(e),
|
|
@@ -3498,7 +3538,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3498
3538
|
const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
|
|
3499
3539
|
|
|
3500
3540
|
async function loadInteractivityPlugin(engine) {
|
|
3501
|
-
engine.checkVersion("4.5.
|
|
3541
|
+
engine.checkVersion("4.5.2");
|
|
3502
3542
|
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
3503
3543
|
addErrorMessages(ErrorMessages);
|
|
3504
3544
|
}
|
|
@@ -3538,8 +3578,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3538
3578
|
this.#canvasSize = canvasSize;
|
|
3539
3579
|
}
|
|
3540
3580
|
contains(point) {
|
|
3541
|
-
if (super.contains(point))
|
|
3581
|
+
if (super.contains(point)) {
|
|
3542
3582
|
return true;
|
|
3583
|
+
}
|
|
3543
3584
|
const { width, height } = this.#canvasSize, { x, y } = point;
|
|
3544
3585
|
return (super.contains({ x: x - width, y }) ||
|
|
3545
3586
|
super.contains({ x: x + width, y }) ||
|
|
@@ -3551,8 +3592,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3551
3592
|
super.contains({ x: x + width, y: y - height }));
|
|
3552
3593
|
}
|
|
3553
3594
|
intersects(range) {
|
|
3554
|
-
if (super.intersects(range))
|
|
3595
|
+
if (super.intersects(range)) {
|
|
3555
3596
|
return true;
|
|
3597
|
+
}
|
|
3556
3598
|
const { width, height } = this.#canvasSize, pos = range.position, shifts = [
|
|
3557
3599
|
{ x: -width, y: 0 },
|
|
3558
3600
|
{ x: width, y: 0 },
|
|
@@ -3573,11 +3615,40 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3573
3615
|
const rect = range;
|
|
3574
3616
|
shiftedRange = new Rectangle(shiftedPos.x, shiftedPos.y, rect.size.width, rect.size.height);
|
|
3575
3617
|
}
|
|
3576
|
-
if (super.intersects(shiftedRange))
|
|
3618
|
+
if (super.intersects(shiftedRange)) {
|
|
3577
3619
|
return true;
|
|
3620
|
+
}
|
|
3578
3621
|
}
|
|
3579
3622
|
return false;
|
|
3580
3623
|
}
|
|
3624
|
+
query(grid) {
|
|
3625
|
+
const { x, y } = this.position, { width, height } = this.#canvasSize, radius = this.radius, crossesLeft = x - radius <= originPoint.x, crossesRight = x + radius >= width, crossesTop = y - radius <= originPoint.y, crossesBottom = y + radius >= height;
|
|
3626
|
+
if (!crossesLeft && !crossesRight && !crossesTop && !crossesBottom) {
|
|
3627
|
+
return grid.query(this);
|
|
3628
|
+
}
|
|
3629
|
+
const xShifts = [originPoint.x], yShifts = [originPoint.y];
|
|
3630
|
+
if (crossesLeft) {
|
|
3631
|
+
xShifts.push(width);
|
|
3632
|
+
}
|
|
3633
|
+
if (crossesRight) {
|
|
3634
|
+
xShifts.push(-width);
|
|
3635
|
+
}
|
|
3636
|
+
if (crossesTop) {
|
|
3637
|
+
yShifts.push(height);
|
|
3638
|
+
}
|
|
3639
|
+
if (crossesBottom) {
|
|
3640
|
+
yShifts.push(-height);
|
|
3641
|
+
}
|
|
3642
|
+
const particles = new Set();
|
|
3643
|
+
for (const dx of xShifts) {
|
|
3644
|
+
for (const dy of yShifts) {
|
|
3645
|
+
for (const particle of grid.queryCircle({ x: x + dx, y: y + dy }, radius)) {
|
|
3646
|
+
particles.add(particle);
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
return [...particles];
|
|
3651
|
+
}
|
|
3581
3652
|
}
|
|
3582
3653
|
|
|
3583
3654
|
class LinksShadow {
|
|
@@ -3687,7 +3758,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3687
3758
|
if (pos1.x < originPoint.x || pos1.y < originPoint.y || pos1.x > canvasSize.width || pos1.y > canvasSize.height) {
|
|
3688
3759
|
return;
|
|
3689
3760
|
}
|
|
3690
|
-
const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp,
|
|
3761
|
+
const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp, query = (warp
|
|
3762
|
+
? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize).query(container.particles.grid)
|
|
3763
|
+
: container.particles.grid.queryCircle(pos1, optDistance));
|
|
3691
3764
|
for (const p2 of query) {
|
|
3692
3765
|
const linkOpt2 = p2.options.links;
|
|
3693
3766
|
if (p1 === p2 ||
|
|
@@ -3775,7 +3848,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
3775
3848
|
}
|
|
3776
3849
|
|
|
3777
3850
|
async function loadParticlesLinksInteraction(engine) {
|
|
3778
|
-
engine.checkVersion("4.5.
|
|
3851
|
+
engine.checkVersion("4.5.2");
|
|
3779
3852
|
await engine.pluginManager.register((e) => {
|
|
3780
3853
|
const pluginManager = e.pluginManager;
|
|
3781
3854
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -4003,7 +4076,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4003
4076
|
});
|
|
4004
4077
|
}
|
|
4005
4078
|
drawParticles(delta) {
|
|
4006
|
-
const { particles, actualOptions } = this.#container
|
|
4079
|
+
const { particles, actualOptions } = this.#container;
|
|
4080
|
+
this.clear();
|
|
4007
4081
|
particles.update(delta);
|
|
4008
4082
|
this.draw(ctx => {
|
|
4009
4083
|
const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
|
|
@@ -4025,9 +4099,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4025
4099
|
}
|
|
4026
4100
|
}
|
|
4027
4101
|
for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
|
|
4028
|
-
|
|
4029
|
-
plugin.canvasPaint?.();
|
|
4030
|
-
}
|
|
4102
|
+
plugin.canvasPaint?.();
|
|
4031
4103
|
}
|
|
4032
4104
|
for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
|
|
4033
4105
|
plugin.drawSettingsSetup?.(ctx, delta);
|
|
@@ -4117,6 +4189,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4117
4189
|
ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
|
|
4118
4190
|
});
|
|
4119
4191
|
}
|
|
4192
|
+
updateBackgroundElement() {
|
|
4193
|
+
this.#resolveBackgroundElement();
|
|
4194
|
+
}
|
|
4120
4195
|
#applyPostDrawUpdaters(particle) {
|
|
4121
4196
|
for (const updater of this.#postDrawUpdaters) {
|
|
4122
4197
|
updater.afterDraw?.(particle);
|
|
@@ -4315,7 +4390,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4315
4390
|
}
|
|
4316
4391
|
if (typeof background.element === "string") {
|
|
4317
4392
|
if (typeof document !== "undefined") {
|
|
4318
|
-
|
|
4393
|
+
let node;
|
|
4394
|
+
try {
|
|
4395
|
+
node = document.querySelector(background.element);
|
|
4396
|
+
}
|
|
4397
|
+
catch {
|
|
4398
|
+
this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
|
|
4399
|
+
return;
|
|
4400
|
+
}
|
|
4319
4401
|
if (node && this.#isSupportedElement(node)) {
|
|
4320
4402
|
this.#backgroundElement = node;
|
|
4321
4403
|
}
|
|
@@ -4761,6 +4843,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
4761
4843
|
this.#manageListeners(true);
|
|
4762
4844
|
}
|
|
4763
4845
|
removeListeners() {
|
|
4846
|
+
if (this.#resizeTimeout !== undefined) {
|
|
4847
|
+
clearTimeout(this.#resizeTimeout);
|
|
4848
|
+
this.#resizeTimeout = undefined;
|
|
4849
|
+
}
|
|
4764
4850
|
this.#manageListeners(false);
|
|
4765
4851
|
}
|
|
4766
4852
|
#handleVisibilityChange() {
|
|
@@ -5135,10 +5221,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5135
5221
|
runParticleCreatedPlugins(container, this);
|
|
5136
5222
|
}
|
|
5137
5223
|
isInsideCanvas(direction) {
|
|
5138
|
-
return this.#getInsideCanvasResult(
|
|
5224
|
+
return this.#getInsideCanvasResult(direction).inside;
|
|
5139
5225
|
}
|
|
5140
5226
|
isInsideCanvasForOutMode(outMode, direction) {
|
|
5141
|
-
return this.#getInsideCanvasResult(
|
|
5227
|
+
return this.#getInsideCanvasResult(direction, outMode).inside;
|
|
5142
5228
|
}
|
|
5143
5229
|
isShowingBack() {
|
|
5144
5230
|
if (!this.roll) {
|
|
@@ -5255,7 +5341,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5255
5341
|
});
|
|
5256
5342
|
}
|
|
5257
5343
|
#getDefaultInsideCanvasResult(direction, outMode) {
|
|
5258
|
-
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
|
|
5344
|
+
const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
|
|
5259
5345
|
if (direction === OutModeDirection.bottom) {
|
|
5260
5346
|
return {
|
|
5261
5347
|
inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
|
|
@@ -5297,12 +5383,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5297
5383
|
radius: this.getRadius(),
|
|
5298
5384
|
};
|
|
5299
5385
|
}
|
|
5300
|
-
#getInsideCanvasResult(
|
|
5301
|
-
const defaultResult = this.#getDefaultInsideCanvasResult(
|
|
5302
|
-
if (!
|
|
5386
|
+
#getInsideCanvasResult(direction, outMode) {
|
|
5387
|
+
const defaultResult = this.#getDefaultInsideCanvasResult(direction, outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined;
|
|
5388
|
+
if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
|
|
5303
5389
|
return defaultResult;
|
|
5304
5390
|
}
|
|
5305
|
-
const callbackData = this.#getInsideCanvasCallbackData(
|
|
5391
|
+
const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
|
|
5392
|
+
? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
|
|
5393
|
+
: undefined, effectResult = effectDrawer?.isInsideCanvas
|
|
5394
|
+
? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
|
|
5395
|
+
: undefined;
|
|
5306
5396
|
if (shapeResult && effectResult) {
|
|
5307
5397
|
const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
|
|
5308
5398
|
return {
|
|
@@ -5368,8 +5458,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5368
5458
|
}
|
|
5369
5459
|
|
|
5370
5460
|
class SpatialHashGrid {
|
|
5371
|
-
#cellSize;
|
|
5372
5461
|
#cells = new Map();
|
|
5462
|
+
#cellSize;
|
|
5373
5463
|
#circlePool = [];
|
|
5374
5464
|
#circlePoolIdx;
|
|
5375
5465
|
#pendingCellSize;
|
|
@@ -5415,14 +5505,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5415
5505
|
return out;
|
|
5416
5506
|
}
|
|
5417
5507
|
queryCircle(position, radius, check, out = []) {
|
|
5418
|
-
const circle = this.#acquireCircle(position.x, position.y, radius)
|
|
5419
|
-
|
|
5420
|
-
|
|
5508
|
+
const circle = this.#acquireCircle(position.x, position.y, radius);
|
|
5509
|
+
try {
|
|
5510
|
+
return this.query(circle, check, out);
|
|
5511
|
+
}
|
|
5512
|
+
finally {
|
|
5513
|
+
this.#circlePoolIdx--;
|
|
5514
|
+
}
|
|
5421
5515
|
}
|
|
5422
5516
|
queryRectangle(position, size, check, out = []) {
|
|
5423
|
-
const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height)
|
|
5424
|
-
|
|
5425
|
-
|
|
5517
|
+
const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
|
|
5518
|
+
try {
|
|
5519
|
+
return this.query(rect, check, out);
|
|
5520
|
+
}
|
|
5521
|
+
finally {
|
|
5522
|
+
this.#rectanglePoolIdx--;
|
|
5523
|
+
}
|
|
5426
5524
|
}
|
|
5427
5525
|
#acquireCircle(x, y, r) {
|
|
5428
5526
|
const idx = this.#circlePoolIdx++;
|
|
@@ -5481,10 +5579,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
5481
5579
|
}
|
|
5482
5580
|
}
|
|
5483
5581
|
}
|
|
5484
|
-
#releaseShapes() {
|
|
5485
|
-
this.#circlePoolIdx = 0;
|
|
5486
|
-
this.#rectanglePoolIdx = 0;
|
|
5487
|
-
}
|
|
5488
5582
|
}
|
|
5489
5583
|
|
|
5490
5584
|
class ParticlesManager {
|
|
@@ -6023,8 +6117,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6023
6117
|
particleCreatedPlugins;
|
|
6024
6118
|
particleDestroyedPlugins;
|
|
6025
6119
|
particlePositionPlugins;
|
|
6026
|
-
particleUpdaters;
|
|
6027
6120
|
particles;
|
|
6121
|
+
particleUpdaters;
|
|
6028
6122
|
peakNits;
|
|
6029
6123
|
plugins;
|
|
6030
6124
|
retina;
|
|
@@ -6032,6 +6126,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6032
6126
|
started;
|
|
6033
6127
|
zLayers;
|
|
6034
6128
|
#delay;
|
|
6129
|
+
#delayResolve;
|
|
6035
6130
|
#delayTimeout;
|
|
6036
6131
|
#delta = { value: 0, factor: 0 };
|
|
6037
6132
|
#dispatchCallback;
|
|
@@ -6270,7 +6365,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6270
6365
|
await this.init();
|
|
6271
6366
|
this.started = true;
|
|
6272
6367
|
await new Promise(resolve => {
|
|
6368
|
+
this.#delayResolve = resolve;
|
|
6273
6369
|
const start = async () => {
|
|
6370
|
+
this.#delayTimeout = undefined;
|
|
6371
|
+
this.#delayResolve = undefined;
|
|
6274
6372
|
this.#eventListeners.addListeners();
|
|
6275
6373
|
for (const plugin of this.plugins) {
|
|
6276
6374
|
await plugin.start?.();
|
|
@@ -6286,9 +6384,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6286
6384
|
if (!guardCheck(this) || !this.started) {
|
|
6287
6385
|
return;
|
|
6288
6386
|
}
|
|
6289
|
-
if (this.#delayTimeout) {
|
|
6387
|
+
if (this.#delayTimeout !== undefined) {
|
|
6290
6388
|
clearTimeout(this.#delayTimeout);
|
|
6291
6389
|
this.#delayTimeout = undefined;
|
|
6390
|
+
this.#delayResolve?.();
|
|
6391
|
+
this.#delayResolve = undefined;
|
|
6292
6392
|
}
|
|
6293
6393
|
this.#firstStart = true;
|
|
6294
6394
|
this.started = false;
|
|
@@ -6312,6 +6412,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6312
6412
|
refresh = plugin.updateActualOptions() || refresh;
|
|
6313
6413
|
}
|
|
6314
6414
|
}
|
|
6415
|
+
this.canvas.render.updateBackgroundElement();
|
|
6315
6416
|
return refresh;
|
|
6316
6417
|
}
|
|
6317
6418
|
#initPlugins(allContainerPlugins) {
|
|
@@ -6722,7 +6823,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
|
|
|
6722
6823
|
manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
|
|
6723
6824
|
manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
|
|
6724
6825
|
manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
|
|
6725
|
-
|
|
6826
|
+
const onClickEnabled = !!options.interactivity?.events.onClick.enable;
|
|
6827
|
+
manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add && onClickEnabled);
|
|
6828
|
+
manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add && !onClickEnabled);
|
|
6726
6829
|
manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
|
|
6727
6830
|
manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
|
|
6728
6831
|
manageListener(interactivityEl, mouseLeaveEvent, handlers.mouseLeave, add);
|