@tsparticles/preset-confetti-explosions 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, 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, 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) {
|
|
@@ -981,7 +981,7 @@
|
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
else {
|
|
984
|
-
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases
|
|
984
|
+
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
|
|
985
985
|
if (foundCanvas) {
|
|
986
986
|
canvasEl = foundCanvas;
|
|
987
987
|
canvasEl.dataset[generatedAttribute] = generatedFalse;
|
|
@@ -1018,7 +1018,7 @@
|
|
|
1018
1018
|
return this._domArray;
|
|
1019
1019
|
}
|
|
1020
1020
|
get version() {
|
|
1021
|
-
return "4.0.0
|
|
1021
|
+
return "4.0.0";
|
|
1022
1022
|
}
|
|
1023
1023
|
addEventListener(type, listener) {
|
|
1024
1024
|
this._eventDispatcher.addEventListener(type, listener);
|
|
@@ -1049,7 +1049,11 @@
|
|
|
1049
1049
|
}
|
|
1050
1050
|
async load(params) {
|
|
1051
1051
|
await this.init();
|
|
1052
|
-
|
|
1052
|
+
let domSourceElement;
|
|
1053
|
+
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
1054
|
+
domSourceElement = params.element;
|
|
1055
|
+
}
|
|
1056
|
+
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({
|
|
1053
1057
|
dispatchCallback: (eventType, args) => {
|
|
1054
1058
|
this.dispatchEvent(eventType, args);
|
|
1055
1059
|
},
|
|
@@ -1076,8 +1080,10 @@
|
|
|
1076
1080
|
else {
|
|
1077
1081
|
items.push(newItem);
|
|
1078
1082
|
}
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1083
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
1084
|
+
? params.element
|
|
1085
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
1086
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
1081
1087
|
await newItem.start();
|
|
1082
1088
|
return newItem;
|
|
1083
1089
|
}
|
|
@@ -2870,7 +2876,7 @@
|
|
|
2870
2876
|
}
|
|
2871
2877
|
|
|
2872
2878
|
async function loadCircleShape(engine) {
|
|
2873
|
-
engine.checkVersion("4.0.0
|
|
2879
|
+
engine.checkVersion("4.0.0");
|
|
2874
2880
|
await engine.pluginManager.register(e => {
|
|
2875
2881
|
e.pluginManager.addShape(["circle"], () => {
|
|
2876
2882
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2918,7 +2924,7 @@
|
|
|
2918
2924
|
}
|
|
2919
2925
|
|
|
2920
2926
|
async function loadHexColorPlugin(engine) {
|
|
2921
|
-
engine.checkVersion("4.0.0
|
|
2927
|
+
engine.checkVersion("4.0.0");
|
|
2922
2928
|
await engine.pluginManager.register(e => {
|
|
2923
2929
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2924
2930
|
});
|
|
@@ -2971,7 +2977,7 @@
|
|
|
2971
2977
|
}
|
|
2972
2978
|
|
|
2973
2979
|
async function loadHslColorPlugin(engine) {
|
|
2974
|
-
engine.checkVersion("4.0.0
|
|
2980
|
+
engine.checkVersion("4.0.0");
|
|
2975
2981
|
await engine.pluginManager.register(e => {
|
|
2976
2982
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2977
2983
|
});
|
|
@@ -2995,7 +3001,7 @@
|
|
|
2995
3001
|
}
|
|
2996
3002
|
|
|
2997
3003
|
async function loadMovePlugin(engine) {
|
|
2998
|
-
engine.checkVersion("4.0.0
|
|
3004
|
+
engine.checkVersion("4.0.0");
|
|
2999
3005
|
await engine.pluginManager.register(e => {
|
|
3000
3006
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
3001
3007
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -3056,7 +3062,7 @@
|
|
|
3056
3062
|
}
|
|
3057
3063
|
|
|
3058
3064
|
async function loadOpacityUpdater(engine) {
|
|
3059
|
-
engine.checkVersion("4.0.0
|
|
3065
|
+
engine.checkVersion("4.0.0");
|
|
3060
3066
|
await engine.pluginManager.register(e => {
|
|
3061
3067
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3062
3068
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3408,7 +3414,7 @@
|
|
|
3408
3414
|
}
|
|
3409
3415
|
|
|
3410
3416
|
async function loadOutModesUpdater(engine) {
|
|
3411
|
-
engine.checkVersion("4.0.0
|
|
3417
|
+
engine.checkVersion("4.0.0");
|
|
3412
3418
|
await engine.pluginManager.register(e => {
|
|
3413
3419
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3414
3420
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3479,7 +3485,7 @@
|
|
|
3479
3485
|
}
|
|
3480
3486
|
|
|
3481
3487
|
async function loadPaintUpdater(engine) {
|
|
3482
|
-
engine.checkVersion("4.0.0
|
|
3488
|
+
engine.checkVersion("4.0.0");
|
|
3483
3489
|
await engine.pluginManager.register(e => {
|
|
3484
3490
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3485
3491
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3534,7 +3540,7 @@
|
|
|
3534
3540
|
}
|
|
3535
3541
|
|
|
3536
3542
|
async function loadRgbColorPlugin(engine) {
|
|
3537
|
-
engine.checkVersion("4.0.0
|
|
3543
|
+
engine.checkVersion("4.0.0");
|
|
3538
3544
|
await engine.pluginManager.register(e => {
|
|
3539
3545
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3540
3546
|
});
|
|
@@ -3577,7 +3583,7 @@
|
|
|
3577
3583
|
}
|
|
3578
3584
|
|
|
3579
3585
|
async function loadSizeUpdater(engine) {
|
|
3580
|
-
engine.checkVersion("4.0.0
|
|
3586
|
+
engine.checkVersion("4.0.0");
|
|
3581
3587
|
await engine.pluginManager.register(e => {
|
|
3582
3588
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3583
3589
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3586,7 +3592,7 @@
|
|
|
3586
3592
|
}
|
|
3587
3593
|
|
|
3588
3594
|
async function loadBasic(engine) {
|
|
3589
|
-
engine.checkVersion("4.0.0
|
|
3595
|
+
engine.checkVersion("4.0.0");
|
|
3590
3596
|
await engine.pluginManager.register(async (e) => {
|
|
3591
3597
|
await Promise.all([
|
|
3592
3598
|
loadHexColorPlugin(e),
|
|
@@ -3900,7 +3906,7 @@
|
|
|
3900
3906
|
})(EmitterClickMode || (EmitterClickMode = {}));
|
|
3901
3907
|
|
|
3902
3908
|
async function loadEmittersPluginSimple(engine) {
|
|
3903
|
-
engine.checkVersion("4.0.0
|
|
3909
|
+
engine.checkVersion("4.0.0");
|
|
3904
3910
|
await engine.pluginManager.register(async (e) => {
|
|
3905
3911
|
const instancesManager = await getEmittersInstancesManager(e);
|
|
3906
3912
|
await addEmittersShapesManager(e);
|
|
@@ -3968,7 +3974,7 @@
|
|
|
3968
3974
|
}
|
|
3969
3975
|
|
|
3970
3976
|
async function loadMotionPlugin(engine) {
|
|
3971
|
-
engine.checkVersion("4.0.0
|
|
3977
|
+
engine.checkVersion("4.0.0");
|
|
3972
3978
|
await engine.pluginManager.register(e => {
|
|
3973
3979
|
e.pluginManager.addPlugin(new MotionPlugin());
|
|
3974
3980
|
});
|
|
@@ -4125,7 +4131,7 @@
|
|
|
4125
4131
|
}
|
|
4126
4132
|
|
|
4127
4133
|
async function loadRollUpdater(engine) {
|
|
4128
|
-
engine.checkVersion("4.0.0
|
|
4134
|
+
engine.checkVersion("4.0.0");
|
|
4129
4135
|
await engine.pluginManager.register(e => {
|
|
4130
4136
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
4131
4137
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -4259,7 +4265,7 @@
|
|
|
4259
4265
|
}
|
|
4260
4266
|
|
|
4261
4267
|
async function loadRotateUpdater(engine) {
|
|
4262
|
-
engine.checkVersion("4.0.0
|
|
4268
|
+
engine.checkVersion("4.0.0");
|
|
4263
4269
|
await engine.pluginManager.register(e => {
|
|
4264
4270
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
4265
4271
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -4283,7 +4289,7 @@
|
|
|
4283
4289
|
}
|
|
4284
4290
|
|
|
4285
4291
|
async function loadSquareShape(engine) {
|
|
4286
|
-
engine.checkVersion("4.0.0
|
|
4292
|
+
engine.checkVersion("4.0.0");
|
|
4287
4293
|
await engine.pluginManager.register(e => {
|
|
4288
4294
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
4289
4295
|
});
|
|
@@ -4420,7 +4426,7 @@
|
|
|
4420
4426
|
}
|
|
4421
4427
|
|
|
4422
4428
|
async function loadTiltUpdater(engine) {
|
|
4423
|
-
engine.checkVersion("4.0.0
|
|
4429
|
+
engine.checkVersion("4.0.0");
|
|
4424
4430
|
await engine.pluginManager.register(e => {
|
|
4425
4431
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
4426
4432
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -4542,7 +4548,7 @@
|
|
|
4542
4548
|
}
|
|
4543
4549
|
|
|
4544
4550
|
async function loadWobbleUpdater(engine) {
|
|
4545
|
-
engine.checkVersion("4.0.0
|
|
4551
|
+
engine.checkVersion("4.0.0");
|
|
4546
4552
|
await engine.pluginManager.register(e => {
|
|
4547
4553
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
4548
4554
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -5005,6 +5011,25 @@
|
|
|
5005
5011
|
};
|
|
5006
5012
|
}
|
|
5007
5013
|
|
|
5014
|
+
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
5015
|
+
const transferredCanvas = transferredCanvases.get(canvas);
|
|
5016
|
+
if (transferredCanvas) {
|
|
5017
|
+
return transferredCanvas;
|
|
5018
|
+
}
|
|
5019
|
+
if (typeof canvas.transferControlToOffscreen !== "function") {
|
|
5020
|
+
throw new TypeError("OffscreenCanvas is required but not supported by this browser");
|
|
5021
|
+
}
|
|
5022
|
+
try {
|
|
5023
|
+
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
5024
|
+
transferredCanvases.set(canvas, offscreenCanvas);
|
|
5025
|
+
return offscreenCanvas;
|
|
5026
|
+
}
|
|
5027
|
+
catch {
|
|
5028
|
+
throw new TypeError("OffscreenCanvas transfer failed");
|
|
5029
|
+
}
|
|
5030
|
+
}, isHtmlCanvasElement = (canvas) => {
|
|
5031
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
5032
|
+
};
|
|
5008
5033
|
function setStyle(canvas, style, important = false) {
|
|
5009
5034
|
if (!style) {
|
|
5010
5035
|
return;
|
|
@@ -5035,8 +5060,9 @@
|
|
|
5035
5060
|
}
|
|
5036
5061
|
}
|
|
5037
5062
|
class CanvasManager {
|
|
5038
|
-
|
|
5063
|
+
domElement;
|
|
5039
5064
|
render;
|
|
5065
|
+
renderCanvas;
|
|
5040
5066
|
size;
|
|
5041
5067
|
zoom = defaultZoom;
|
|
5042
5068
|
_container;
|
|
@@ -5071,9 +5097,10 @@
|
|
|
5071
5097
|
destroy() {
|
|
5072
5098
|
this.stop();
|
|
5073
5099
|
if (this._generated) {
|
|
5074
|
-
const element = this.
|
|
5100
|
+
const element = this.domElement;
|
|
5075
5101
|
element?.remove();
|
|
5076
|
-
this.
|
|
5102
|
+
this.domElement = undefined;
|
|
5103
|
+
this.renderCanvas = undefined;
|
|
5077
5104
|
}
|
|
5078
5105
|
else {
|
|
5079
5106
|
this._resetOriginalStyle();
|
|
@@ -5106,16 +5133,17 @@
|
|
|
5106
5133
|
this._initStyle();
|
|
5107
5134
|
this.initBackground();
|
|
5108
5135
|
this._safeMutationObserver(obs => {
|
|
5109
|
-
|
|
5136
|
+
const element = this.domElement;
|
|
5137
|
+
if (!element || !(element instanceof Node)) {
|
|
5110
5138
|
return;
|
|
5111
5139
|
}
|
|
5112
|
-
obs.observe(
|
|
5140
|
+
obs.observe(element, { attributes: true });
|
|
5113
5141
|
});
|
|
5114
5142
|
this.initPlugins();
|
|
5115
5143
|
this.render.init();
|
|
5116
5144
|
}
|
|
5117
5145
|
initBackground() {
|
|
5118
|
-
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.
|
|
5146
|
+
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
|
|
5119
5147
|
if (!element) {
|
|
5120
5148
|
return;
|
|
5121
5149
|
}
|
|
@@ -5140,21 +5168,30 @@
|
|
|
5140
5168
|
}
|
|
5141
5169
|
}
|
|
5142
5170
|
loadCanvas(canvas) {
|
|
5143
|
-
if (this._generated && this.
|
|
5144
|
-
this.
|
|
5171
|
+
if (this._generated && this.domElement) {
|
|
5172
|
+
this.domElement.remove();
|
|
5173
|
+
}
|
|
5174
|
+
const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
5175
|
+
this.domElement = domCanvas;
|
|
5176
|
+
this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
5177
|
+
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
5178
|
+
const domElement = this.domElement;
|
|
5179
|
+
if (domElement) {
|
|
5180
|
+
domElement.ariaHidden = "true";
|
|
5181
|
+
this._originalStyle = cloneStyle(domElement.style);
|
|
5182
|
+
}
|
|
5183
|
+
const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
|
|
5184
|
+
if (domElement) {
|
|
5185
|
+
standardSize.height = domElement.offsetHeight;
|
|
5186
|
+
standardSize.width = domElement.offsetWidth;
|
|
5187
|
+
}
|
|
5188
|
+
else {
|
|
5189
|
+
standardSize.height = renderCanvas.height;
|
|
5190
|
+
standardSize.width = renderCanvas.width;
|
|
5145
5191
|
}
|
|
5146
|
-
const container = this._container;
|
|
5147
|
-
this._generated =
|
|
5148
|
-
generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
|
|
5149
|
-
this.element = canvas;
|
|
5150
|
-
this.element.ariaHidden = "true";
|
|
5151
|
-
this._originalStyle = cloneStyle(this.element.style);
|
|
5152
|
-
const standardSize = this._standardSize;
|
|
5153
|
-
standardSize.height = canvas.offsetHeight;
|
|
5154
|
-
standardSize.width = canvas.offsetWidth;
|
|
5155
5192
|
const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
|
|
5156
|
-
|
|
5157
|
-
|
|
5193
|
+
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
5194
|
+
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
5158
5195
|
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
5159
5196
|
this.render.setContextSettings({
|
|
5160
5197
|
alpha: true,
|
|
@@ -5162,42 +5199,48 @@
|
|
|
5162
5199
|
desynchronized: true,
|
|
5163
5200
|
willReadFrequently: false,
|
|
5164
5201
|
});
|
|
5165
|
-
this.render.setContext(
|
|
5202
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
5166
5203
|
this._safeMutationObserver(obs => {
|
|
5167
5204
|
obs.disconnect();
|
|
5168
5205
|
});
|
|
5169
5206
|
container.retina.init();
|
|
5170
5207
|
this.initBackground();
|
|
5171
5208
|
this._safeMutationObserver(obs => {
|
|
5172
|
-
|
|
5209
|
+
const element = this.domElement;
|
|
5210
|
+
if (!element || !(element instanceof Node)) {
|
|
5173
5211
|
return;
|
|
5174
5212
|
}
|
|
5175
|
-
obs.observe(
|
|
5213
|
+
obs.observe(element, { attributes: true });
|
|
5176
5214
|
});
|
|
5177
5215
|
}
|
|
5178
5216
|
resize() {
|
|
5179
|
-
|
|
5217
|
+
const element = this.domElement;
|
|
5218
|
+
if (!element) {
|
|
5219
|
+
return false;
|
|
5220
|
+
}
|
|
5221
|
+
const container = this._container, renderCanvas = this.renderCanvas;
|
|
5222
|
+
if (renderCanvas === undefined) {
|
|
5180
5223
|
return false;
|
|
5181
5224
|
}
|
|
5182
|
-
const
|
|
5183
|
-
width:
|
|
5184
|
-
height:
|
|
5225
|
+
const currentSize = container.canvas._standardSize, newSize = {
|
|
5226
|
+
width: element.offsetWidth,
|
|
5227
|
+
height: element.offsetHeight,
|
|
5185
5228
|
}, pxRatio = container.retina.pixelRatio, retinaSize = {
|
|
5186
5229
|
width: newSize.width * pxRatio,
|
|
5187
5230
|
height: newSize.height * pxRatio,
|
|
5188
5231
|
};
|
|
5189
5232
|
if (newSize.height === currentSize.height &&
|
|
5190
5233
|
newSize.width === currentSize.width &&
|
|
5191
|
-
retinaSize.height ===
|
|
5192
|
-
retinaSize.width ===
|
|
5234
|
+
retinaSize.height === renderCanvas.height &&
|
|
5235
|
+
retinaSize.width === renderCanvas.width) {
|
|
5193
5236
|
return false;
|
|
5194
5237
|
}
|
|
5195
5238
|
const oldSize = { ...currentSize };
|
|
5196
5239
|
currentSize.height = newSize.height;
|
|
5197
5240
|
currentSize.width = newSize.width;
|
|
5198
5241
|
const canvasSize = this.size;
|
|
5199
|
-
|
|
5200
|
-
|
|
5242
|
+
renderCanvas.width = canvasSize.width = retinaSize.width;
|
|
5243
|
+
renderCanvas.height = canvasSize.height = retinaSize.height;
|
|
5201
5244
|
if (this._container.started) {
|
|
5202
5245
|
container.particles.setResizeFactor({
|
|
5203
5246
|
width: currentSize.width / oldSize.width,
|
|
@@ -5207,7 +5250,7 @@
|
|
|
5207
5250
|
return true;
|
|
5208
5251
|
}
|
|
5209
5252
|
setPointerEvents(type) {
|
|
5210
|
-
const element = this.
|
|
5253
|
+
const element = this.domElement;
|
|
5211
5254
|
if (!element) {
|
|
5212
5255
|
return;
|
|
5213
5256
|
}
|
|
@@ -5226,7 +5269,7 @@
|
|
|
5226
5269
|
this.render.stop();
|
|
5227
5270
|
}
|
|
5228
5271
|
async windowResize() {
|
|
5229
|
-
if (!this.
|
|
5272
|
+
if (!this.domElement || !this.resize()) {
|
|
5230
5273
|
return;
|
|
5231
5274
|
}
|
|
5232
5275
|
const container = this._container, needsRefresh = container.updateActualOptions();
|
|
@@ -5242,7 +5285,7 @@
|
|
|
5242
5285
|
}
|
|
5243
5286
|
};
|
|
5244
5287
|
_initStyle = () => {
|
|
5245
|
-
const element = this.
|
|
5288
|
+
const element = this.domElement, options = this._container.actualOptions;
|
|
5246
5289
|
if (!element) {
|
|
5247
5290
|
return;
|
|
5248
5291
|
}
|
|
@@ -5264,7 +5307,7 @@
|
|
|
5264
5307
|
}
|
|
5265
5308
|
};
|
|
5266
5309
|
_repairStyle = () => {
|
|
5267
|
-
const element = this.
|
|
5310
|
+
const element = this.domElement;
|
|
5268
5311
|
if (!element) {
|
|
5269
5312
|
return;
|
|
5270
5313
|
}
|
|
@@ -5284,7 +5327,7 @@
|
|
|
5284
5327
|
});
|
|
5285
5328
|
};
|
|
5286
5329
|
_resetOriginalStyle = () => {
|
|
5287
|
-
const element = this.
|
|
5330
|
+
const element = this.domElement, originalStyle = this._originalStyle;
|
|
5288
5331
|
if (!element || !originalStyle) {
|
|
5289
5332
|
return;
|
|
5290
5333
|
}
|
|
@@ -5297,7 +5340,7 @@
|
|
|
5297
5340
|
callback(this._mutationObserver);
|
|
5298
5341
|
};
|
|
5299
5342
|
_setFullScreenStyle = () => {
|
|
5300
|
-
const element = this.
|
|
5343
|
+
const element = this.domElement;
|
|
5301
5344
|
if (!element) {
|
|
5302
5345
|
return;
|
|
5303
5346
|
}
|
|
@@ -5371,7 +5414,7 @@
|
|
|
5371
5414
|
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
5372
5415
|
return;
|
|
5373
5416
|
}
|
|
5374
|
-
const canvasEl = container.canvas.
|
|
5417
|
+
const canvasEl = container.canvas.domElement;
|
|
5375
5418
|
if (this._resizeObserver && !add) {
|
|
5376
5419
|
if (canvasEl) {
|
|
5377
5420
|
this._resizeObserver.unobserve(canvasEl);
|
|
@@ -5626,8 +5669,6 @@
|
|
|
5626
5669
|
this._initPosition(position);
|
|
5627
5670
|
this.initialVelocity = this._calculateVelocity();
|
|
5628
5671
|
this.velocity = this.initialVelocity.copy();
|
|
5629
|
-
const particles = container.particles;
|
|
5630
|
-
particles.setLastZIndex(this.position.z);
|
|
5631
5672
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
5632
5673
|
this.sides = 24;
|
|
5633
5674
|
let effectDrawer, shapeDrawer;
|
|
@@ -5777,7 +5818,7 @@
|
|
|
5777
5818
|
return color;
|
|
5778
5819
|
};
|
|
5779
5820
|
_initPosition = position => {
|
|
5780
|
-
const container = this._container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5821
|
+
const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5781
5822
|
if (!initialPosition) {
|
|
5782
5823
|
throw new Error("a valid position cannot be found for particle");
|
|
5783
5824
|
}
|
|
@@ -5911,10 +5952,8 @@
|
|
|
5911
5952
|
_container;
|
|
5912
5953
|
_groupLimits;
|
|
5913
5954
|
_limit;
|
|
5914
|
-
_maxZIndex;
|
|
5915
|
-
_minZIndex;
|
|
5916
|
-
_needsSort;
|
|
5917
5955
|
_nextId;
|
|
5956
|
+
_particleBuckets;
|
|
5918
5957
|
_particleResetPlugins;
|
|
5919
5958
|
_particleUpdatePlugins;
|
|
5920
5959
|
_pluginManager;
|
|
@@ -5923,19 +5962,17 @@
|
|
|
5923
5962
|
_postUpdatePlugins;
|
|
5924
5963
|
_resizeFactor;
|
|
5925
5964
|
_updatePlugins;
|
|
5926
|
-
|
|
5965
|
+
_zBuckets;
|
|
5927
5966
|
constructor(pluginManager, container) {
|
|
5928
5967
|
this._pluginManager = pluginManager;
|
|
5929
5968
|
this._container = container;
|
|
5930
5969
|
this._nextId = 0;
|
|
5931
5970
|
this._array = [];
|
|
5932
|
-
this._zArray = [];
|
|
5933
5971
|
this._pool = [];
|
|
5934
5972
|
this._limit = 0;
|
|
5935
5973
|
this._groupLimits = new Map();
|
|
5936
|
-
this.
|
|
5937
|
-
this.
|
|
5938
|
-
this._maxZIndex = 0;
|
|
5974
|
+
this._particleBuckets = new Map();
|
|
5975
|
+
this._zBuckets = this._createBuckets(this._container.zLayers);
|
|
5939
5976
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize);
|
|
5940
5977
|
this.checkParticlePositionPlugins = [];
|
|
5941
5978
|
this._particleResetPlugins = [];
|
|
@@ -5977,7 +6014,7 @@
|
|
|
5977
6014
|
return;
|
|
5978
6015
|
}
|
|
5979
6016
|
this._array.push(particle);
|
|
5980
|
-
this.
|
|
6017
|
+
this._insertParticleIntoBucket(particle);
|
|
5981
6018
|
this._nextId++;
|
|
5982
6019
|
this._container.dispatchEvent(EventType.particleAdded, {
|
|
5983
6020
|
particle,
|
|
@@ -5991,12 +6028,14 @@
|
|
|
5991
6028
|
}
|
|
5992
6029
|
clear() {
|
|
5993
6030
|
this._array = [];
|
|
5994
|
-
this.
|
|
6031
|
+
this._particleBuckets.clear();
|
|
6032
|
+
this._resetBuckets(this._container.zLayers);
|
|
5995
6033
|
}
|
|
5996
6034
|
destroy() {
|
|
5997
6035
|
this._array = [];
|
|
5998
6036
|
this._pool.length = 0;
|
|
5999
|
-
this.
|
|
6037
|
+
this._particleBuckets.clear();
|
|
6038
|
+
this._zBuckets = [];
|
|
6000
6039
|
this.checkParticlePositionPlugins = [];
|
|
6001
6040
|
this._particleResetPlugins = [];
|
|
6002
6041
|
this._particleUpdatePlugins = [];
|
|
@@ -6005,8 +6044,14 @@
|
|
|
6005
6044
|
this._updatePlugins = [];
|
|
6006
6045
|
}
|
|
6007
6046
|
drawParticles(delta) {
|
|
6008
|
-
for (
|
|
6009
|
-
|
|
6047
|
+
for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
|
|
6048
|
+
const bucket = this._zBuckets[i];
|
|
6049
|
+
if (!bucket) {
|
|
6050
|
+
continue;
|
|
6051
|
+
}
|
|
6052
|
+
for (const particle of bucket) {
|
|
6053
|
+
particle.draw(delta);
|
|
6054
|
+
}
|
|
6010
6055
|
}
|
|
6011
6056
|
}
|
|
6012
6057
|
filter(condition) {
|
|
@@ -6020,15 +6065,14 @@
|
|
|
6020
6065
|
}
|
|
6021
6066
|
async init() {
|
|
6022
6067
|
const container = this._container, options = container.actualOptions;
|
|
6023
|
-
this._minZIndex = 0;
|
|
6024
|
-
this._maxZIndex = 0;
|
|
6025
|
-
this._needsSort = false;
|
|
6026
6068
|
this.checkParticlePositionPlugins = [];
|
|
6027
6069
|
this._updatePlugins = [];
|
|
6028
6070
|
this._particleUpdatePlugins = [];
|
|
6029
6071
|
this._postUpdatePlugins = [];
|
|
6030
6072
|
this._particleResetPlugins = [];
|
|
6031
6073
|
this._postParticleUpdatePlugins = [];
|
|
6074
|
+
this._particleBuckets.clear();
|
|
6075
|
+
this._resetBuckets(container.zLayers);
|
|
6032
6076
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
|
|
6033
6077
|
for (const plugin of container.plugins) {
|
|
6034
6078
|
if (plugin.redrawInit) {
|
|
@@ -6129,79 +6173,25 @@
|
|
|
6129
6173
|
}
|
|
6130
6174
|
this._applyDensity(options.particles, pluginsCount);
|
|
6131
6175
|
}
|
|
6132
|
-
setLastZIndex(zIndex) {
|
|
6133
|
-
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
6134
|
-
}
|
|
6135
6176
|
setResizeFactor(factor) {
|
|
6136
6177
|
this._resizeFactor = factor;
|
|
6137
6178
|
}
|
|
6138
6179
|
update(delta) {
|
|
6139
|
-
const particlesToDelete = new Set();
|
|
6140
6180
|
this.grid.clear();
|
|
6141
6181
|
for (const plugin of this._updatePlugins) {
|
|
6142
6182
|
plugin.update?.(delta);
|
|
6143
6183
|
}
|
|
6144
|
-
const
|
|
6145
|
-
for (const particle of this._array) {
|
|
6146
|
-
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6147
|
-
particle.position.x *= resizeFactor.width;
|
|
6148
|
-
particle.position.y *= resizeFactor.height;
|
|
6149
|
-
particle.initialPosition.x *= resizeFactor.width;
|
|
6150
|
-
particle.initialPosition.y *= resizeFactor.height;
|
|
6151
|
-
}
|
|
6152
|
-
particle.ignoresResizeRatio = false;
|
|
6153
|
-
for (const plugin of this._particleResetPlugins) {
|
|
6154
|
-
plugin.particleReset?.(particle);
|
|
6155
|
-
}
|
|
6156
|
-
for (const plugin of this._particleUpdatePlugins) {
|
|
6157
|
-
if (particle.destroyed) {
|
|
6158
|
-
break;
|
|
6159
|
-
}
|
|
6160
|
-
plugin.particleUpdate?.(particle, delta);
|
|
6161
|
-
}
|
|
6162
|
-
if (particle.destroyed) {
|
|
6163
|
-
particlesToDelete.add(particle);
|
|
6164
|
-
continue;
|
|
6165
|
-
}
|
|
6166
|
-
this.grid.insert(particle);
|
|
6167
|
-
}
|
|
6184
|
+
const particlesToDelete = this._updateParticlesPhase1(delta);
|
|
6168
6185
|
for (const plugin of this._postUpdatePlugins) {
|
|
6169
6186
|
plugin.postUpdate?.(delta);
|
|
6170
6187
|
}
|
|
6171
|
-
|
|
6172
|
-
if (particle.destroyed) {
|
|
6173
|
-
particlesToDelete.add(particle);
|
|
6174
|
-
continue;
|
|
6175
|
-
}
|
|
6176
|
-
for (const updater of this._container.particleUpdaters) {
|
|
6177
|
-
updater.update(particle, delta);
|
|
6178
|
-
}
|
|
6179
|
-
if (!particle.destroyed && !particle.spawning) {
|
|
6180
|
-
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6181
|
-
plugin.postParticleUpdate?.(particle, delta);
|
|
6182
|
-
}
|
|
6183
|
-
}
|
|
6184
|
-
else if (particle.destroyed) {
|
|
6185
|
-
particlesToDelete.add(particle);
|
|
6186
|
-
}
|
|
6187
|
-
}
|
|
6188
|
+
this._updateParticlesPhase2(delta, particlesToDelete);
|
|
6188
6189
|
if (particlesToDelete.size) {
|
|
6189
6190
|
for (const particle of particlesToDelete) {
|
|
6190
6191
|
this.remove(particle);
|
|
6191
6192
|
}
|
|
6192
6193
|
}
|
|
6193
6194
|
delete this._resizeFactor;
|
|
6194
|
-
if (this._needsSort) {
|
|
6195
|
-
const zArray = this._zArray;
|
|
6196
|
-
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
6197
|
-
const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
|
|
6198
|
-
if (!firstItem || !lastItem) {
|
|
6199
|
-
return;
|
|
6200
|
-
}
|
|
6201
|
-
this._maxZIndex = firstItem.position.z;
|
|
6202
|
-
this._minZIndex = lastItem.position.z;
|
|
6203
|
-
this._needsSort = false;
|
|
6204
|
-
}
|
|
6205
6195
|
}
|
|
6206
6196
|
_addToPool = (...particles) => {
|
|
6207
6197
|
this._pool.push(...particles);
|
|
@@ -6231,13 +6221,52 @@
|
|
|
6231
6221
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
6232
6222
|
}
|
|
6233
6223
|
};
|
|
6224
|
+
_createBuckets = (zLayers) => {
|
|
6225
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
6226
|
+
return Array.from({ length: bucketCount }, () => []);
|
|
6227
|
+
};
|
|
6228
|
+
_getBucketIndex = (zIndex) => {
|
|
6229
|
+
const maxBucketIndex = this._zBuckets.length - one;
|
|
6230
|
+
if (maxBucketIndex <= minIndex) {
|
|
6231
|
+
return minIndex;
|
|
6232
|
+
}
|
|
6233
|
+
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
6234
|
+
};
|
|
6235
|
+
_getParticleInsertIndex = (bucket, particleId) => {
|
|
6236
|
+
let start = minIndex, end = bucket.length;
|
|
6237
|
+
while (start < end) {
|
|
6238
|
+
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
6239
|
+
if (!middleParticle) {
|
|
6240
|
+
end = middle;
|
|
6241
|
+
continue;
|
|
6242
|
+
}
|
|
6243
|
+
if (middleParticle.id < particleId) {
|
|
6244
|
+
start = middle + one;
|
|
6245
|
+
}
|
|
6246
|
+
else {
|
|
6247
|
+
end = middle;
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
6250
|
+
return start;
|
|
6251
|
+
};
|
|
6234
6252
|
_initDensityFactor = densityOptions => {
|
|
6235
6253
|
const container = this._container;
|
|
6236
|
-
if (!
|
|
6254
|
+
if (!densityOptions.enable) {
|
|
6255
|
+
return defaultDensityFactor;
|
|
6256
|
+
}
|
|
6257
|
+
const canvasSize = container.canvas.size, pxRatio = container.retina.pixelRatio;
|
|
6258
|
+
if (!canvasSize.width || !canvasSize.height) {
|
|
6237
6259
|
return defaultDensityFactor;
|
|
6238
6260
|
}
|
|
6239
|
-
|
|
6240
|
-
|
|
6261
|
+
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
6262
|
+
};
|
|
6263
|
+
_insertParticleIntoBucket = (particle) => {
|
|
6264
|
+
const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
6265
|
+
if (!bucket) {
|
|
6266
|
+
return;
|
|
6267
|
+
}
|
|
6268
|
+
bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
|
|
6269
|
+
this._particleBuckets.set(particle.id, bucketIndex);
|
|
6241
6270
|
};
|
|
6242
6271
|
_removeParticle = (index, group, override) => {
|
|
6243
6272
|
const particle = this._array[index];
|
|
@@ -6247,9 +6276,8 @@
|
|
|
6247
6276
|
if (particle.group !== group) {
|
|
6248
6277
|
return false;
|
|
6249
6278
|
}
|
|
6250
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
6251
6279
|
this._array.splice(index, deleteCount);
|
|
6252
|
-
this.
|
|
6280
|
+
this._removeParticleFromBucket(particle);
|
|
6253
6281
|
particle.destroy(override);
|
|
6254
6282
|
this._container.dispatchEvent(EventType.particleRemoved, {
|
|
6255
6283
|
particle,
|
|
@@ -6257,6 +6285,98 @@
|
|
|
6257
6285
|
this._addToPool(particle);
|
|
6258
6286
|
return true;
|
|
6259
6287
|
};
|
|
6288
|
+
_removeParticleFromBucket = (particle) => {
|
|
6289
|
+
const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
6290
|
+
if (!bucket) {
|
|
6291
|
+
this._particleBuckets.delete(particle.id);
|
|
6292
|
+
return;
|
|
6293
|
+
}
|
|
6294
|
+
const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
|
|
6295
|
+
if (bucket[particleIndex]?.id !== particle.id) {
|
|
6296
|
+
this._particleBuckets.delete(particle.id);
|
|
6297
|
+
return;
|
|
6298
|
+
}
|
|
6299
|
+
bucket.splice(particleIndex, deleteCount);
|
|
6300
|
+
this._particleBuckets.delete(particle.id);
|
|
6301
|
+
};
|
|
6302
|
+
_resetBuckets = (zLayers) => {
|
|
6303
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
6304
|
+
if (this._zBuckets.length !== bucketCount) {
|
|
6305
|
+
this._zBuckets = this._createBuckets(bucketCount);
|
|
6306
|
+
return;
|
|
6307
|
+
}
|
|
6308
|
+
for (const bucket of this._zBuckets) {
|
|
6309
|
+
bucket.length = minIndex;
|
|
6310
|
+
}
|
|
6311
|
+
};
|
|
6312
|
+
_updateParticleBucket = (particle) => {
|
|
6313
|
+
const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
|
|
6314
|
+
if (currentBucketIndex === undefined) {
|
|
6315
|
+
this._insertParticleIntoBucket(particle);
|
|
6316
|
+
return;
|
|
6317
|
+
}
|
|
6318
|
+
if (currentBucketIndex === newBucketIndex) {
|
|
6319
|
+
return;
|
|
6320
|
+
}
|
|
6321
|
+
const currentBucket = this._zBuckets[currentBucketIndex];
|
|
6322
|
+
if (currentBucket) {
|
|
6323
|
+
const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
|
|
6324
|
+
if (currentBucket[particleIndex]?.id === particle.id) {
|
|
6325
|
+
currentBucket.splice(particleIndex, deleteCount);
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
const newBucket = this._zBuckets[newBucketIndex];
|
|
6329
|
+
if (!newBucket) {
|
|
6330
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
6331
|
+
return;
|
|
6332
|
+
}
|
|
6333
|
+
newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
|
|
6334
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
6335
|
+
};
|
|
6336
|
+
_updateParticlesPhase1 = (delta) => {
|
|
6337
|
+
const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
|
|
6338
|
+
for (const particle of this._array) {
|
|
6339
|
+
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6340
|
+
particle.position.x *= resizeFactor.width;
|
|
6341
|
+
particle.position.y *= resizeFactor.height;
|
|
6342
|
+
particle.initialPosition.x *= resizeFactor.width;
|
|
6343
|
+
particle.initialPosition.y *= resizeFactor.height;
|
|
6344
|
+
}
|
|
6345
|
+
particle.ignoresResizeRatio = false;
|
|
6346
|
+
for (const plugin of this._particleResetPlugins) {
|
|
6347
|
+
plugin.particleReset?.(particle);
|
|
6348
|
+
}
|
|
6349
|
+
for (const plugin of this._particleUpdatePlugins) {
|
|
6350
|
+
if (particle.destroyed) {
|
|
6351
|
+
break;
|
|
6352
|
+
}
|
|
6353
|
+
plugin.particleUpdate?.(particle, delta);
|
|
6354
|
+
}
|
|
6355
|
+
if (particle.destroyed) {
|
|
6356
|
+
particlesToDelete.add(particle);
|
|
6357
|
+
continue;
|
|
6358
|
+
}
|
|
6359
|
+
this.grid.insert(particle);
|
|
6360
|
+
}
|
|
6361
|
+
return particlesToDelete;
|
|
6362
|
+
};
|
|
6363
|
+
_updateParticlesPhase2 = (delta, particlesToDelete) => {
|
|
6364
|
+
for (const particle of this._array) {
|
|
6365
|
+
if (particle.destroyed) {
|
|
6366
|
+
particlesToDelete.add(particle);
|
|
6367
|
+
continue;
|
|
6368
|
+
}
|
|
6369
|
+
for (const updater of this._container.particleUpdaters) {
|
|
6370
|
+
updater.update(particle, delta);
|
|
6371
|
+
}
|
|
6372
|
+
if (!particle.spawning) {
|
|
6373
|
+
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6374
|
+
plugin.postParticleUpdate?.(particle, delta);
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
6377
|
+
this._updateParticleBucket(particle);
|
|
6378
|
+
}
|
|
6379
|
+
};
|
|
6260
6380
|
}
|
|
6261
6381
|
|
|
6262
6382
|
class Retina {
|
|
@@ -6272,9 +6392,8 @@
|
|
|
6272
6392
|
const container = this.container, options = container.actualOptions;
|
|
6273
6393
|
this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
|
|
6274
6394
|
this.reduceFactor = defaultReduceFactor;
|
|
6275
|
-
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
6276
|
-
if (
|
|
6277
|
-
const element = canvas.element;
|
|
6395
|
+
const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
|
|
6396
|
+
if (element) {
|
|
6278
6397
|
canvas.size.width = element.offsetWidth * ratio;
|
|
6279
6398
|
canvas.size.height = element.offsetHeight * ratio;
|
|
6280
6399
|
}
|