@tsparticles/preset-fireworks 4.0.0-beta.16 → 4.0.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.
|
@@ -1,5 +1,5 @@
|
|
|
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);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Preset v4.0.0
|
|
2
|
+
/* Preset v4.0.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
b: 0,
|
|
16
16
|
c: 0,
|
|
17
17
|
d: 1,
|
|
18
|
-
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha$1 = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0,
|
|
18
|
+
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha$1 = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity$1 = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity$2 = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0, defaultZoom = 1;
|
|
19
19
|
|
|
20
20
|
var MoveDirection;
|
|
21
21
|
(function (MoveDirection) {
|
|
@@ -984,7 +984,7 @@
|
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
else {
|
|
987
|
-
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases
|
|
987
|
+
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
|
|
988
988
|
if (foundCanvas) {
|
|
989
989
|
canvasEl = foundCanvas;
|
|
990
990
|
canvasEl.dataset[generatedAttribute] = generatedFalse;
|
|
@@ -1021,7 +1021,7 @@
|
|
|
1021
1021
|
return this._domArray;
|
|
1022
1022
|
}
|
|
1023
1023
|
get version() {
|
|
1024
|
-
return "4.0.0
|
|
1024
|
+
return "4.0.0";
|
|
1025
1025
|
}
|
|
1026
1026
|
addEventListener(type, listener) {
|
|
1027
1027
|
this._eventDispatcher.addEventListener(type, listener);
|
|
@@ -1052,7 +1052,11 @@
|
|
|
1052
1052
|
}
|
|
1053
1053
|
async load(params) {
|
|
1054
1054
|
await this.init();
|
|
1055
|
-
|
|
1055
|
+
let domSourceElement;
|
|
1056
|
+
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
1057
|
+
domSourceElement = params.element;
|
|
1058
|
+
}
|
|
1059
|
+
const { Container } = await Promise.resolve().then(function () { return Container$1; }), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
1056
1060
|
dispatchCallback: (eventType, args) => {
|
|
1057
1061
|
this.dispatchEvent(eventType, args);
|
|
1058
1062
|
},
|
|
@@ -1079,8 +1083,10 @@
|
|
|
1079
1083
|
else {
|
|
1080
1084
|
items.push(newItem);
|
|
1081
1085
|
}
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1086
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
1087
|
+
? params.element
|
|
1088
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
1089
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
1084
1090
|
await newItem.start();
|
|
1085
1091
|
return newItem;
|
|
1086
1092
|
}
|
|
@@ -3129,7 +3135,7 @@
|
|
|
3129
3135
|
}
|
|
3130
3136
|
|
|
3131
3137
|
async function loadCircleShape(engine) {
|
|
3132
|
-
engine.checkVersion("4.0.0
|
|
3138
|
+
engine.checkVersion("4.0.0");
|
|
3133
3139
|
await engine.pluginManager.register(e => {
|
|
3134
3140
|
e.pluginManager.addShape(["circle"], () => {
|
|
3135
3141
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -3177,7 +3183,7 @@
|
|
|
3177
3183
|
}
|
|
3178
3184
|
|
|
3179
3185
|
async function loadHexColorPlugin(engine) {
|
|
3180
|
-
engine.checkVersion("4.0.0
|
|
3186
|
+
engine.checkVersion("4.0.0");
|
|
3181
3187
|
await engine.pluginManager.register(e => {
|
|
3182
3188
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
3183
3189
|
});
|
|
@@ -3230,7 +3236,7 @@
|
|
|
3230
3236
|
}
|
|
3231
3237
|
|
|
3232
3238
|
async function loadHslColorPlugin(engine) {
|
|
3233
|
-
engine.checkVersion("4.0.0
|
|
3239
|
+
engine.checkVersion("4.0.0");
|
|
3234
3240
|
await engine.pluginManager.register(e => {
|
|
3235
3241
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
3236
3242
|
});
|
|
@@ -3254,7 +3260,7 @@
|
|
|
3254
3260
|
}
|
|
3255
3261
|
|
|
3256
3262
|
async function loadMovePlugin(engine) {
|
|
3257
|
-
engine.checkVersion("4.0.0
|
|
3263
|
+
engine.checkVersion("4.0.0");
|
|
3258
3264
|
await engine.pluginManager.register(e => {
|
|
3259
3265
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
3260
3266
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -3315,7 +3321,7 @@
|
|
|
3315
3321
|
}
|
|
3316
3322
|
|
|
3317
3323
|
async function loadOpacityUpdater(engine) {
|
|
3318
|
-
engine.checkVersion("4.0.0
|
|
3324
|
+
engine.checkVersion("4.0.0");
|
|
3319
3325
|
await engine.pluginManager.register(e => {
|
|
3320
3326
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3321
3327
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3667,7 +3673,7 @@
|
|
|
3667
3673
|
}
|
|
3668
3674
|
|
|
3669
3675
|
async function loadOutModesUpdater(engine) {
|
|
3670
|
-
engine.checkVersion("4.0.0
|
|
3676
|
+
engine.checkVersion("4.0.0");
|
|
3671
3677
|
await engine.pluginManager.register(e => {
|
|
3672
3678
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3673
3679
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3738,7 +3744,7 @@
|
|
|
3738
3744
|
}
|
|
3739
3745
|
|
|
3740
3746
|
async function loadPaintUpdater(engine) {
|
|
3741
|
-
engine.checkVersion("4.0.0
|
|
3747
|
+
engine.checkVersion("4.0.0");
|
|
3742
3748
|
await engine.pluginManager.register(e => {
|
|
3743
3749
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3744
3750
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3793,7 +3799,7 @@
|
|
|
3793
3799
|
}
|
|
3794
3800
|
|
|
3795
3801
|
async function loadRgbColorPlugin(engine) {
|
|
3796
|
-
engine.checkVersion("4.0.0
|
|
3802
|
+
engine.checkVersion("4.0.0");
|
|
3797
3803
|
await engine.pluginManager.register(e => {
|
|
3798
3804
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3799
3805
|
});
|
|
@@ -3836,7 +3842,7 @@
|
|
|
3836
3842
|
}
|
|
3837
3843
|
|
|
3838
3844
|
async function loadSizeUpdater(engine) {
|
|
3839
|
-
engine.checkVersion("4.0.0
|
|
3845
|
+
engine.checkVersion("4.0.0");
|
|
3840
3846
|
await engine.pluginManager.register(e => {
|
|
3841
3847
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3842
3848
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3845,7 +3851,7 @@
|
|
|
3845
3851
|
}
|
|
3846
3852
|
|
|
3847
3853
|
async function loadBasic(engine) {
|
|
3848
|
-
engine.checkVersion("4.0.0
|
|
3854
|
+
engine.checkVersion("4.0.0");
|
|
3849
3855
|
await engine.pluginManager.register(async (e) => {
|
|
3850
3856
|
await Promise.all([
|
|
3851
3857
|
loadHexColorPlugin(e),
|
|
@@ -4214,7 +4220,7 @@
|
|
|
4214
4220
|
}
|
|
4215
4221
|
|
|
4216
4222
|
async function loadDestroyUpdater(engine) {
|
|
4217
|
-
engine.checkVersion("4.0.0
|
|
4223
|
+
engine.checkVersion("4.0.0");
|
|
4218
4224
|
await engine.pluginManager.register(e => {
|
|
4219
4225
|
e.pluginManager.addParticleUpdater("destroy", container => {
|
|
4220
4226
|
return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
|
|
@@ -4507,7 +4513,7 @@
|
|
|
4507
4513
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
4508
4514
|
|
|
4509
4515
|
async function loadEmittersPluginSimple(engine) {
|
|
4510
|
-
engine.checkVersion("4.0.0
|
|
4516
|
+
engine.checkVersion("4.0.0");
|
|
4511
4517
|
await engine.pluginManager.register(async (e) => {
|
|
4512
4518
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
4513
4519
|
await addEmittersShapesManager(e);
|
|
@@ -4595,7 +4601,7 @@
|
|
|
4595
4601
|
}
|
|
4596
4602
|
|
|
4597
4603
|
async function loadEmittersShapeSquare(engine) {
|
|
4598
|
-
engine.checkVersion("4.0.0
|
|
4604
|
+
engine.checkVersion("4.0.0");
|
|
4599
4605
|
await engine.pluginManager.register((e) => {
|
|
4600
4606
|
ensureEmittersPluginLoaded(e);
|
|
4601
4607
|
e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
|
|
@@ -4761,7 +4767,7 @@
|
|
|
4761
4767
|
}
|
|
4762
4768
|
|
|
4763
4769
|
async function loadLifeUpdater(engine) {
|
|
4764
|
-
engine.checkVersion("4.0.0
|
|
4770
|
+
engine.checkVersion("4.0.0");
|
|
4765
4771
|
await engine.pluginManager.register(e => {
|
|
4766
4772
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
4767
4773
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -4787,7 +4793,7 @@
|
|
|
4787
4793
|
}
|
|
4788
4794
|
|
|
4789
4795
|
async function loadLineShape(engine) {
|
|
4790
|
-
engine.checkVersion("4.0.0
|
|
4796
|
+
engine.checkVersion("4.0.0");
|
|
4791
4797
|
await engine.pluginManager.register(e => {
|
|
4792
4798
|
e.pluginManager.addShape(["line"], () => Promise.resolve(new LineDrawer()));
|
|
4793
4799
|
});
|
|
@@ -4919,7 +4925,7 @@
|
|
|
4919
4925
|
}
|
|
4920
4926
|
|
|
4921
4927
|
async function loadRotateUpdater(engine) {
|
|
4922
|
-
engine.checkVersion("4.0.0
|
|
4928
|
+
engine.checkVersion("4.0.0");
|
|
4923
4929
|
await engine.pluginManager.register(e => {
|
|
4924
4930
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
4925
4931
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -5300,7 +5306,7 @@
|
|
|
5300
5306
|
}
|
|
5301
5307
|
|
|
5302
5308
|
async function loadSoundsPlugin(engine) {
|
|
5303
|
-
engine.checkVersion("4.0.0
|
|
5309
|
+
engine.checkVersion("4.0.0");
|
|
5304
5310
|
await engine.pluginManager.register(e => {
|
|
5305
5311
|
e.pluginManager.addPlugin(new SoundsPlugin(e));
|
|
5306
5312
|
});
|
|
@@ -5383,7 +5389,7 @@
|
|
|
5383
5389
|
}
|
|
5384
5390
|
|
|
5385
5391
|
async function loadTrailEffect(engine) {
|
|
5386
|
-
engine.checkVersion("4.0.0
|
|
5392
|
+
engine.checkVersion("4.0.0");
|
|
5387
5393
|
await engine.pluginManager.register(e => {
|
|
5388
5394
|
e.pluginManager.addEffect("trail", container => {
|
|
5389
5395
|
return Promise.resolve(new TrailDrawer(container));
|
|
@@ -5717,6 +5723,25 @@
|
|
|
5717
5723
|
};
|
|
5718
5724
|
}
|
|
5719
5725
|
|
|
5726
|
+
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
5727
|
+
const transferredCanvas = transferredCanvases.get(canvas);
|
|
5728
|
+
if (transferredCanvas) {
|
|
5729
|
+
return transferredCanvas;
|
|
5730
|
+
}
|
|
5731
|
+
if (typeof canvas.transferControlToOffscreen !== "function") {
|
|
5732
|
+
throw new TypeError("OffscreenCanvas is required but not supported by this browser");
|
|
5733
|
+
}
|
|
5734
|
+
try {
|
|
5735
|
+
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
5736
|
+
transferredCanvases.set(canvas, offscreenCanvas);
|
|
5737
|
+
return offscreenCanvas;
|
|
5738
|
+
}
|
|
5739
|
+
catch {
|
|
5740
|
+
throw new TypeError("OffscreenCanvas transfer failed");
|
|
5741
|
+
}
|
|
5742
|
+
}, isHtmlCanvasElement = (canvas) => {
|
|
5743
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
5744
|
+
};
|
|
5720
5745
|
function setStyle(canvas, style, important = false) {
|
|
5721
5746
|
if (!style) {
|
|
5722
5747
|
return;
|
|
@@ -5747,8 +5772,9 @@
|
|
|
5747
5772
|
}
|
|
5748
5773
|
}
|
|
5749
5774
|
class CanvasManager {
|
|
5750
|
-
|
|
5775
|
+
domElement;
|
|
5751
5776
|
render;
|
|
5777
|
+
renderCanvas;
|
|
5752
5778
|
size;
|
|
5753
5779
|
zoom = defaultZoom;
|
|
5754
5780
|
_container;
|
|
@@ -5783,9 +5809,10 @@
|
|
|
5783
5809
|
destroy() {
|
|
5784
5810
|
this.stop();
|
|
5785
5811
|
if (this._generated) {
|
|
5786
|
-
const element = this.
|
|
5812
|
+
const element = this.domElement;
|
|
5787
5813
|
element?.remove();
|
|
5788
|
-
this.
|
|
5814
|
+
this.domElement = undefined;
|
|
5815
|
+
this.renderCanvas = undefined;
|
|
5789
5816
|
}
|
|
5790
5817
|
else {
|
|
5791
5818
|
this._resetOriginalStyle();
|
|
@@ -5818,16 +5845,17 @@
|
|
|
5818
5845
|
this._initStyle();
|
|
5819
5846
|
this.initBackground();
|
|
5820
5847
|
this._safeMutationObserver(obs => {
|
|
5821
|
-
|
|
5848
|
+
const element = this.domElement;
|
|
5849
|
+
if (!element || !(element instanceof Node)) {
|
|
5822
5850
|
return;
|
|
5823
5851
|
}
|
|
5824
|
-
obs.observe(
|
|
5852
|
+
obs.observe(element, { attributes: true });
|
|
5825
5853
|
});
|
|
5826
5854
|
this.initPlugins();
|
|
5827
5855
|
this.render.init();
|
|
5828
5856
|
}
|
|
5829
5857
|
initBackground() {
|
|
5830
|
-
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.
|
|
5858
|
+
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
|
|
5831
5859
|
if (!element) {
|
|
5832
5860
|
return;
|
|
5833
5861
|
}
|
|
@@ -5852,21 +5880,30 @@
|
|
|
5852
5880
|
}
|
|
5853
5881
|
}
|
|
5854
5882
|
loadCanvas(canvas) {
|
|
5855
|
-
if (this._generated && this.
|
|
5856
|
-
this.
|
|
5883
|
+
if (this._generated && this.domElement) {
|
|
5884
|
+
this.domElement.remove();
|
|
5885
|
+
}
|
|
5886
|
+
const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
5887
|
+
this.domElement = domCanvas;
|
|
5888
|
+
this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
5889
|
+
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
5890
|
+
const domElement = this.domElement;
|
|
5891
|
+
if (domElement) {
|
|
5892
|
+
domElement.ariaHidden = "true";
|
|
5893
|
+
this._originalStyle = cloneStyle(domElement.style);
|
|
5894
|
+
}
|
|
5895
|
+
const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
|
|
5896
|
+
if (domElement) {
|
|
5897
|
+
standardSize.height = domElement.offsetHeight;
|
|
5898
|
+
standardSize.width = domElement.offsetWidth;
|
|
5899
|
+
}
|
|
5900
|
+
else {
|
|
5901
|
+
standardSize.height = renderCanvas.height;
|
|
5902
|
+
standardSize.width = renderCanvas.width;
|
|
5857
5903
|
}
|
|
5858
|
-
const container = this._container;
|
|
5859
|
-
this._generated =
|
|
5860
|
-
generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
|
|
5861
|
-
this.element = canvas;
|
|
5862
|
-
this.element.ariaHidden = "true";
|
|
5863
|
-
this._originalStyle = cloneStyle(this.element.style);
|
|
5864
|
-
const standardSize = this._standardSize;
|
|
5865
|
-
standardSize.height = canvas.offsetHeight;
|
|
5866
|
-
standardSize.width = canvas.offsetWidth;
|
|
5867
5904
|
const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
|
|
5868
|
-
|
|
5869
|
-
|
|
5905
|
+
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
5906
|
+
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
5870
5907
|
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
5871
5908
|
this.render.setContextSettings({
|
|
5872
5909
|
alpha: true,
|
|
@@ -5874,42 +5911,48 @@
|
|
|
5874
5911
|
desynchronized: true,
|
|
5875
5912
|
willReadFrequently: false,
|
|
5876
5913
|
});
|
|
5877
|
-
this.render.setContext(
|
|
5914
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
5878
5915
|
this._safeMutationObserver(obs => {
|
|
5879
5916
|
obs.disconnect();
|
|
5880
5917
|
});
|
|
5881
5918
|
container.retina.init();
|
|
5882
5919
|
this.initBackground();
|
|
5883
5920
|
this._safeMutationObserver(obs => {
|
|
5884
|
-
|
|
5921
|
+
const element = this.domElement;
|
|
5922
|
+
if (!element || !(element instanceof Node)) {
|
|
5885
5923
|
return;
|
|
5886
5924
|
}
|
|
5887
|
-
obs.observe(
|
|
5925
|
+
obs.observe(element, { attributes: true });
|
|
5888
5926
|
});
|
|
5889
5927
|
}
|
|
5890
5928
|
resize() {
|
|
5891
|
-
|
|
5929
|
+
const element = this.domElement;
|
|
5930
|
+
if (!element) {
|
|
5931
|
+
return false;
|
|
5932
|
+
}
|
|
5933
|
+
const container = this._container, renderCanvas = this.renderCanvas;
|
|
5934
|
+
if (renderCanvas === undefined) {
|
|
5892
5935
|
return false;
|
|
5893
5936
|
}
|
|
5894
|
-
const
|
|
5895
|
-
width:
|
|
5896
|
-
height:
|
|
5937
|
+
const currentSize = container.canvas._standardSize, newSize = {
|
|
5938
|
+
width: element.offsetWidth,
|
|
5939
|
+
height: element.offsetHeight,
|
|
5897
5940
|
}, pxRatio = container.retina.pixelRatio, retinaSize = {
|
|
5898
5941
|
width: newSize.width * pxRatio,
|
|
5899
5942
|
height: newSize.height * pxRatio,
|
|
5900
5943
|
};
|
|
5901
5944
|
if (newSize.height === currentSize.height &&
|
|
5902
5945
|
newSize.width === currentSize.width &&
|
|
5903
|
-
retinaSize.height ===
|
|
5904
|
-
retinaSize.width ===
|
|
5946
|
+
retinaSize.height === renderCanvas.height &&
|
|
5947
|
+
retinaSize.width === renderCanvas.width) {
|
|
5905
5948
|
return false;
|
|
5906
5949
|
}
|
|
5907
5950
|
const oldSize = { ...currentSize };
|
|
5908
5951
|
currentSize.height = newSize.height;
|
|
5909
5952
|
currentSize.width = newSize.width;
|
|
5910
5953
|
const canvasSize = this.size;
|
|
5911
|
-
|
|
5912
|
-
|
|
5954
|
+
renderCanvas.width = canvasSize.width = retinaSize.width;
|
|
5955
|
+
renderCanvas.height = canvasSize.height = retinaSize.height;
|
|
5913
5956
|
if (this._container.started) {
|
|
5914
5957
|
container.particles.setResizeFactor({
|
|
5915
5958
|
width: currentSize.width / oldSize.width,
|
|
@@ -5919,7 +5962,7 @@
|
|
|
5919
5962
|
return true;
|
|
5920
5963
|
}
|
|
5921
5964
|
setPointerEvents(type) {
|
|
5922
|
-
const element = this.
|
|
5965
|
+
const element = this.domElement;
|
|
5923
5966
|
if (!element) {
|
|
5924
5967
|
return;
|
|
5925
5968
|
}
|
|
@@ -5938,7 +5981,7 @@
|
|
|
5938
5981
|
this.render.stop();
|
|
5939
5982
|
}
|
|
5940
5983
|
async windowResize() {
|
|
5941
|
-
if (!this.
|
|
5984
|
+
if (!this.domElement || !this.resize()) {
|
|
5942
5985
|
return;
|
|
5943
5986
|
}
|
|
5944
5987
|
const container = this._container, needsRefresh = container.updateActualOptions();
|
|
@@ -5954,7 +5997,7 @@
|
|
|
5954
5997
|
}
|
|
5955
5998
|
};
|
|
5956
5999
|
_initStyle = () => {
|
|
5957
|
-
const element = this.
|
|
6000
|
+
const element = this.domElement, options = this._container.actualOptions;
|
|
5958
6001
|
if (!element) {
|
|
5959
6002
|
return;
|
|
5960
6003
|
}
|
|
@@ -5976,7 +6019,7 @@
|
|
|
5976
6019
|
}
|
|
5977
6020
|
};
|
|
5978
6021
|
_repairStyle = () => {
|
|
5979
|
-
const element = this.
|
|
6022
|
+
const element = this.domElement;
|
|
5980
6023
|
if (!element) {
|
|
5981
6024
|
return;
|
|
5982
6025
|
}
|
|
@@ -5996,7 +6039,7 @@
|
|
|
5996
6039
|
});
|
|
5997
6040
|
};
|
|
5998
6041
|
_resetOriginalStyle = () => {
|
|
5999
|
-
const element = this.
|
|
6042
|
+
const element = this.domElement, originalStyle = this._originalStyle;
|
|
6000
6043
|
if (!element || !originalStyle) {
|
|
6001
6044
|
return;
|
|
6002
6045
|
}
|
|
@@ -6009,7 +6052,7 @@
|
|
|
6009
6052
|
callback(this._mutationObserver);
|
|
6010
6053
|
};
|
|
6011
6054
|
_setFullScreenStyle = () => {
|
|
6012
|
-
const element = this.
|
|
6055
|
+
const element = this.domElement;
|
|
6013
6056
|
if (!element) {
|
|
6014
6057
|
return;
|
|
6015
6058
|
}
|
|
@@ -6083,7 +6126,7 @@
|
|
|
6083
6126
|
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
6084
6127
|
return;
|
|
6085
6128
|
}
|
|
6086
|
-
const canvasEl = container.canvas.
|
|
6129
|
+
const canvasEl = container.canvas.domElement;
|
|
6087
6130
|
if (this._resizeObserver && !add) {
|
|
6088
6131
|
if (canvasEl) {
|
|
6089
6132
|
this._resizeObserver.unobserve(canvasEl);
|
|
@@ -6338,8 +6381,6 @@
|
|
|
6338
6381
|
this._initPosition(position);
|
|
6339
6382
|
this.initialVelocity = this._calculateVelocity();
|
|
6340
6383
|
this.velocity = this.initialVelocity.copy();
|
|
6341
|
-
const particles = container.particles;
|
|
6342
|
-
particles.setLastZIndex(this.position.z);
|
|
6343
6384
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
6344
6385
|
this.sides = 24;
|
|
6345
6386
|
let effectDrawer, shapeDrawer;
|
|
@@ -6489,7 +6530,7 @@
|
|
|
6489
6530
|
return color;
|
|
6490
6531
|
};
|
|
6491
6532
|
_initPosition = position => {
|
|
6492
|
-
const container = this._container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
6533
|
+
const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
6493
6534
|
if (!initialPosition) {
|
|
6494
6535
|
throw new Error("a valid position cannot be found for particle");
|
|
6495
6536
|
}
|
|
@@ -6623,10 +6664,8 @@
|
|
|
6623
6664
|
_container;
|
|
6624
6665
|
_groupLimits;
|
|
6625
6666
|
_limit;
|
|
6626
|
-
_maxZIndex;
|
|
6627
|
-
_minZIndex;
|
|
6628
|
-
_needsSort;
|
|
6629
6667
|
_nextId;
|
|
6668
|
+
_particleBuckets;
|
|
6630
6669
|
_particleResetPlugins;
|
|
6631
6670
|
_particleUpdatePlugins;
|
|
6632
6671
|
_pluginManager;
|
|
@@ -6635,19 +6674,17 @@
|
|
|
6635
6674
|
_postUpdatePlugins;
|
|
6636
6675
|
_resizeFactor;
|
|
6637
6676
|
_updatePlugins;
|
|
6638
|
-
|
|
6677
|
+
_zBuckets;
|
|
6639
6678
|
constructor(pluginManager, container) {
|
|
6640
6679
|
this._pluginManager = pluginManager;
|
|
6641
6680
|
this._container = container;
|
|
6642
6681
|
this._nextId = 0;
|
|
6643
6682
|
this._array = [];
|
|
6644
|
-
this._zArray = [];
|
|
6645
6683
|
this._pool = [];
|
|
6646
6684
|
this._limit = 0;
|
|
6647
6685
|
this._groupLimits = new Map();
|
|
6648
|
-
this.
|
|
6649
|
-
this.
|
|
6650
|
-
this._maxZIndex = 0;
|
|
6686
|
+
this._particleBuckets = new Map();
|
|
6687
|
+
this._zBuckets = this._createBuckets(this._container.zLayers);
|
|
6651
6688
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize);
|
|
6652
6689
|
this.checkParticlePositionPlugins = [];
|
|
6653
6690
|
this._particleResetPlugins = [];
|
|
@@ -6689,7 +6726,7 @@
|
|
|
6689
6726
|
return;
|
|
6690
6727
|
}
|
|
6691
6728
|
this._array.push(particle);
|
|
6692
|
-
this.
|
|
6729
|
+
this._insertParticleIntoBucket(particle);
|
|
6693
6730
|
this._nextId++;
|
|
6694
6731
|
this._container.dispatchEvent(EventType.particleAdded, {
|
|
6695
6732
|
particle,
|
|
@@ -6703,12 +6740,14 @@
|
|
|
6703
6740
|
}
|
|
6704
6741
|
clear() {
|
|
6705
6742
|
this._array = [];
|
|
6706
|
-
this.
|
|
6743
|
+
this._particleBuckets.clear();
|
|
6744
|
+
this._resetBuckets(this._container.zLayers);
|
|
6707
6745
|
}
|
|
6708
6746
|
destroy() {
|
|
6709
6747
|
this._array = [];
|
|
6710
6748
|
this._pool.length = 0;
|
|
6711
|
-
this.
|
|
6749
|
+
this._particleBuckets.clear();
|
|
6750
|
+
this._zBuckets = [];
|
|
6712
6751
|
this.checkParticlePositionPlugins = [];
|
|
6713
6752
|
this._particleResetPlugins = [];
|
|
6714
6753
|
this._particleUpdatePlugins = [];
|
|
@@ -6717,8 +6756,14 @@
|
|
|
6717
6756
|
this._updatePlugins = [];
|
|
6718
6757
|
}
|
|
6719
6758
|
drawParticles(delta) {
|
|
6720
|
-
for (
|
|
6721
|
-
|
|
6759
|
+
for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
|
|
6760
|
+
const bucket = this._zBuckets[i];
|
|
6761
|
+
if (!bucket) {
|
|
6762
|
+
continue;
|
|
6763
|
+
}
|
|
6764
|
+
for (const particle of bucket) {
|
|
6765
|
+
particle.draw(delta);
|
|
6766
|
+
}
|
|
6722
6767
|
}
|
|
6723
6768
|
}
|
|
6724
6769
|
filter(condition) {
|
|
@@ -6732,15 +6777,14 @@
|
|
|
6732
6777
|
}
|
|
6733
6778
|
async init() {
|
|
6734
6779
|
const container = this._container, options = container.actualOptions;
|
|
6735
|
-
this._minZIndex = 0;
|
|
6736
|
-
this._maxZIndex = 0;
|
|
6737
|
-
this._needsSort = false;
|
|
6738
6780
|
this.checkParticlePositionPlugins = [];
|
|
6739
6781
|
this._updatePlugins = [];
|
|
6740
6782
|
this._particleUpdatePlugins = [];
|
|
6741
6783
|
this._postUpdatePlugins = [];
|
|
6742
6784
|
this._particleResetPlugins = [];
|
|
6743
6785
|
this._postParticleUpdatePlugins = [];
|
|
6786
|
+
this._particleBuckets.clear();
|
|
6787
|
+
this._resetBuckets(container.zLayers);
|
|
6744
6788
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
|
|
6745
6789
|
for (const plugin of container.plugins) {
|
|
6746
6790
|
if (plugin.redrawInit) {
|
|
@@ -6841,79 +6885,25 @@
|
|
|
6841
6885
|
}
|
|
6842
6886
|
this._applyDensity(options.particles, pluginsCount);
|
|
6843
6887
|
}
|
|
6844
|
-
setLastZIndex(zIndex) {
|
|
6845
|
-
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
6846
|
-
}
|
|
6847
6888
|
setResizeFactor(factor) {
|
|
6848
6889
|
this._resizeFactor = factor;
|
|
6849
6890
|
}
|
|
6850
6891
|
update(delta) {
|
|
6851
|
-
const particlesToDelete = new Set();
|
|
6852
6892
|
this.grid.clear();
|
|
6853
6893
|
for (const plugin of this._updatePlugins) {
|
|
6854
6894
|
plugin.update?.(delta);
|
|
6855
6895
|
}
|
|
6856
|
-
const
|
|
6857
|
-
for (const particle of this._array) {
|
|
6858
|
-
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6859
|
-
particle.position.x *= resizeFactor.width;
|
|
6860
|
-
particle.position.y *= resizeFactor.height;
|
|
6861
|
-
particle.initialPosition.x *= resizeFactor.width;
|
|
6862
|
-
particle.initialPosition.y *= resizeFactor.height;
|
|
6863
|
-
}
|
|
6864
|
-
particle.ignoresResizeRatio = false;
|
|
6865
|
-
for (const plugin of this._particleResetPlugins) {
|
|
6866
|
-
plugin.particleReset?.(particle);
|
|
6867
|
-
}
|
|
6868
|
-
for (const plugin of this._particleUpdatePlugins) {
|
|
6869
|
-
if (particle.destroyed) {
|
|
6870
|
-
break;
|
|
6871
|
-
}
|
|
6872
|
-
plugin.particleUpdate?.(particle, delta);
|
|
6873
|
-
}
|
|
6874
|
-
if (particle.destroyed) {
|
|
6875
|
-
particlesToDelete.add(particle);
|
|
6876
|
-
continue;
|
|
6877
|
-
}
|
|
6878
|
-
this.grid.insert(particle);
|
|
6879
|
-
}
|
|
6896
|
+
const particlesToDelete = this._updateParticlesPhase1(delta);
|
|
6880
6897
|
for (const plugin of this._postUpdatePlugins) {
|
|
6881
6898
|
plugin.postUpdate?.(delta);
|
|
6882
6899
|
}
|
|
6883
|
-
|
|
6884
|
-
if (particle.destroyed) {
|
|
6885
|
-
particlesToDelete.add(particle);
|
|
6886
|
-
continue;
|
|
6887
|
-
}
|
|
6888
|
-
for (const updater of this._container.particleUpdaters) {
|
|
6889
|
-
updater.update(particle, delta);
|
|
6890
|
-
}
|
|
6891
|
-
if (!particle.destroyed && !particle.spawning) {
|
|
6892
|
-
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6893
|
-
plugin.postParticleUpdate?.(particle, delta);
|
|
6894
|
-
}
|
|
6895
|
-
}
|
|
6896
|
-
else if (particle.destroyed) {
|
|
6897
|
-
particlesToDelete.add(particle);
|
|
6898
|
-
}
|
|
6899
|
-
}
|
|
6900
|
+
this._updateParticlesPhase2(delta, particlesToDelete);
|
|
6900
6901
|
if (particlesToDelete.size) {
|
|
6901
6902
|
for (const particle of particlesToDelete) {
|
|
6902
6903
|
this.remove(particle);
|
|
6903
6904
|
}
|
|
6904
6905
|
}
|
|
6905
6906
|
delete this._resizeFactor;
|
|
6906
|
-
if (this._needsSort) {
|
|
6907
|
-
const zArray = this._zArray;
|
|
6908
|
-
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
6909
|
-
const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
|
|
6910
|
-
if (!firstItem || !lastItem) {
|
|
6911
|
-
return;
|
|
6912
|
-
}
|
|
6913
|
-
this._maxZIndex = firstItem.position.z;
|
|
6914
|
-
this._minZIndex = lastItem.position.z;
|
|
6915
|
-
this._needsSort = false;
|
|
6916
|
-
}
|
|
6917
6907
|
}
|
|
6918
6908
|
_addToPool = (...particles) => {
|
|
6919
6909
|
this._pool.push(...particles);
|
|
@@ -6943,13 +6933,52 @@
|
|
|
6943
6933
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
6944
6934
|
}
|
|
6945
6935
|
};
|
|
6936
|
+
_createBuckets = (zLayers) => {
|
|
6937
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
6938
|
+
return Array.from({ length: bucketCount }, () => []);
|
|
6939
|
+
};
|
|
6940
|
+
_getBucketIndex = (zIndex) => {
|
|
6941
|
+
const maxBucketIndex = this._zBuckets.length - one;
|
|
6942
|
+
if (maxBucketIndex <= minIndex) {
|
|
6943
|
+
return minIndex;
|
|
6944
|
+
}
|
|
6945
|
+
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
6946
|
+
};
|
|
6947
|
+
_getParticleInsertIndex = (bucket, particleId) => {
|
|
6948
|
+
let start = minIndex, end = bucket.length;
|
|
6949
|
+
while (start < end) {
|
|
6950
|
+
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
6951
|
+
if (!middleParticle) {
|
|
6952
|
+
end = middle;
|
|
6953
|
+
continue;
|
|
6954
|
+
}
|
|
6955
|
+
if (middleParticle.id < particleId) {
|
|
6956
|
+
start = middle + one;
|
|
6957
|
+
}
|
|
6958
|
+
else {
|
|
6959
|
+
end = middle;
|
|
6960
|
+
}
|
|
6961
|
+
}
|
|
6962
|
+
return start;
|
|
6963
|
+
};
|
|
6946
6964
|
_initDensityFactor = densityOptions => {
|
|
6947
6965
|
const container = this._container;
|
|
6948
|
-
if (!
|
|
6966
|
+
if (!densityOptions.enable) {
|
|
6967
|
+
return defaultDensityFactor;
|
|
6968
|
+
}
|
|
6969
|
+
const canvasSize = container.canvas.size, pxRatio = container.retina.pixelRatio;
|
|
6970
|
+
if (!canvasSize.width || !canvasSize.height) {
|
|
6949
6971
|
return defaultDensityFactor;
|
|
6950
6972
|
}
|
|
6951
|
-
|
|
6952
|
-
|
|
6973
|
+
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
6974
|
+
};
|
|
6975
|
+
_insertParticleIntoBucket = (particle) => {
|
|
6976
|
+
const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
6977
|
+
if (!bucket) {
|
|
6978
|
+
return;
|
|
6979
|
+
}
|
|
6980
|
+
bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
|
|
6981
|
+
this._particleBuckets.set(particle.id, bucketIndex);
|
|
6953
6982
|
};
|
|
6954
6983
|
_removeParticle = (index, group, override) => {
|
|
6955
6984
|
const particle = this._array[index];
|
|
@@ -6959,9 +6988,8 @@
|
|
|
6959
6988
|
if (particle.group !== group) {
|
|
6960
6989
|
return false;
|
|
6961
6990
|
}
|
|
6962
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
6963
6991
|
this._array.splice(index, deleteCount);
|
|
6964
|
-
this.
|
|
6992
|
+
this._removeParticleFromBucket(particle);
|
|
6965
6993
|
particle.destroy(override);
|
|
6966
6994
|
this._container.dispatchEvent(EventType.particleRemoved, {
|
|
6967
6995
|
particle,
|
|
@@ -6969,6 +6997,98 @@
|
|
|
6969
6997
|
this._addToPool(particle);
|
|
6970
6998
|
return true;
|
|
6971
6999
|
};
|
|
7000
|
+
_removeParticleFromBucket = (particle) => {
|
|
7001
|
+
const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
7002
|
+
if (!bucket) {
|
|
7003
|
+
this._particleBuckets.delete(particle.id);
|
|
7004
|
+
return;
|
|
7005
|
+
}
|
|
7006
|
+
const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
|
|
7007
|
+
if (bucket[particleIndex]?.id !== particle.id) {
|
|
7008
|
+
this._particleBuckets.delete(particle.id);
|
|
7009
|
+
return;
|
|
7010
|
+
}
|
|
7011
|
+
bucket.splice(particleIndex, deleteCount);
|
|
7012
|
+
this._particleBuckets.delete(particle.id);
|
|
7013
|
+
};
|
|
7014
|
+
_resetBuckets = (zLayers) => {
|
|
7015
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
7016
|
+
if (this._zBuckets.length !== bucketCount) {
|
|
7017
|
+
this._zBuckets = this._createBuckets(bucketCount);
|
|
7018
|
+
return;
|
|
7019
|
+
}
|
|
7020
|
+
for (const bucket of this._zBuckets) {
|
|
7021
|
+
bucket.length = minIndex;
|
|
7022
|
+
}
|
|
7023
|
+
};
|
|
7024
|
+
_updateParticleBucket = (particle) => {
|
|
7025
|
+
const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
|
|
7026
|
+
if (currentBucketIndex === undefined) {
|
|
7027
|
+
this._insertParticleIntoBucket(particle);
|
|
7028
|
+
return;
|
|
7029
|
+
}
|
|
7030
|
+
if (currentBucketIndex === newBucketIndex) {
|
|
7031
|
+
return;
|
|
7032
|
+
}
|
|
7033
|
+
const currentBucket = this._zBuckets[currentBucketIndex];
|
|
7034
|
+
if (currentBucket) {
|
|
7035
|
+
const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
|
|
7036
|
+
if (currentBucket[particleIndex]?.id === particle.id) {
|
|
7037
|
+
currentBucket.splice(particleIndex, deleteCount);
|
|
7038
|
+
}
|
|
7039
|
+
}
|
|
7040
|
+
const newBucket = this._zBuckets[newBucketIndex];
|
|
7041
|
+
if (!newBucket) {
|
|
7042
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
7043
|
+
return;
|
|
7044
|
+
}
|
|
7045
|
+
newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
|
|
7046
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
7047
|
+
};
|
|
7048
|
+
_updateParticlesPhase1 = (delta) => {
|
|
7049
|
+
const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
|
|
7050
|
+
for (const particle of this._array) {
|
|
7051
|
+
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
7052
|
+
particle.position.x *= resizeFactor.width;
|
|
7053
|
+
particle.position.y *= resizeFactor.height;
|
|
7054
|
+
particle.initialPosition.x *= resizeFactor.width;
|
|
7055
|
+
particle.initialPosition.y *= resizeFactor.height;
|
|
7056
|
+
}
|
|
7057
|
+
particle.ignoresResizeRatio = false;
|
|
7058
|
+
for (const plugin of this._particleResetPlugins) {
|
|
7059
|
+
plugin.particleReset?.(particle);
|
|
7060
|
+
}
|
|
7061
|
+
for (const plugin of this._particleUpdatePlugins) {
|
|
7062
|
+
if (particle.destroyed) {
|
|
7063
|
+
break;
|
|
7064
|
+
}
|
|
7065
|
+
plugin.particleUpdate?.(particle, delta);
|
|
7066
|
+
}
|
|
7067
|
+
if (particle.destroyed) {
|
|
7068
|
+
particlesToDelete.add(particle);
|
|
7069
|
+
continue;
|
|
7070
|
+
}
|
|
7071
|
+
this.grid.insert(particle);
|
|
7072
|
+
}
|
|
7073
|
+
return particlesToDelete;
|
|
7074
|
+
};
|
|
7075
|
+
_updateParticlesPhase2 = (delta, particlesToDelete) => {
|
|
7076
|
+
for (const particle of this._array) {
|
|
7077
|
+
if (particle.destroyed) {
|
|
7078
|
+
particlesToDelete.add(particle);
|
|
7079
|
+
continue;
|
|
7080
|
+
}
|
|
7081
|
+
for (const updater of this._container.particleUpdaters) {
|
|
7082
|
+
updater.update(particle, delta);
|
|
7083
|
+
}
|
|
7084
|
+
if (!particle.spawning) {
|
|
7085
|
+
for (const plugin of this._postParticleUpdatePlugins) {
|
|
7086
|
+
plugin.postParticleUpdate?.(particle, delta);
|
|
7087
|
+
}
|
|
7088
|
+
}
|
|
7089
|
+
this._updateParticleBucket(particle);
|
|
7090
|
+
}
|
|
7091
|
+
};
|
|
6972
7092
|
}
|
|
6973
7093
|
|
|
6974
7094
|
class Retina {
|
|
@@ -6984,9 +7104,8 @@
|
|
|
6984
7104
|
const container = this.container, options = container.actualOptions;
|
|
6985
7105
|
this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
|
|
6986
7106
|
this.reduceFactor = defaultReduceFactor;
|
|
6987
|
-
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
6988
|
-
if (
|
|
6989
|
-
const element = canvas.element;
|
|
7107
|
+
const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
|
|
7108
|
+
if (element) {
|
|
6990
7109
|
canvas.size.width = element.offsetWidth * ratio;
|
|
6991
7110
|
canvas.size.height = element.offsetHeight * ratio;
|
|
6992
7111
|
}
|
|
@@ -7746,7 +7865,7 @@
|
|
|
7746
7865
|
setIconStyle(img, pos.top + margin, pos.right -
|
|
7747
7866
|
(margin * (rightOffsets.length + rightOffset) + width + rightOffsets.reduce((a, b) => a + b, defaultAccumulator)), display, options.fullScreen.zIndex + zIndexOffset, width, margin, style);
|
|
7748
7867
|
img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : "");
|
|
7749
|
-
const parent = container.canvas.
|
|
7868
|
+
const parent = container.canvas.domElement?.parentNode ?? safeDocument().body;
|
|
7750
7869
|
parent.append(img);
|
|
7751
7870
|
img.addEventListener("click", () => {
|
|
7752
7871
|
void clickCb();
|
|
@@ -7834,11 +7953,11 @@
|
|
|
7834
7953
|
}
|
|
7835
7954
|
async start() {
|
|
7836
7955
|
const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
|
|
7837
|
-
if (!soundsOptions?.enable || !container.canvas.
|
|
7956
|
+
if (!soundsOptions?.enable || !container.canvas.domElement) {
|
|
7838
7957
|
return;
|
|
7839
7958
|
}
|
|
7840
7959
|
container.muted = true;
|
|
7841
|
-
const canvas = container.canvas.
|
|
7960
|
+
const canvas = container.canvas.domElement, pos = {
|
|
7842
7961
|
top: canvas.offsetTop,
|
|
7843
7962
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
7844
7963
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10, toggleMute = async () => {
|
|
@@ -7949,7 +8068,7 @@
|
|
|
7949
8068
|
}
|
|
7950
8069
|
_initEvents = () => {
|
|
7951
8070
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
7952
|
-
if (!soundsOptions?.enable || !container.canvas.
|
|
8071
|
+
if (!soundsOptions?.enable || !container.canvas.domElement) {
|
|
7953
8072
|
return;
|
|
7954
8073
|
}
|
|
7955
8074
|
for (const event of soundsOptions.events) {
|