@tsparticles/preset-confetti 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$3 = 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);
|
|
@@ -4067,7 +4073,7 @@
|
|
|
4067
4073
|
}
|
|
4068
4074
|
|
|
4069
4075
|
async function loadLifeUpdater(engine) {
|
|
4070
|
-
engine.checkVersion("4.0.0
|
|
4076
|
+
engine.checkVersion("4.0.0");
|
|
4071
4077
|
await engine.pluginManager.register(e => {
|
|
4072
4078
|
e.pluginManager.addParticleUpdater("life", container => {
|
|
4073
4079
|
return Promise.resolve(new LifeUpdater(container));
|
|
@@ -4135,7 +4141,7 @@
|
|
|
4135
4141
|
}
|
|
4136
4142
|
|
|
4137
4143
|
async function loadMotionPlugin(engine) {
|
|
4138
|
-
engine.checkVersion("4.0.0
|
|
4144
|
+
engine.checkVersion("4.0.0");
|
|
4139
4145
|
await engine.pluginManager.register(e => {
|
|
4140
4146
|
e.pluginManager.addPlugin(new MotionPlugin());
|
|
4141
4147
|
});
|
|
@@ -4292,7 +4298,7 @@
|
|
|
4292
4298
|
}
|
|
4293
4299
|
|
|
4294
4300
|
async function loadRollUpdater(engine) {
|
|
4295
|
-
engine.checkVersion("4.0.0
|
|
4301
|
+
engine.checkVersion("4.0.0");
|
|
4296
4302
|
await engine.pluginManager.register(e => {
|
|
4297
4303
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
4298
4304
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -4426,7 +4432,7 @@
|
|
|
4426
4432
|
}
|
|
4427
4433
|
|
|
4428
4434
|
async function loadRotateUpdater(engine) {
|
|
4429
|
-
engine.checkVersion("4.0.0
|
|
4435
|
+
engine.checkVersion("4.0.0");
|
|
4430
4436
|
await engine.pluginManager.register(e => {
|
|
4431
4437
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
4432
4438
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -4450,7 +4456,7 @@
|
|
|
4450
4456
|
}
|
|
4451
4457
|
|
|
4452
4458
|
async function loadSquareShape(engine) {
|
|
4453
|
-
engine.checkVersion("4.0.0
|
|
4459
|
+
engine.checkVersion("4.0.0");
|
|
4454
4460
|
await engine.pluginManager.register(e => {
|
|
4455
4461
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
4456
4462
|
});
|
|
@@ -4587,7 +4593,7 @@
|
|
|
4587
4593
|
}
|
|
4588
4594
|
|
|
4589
4595
|
async function loadTiltUpdater(engine) {
|
|
4590
|
-
engine.checkVersion("4.0.0
|
|
4596
|
+
engine.checkVersion("4.0.0");
|
|
4591
4597
|
await engine.pluginManager.register(e => {
|
|
4592
4598
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
4593
4599
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -4709,7 +4715,7 @@
|
|
|
4709
4715
|
}
|
|
4710
4716
|
|
|
4711
4717
|
async function loadWobbleUpdater(engine) {
|
|
4712
|
-
engine.checkVersion("4.0.0
|
|
4718
|
+
engine.checkVersion("4.0.0");
|
|
4713
4719
|
await engine.pluginManager.register(e => {
|
|
4714
4720
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
4715
4721
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -5171,6 +5177,25 @@
|
|
|
5171
5177
|
};
|
|
5172
5178
|
}
|
|
5173
5179
|
|
|
5180
|
+
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
5181
|
+
const transferredCanvas = transferredCanvases.get(canvas);
|
|
5182
|
+
if (transferredCanvas) {
|
|
5183
|
+
return transferredCanvas;
|
|
5184
|
+
}
|
|
5185
|
+
if (typeof canvas.transferControlToOffscreen !== "function") {
|
|
5186
|
+
throw new TypeError("OffscreenCanvas is required but not supported by this browser");
|
|
5187
|
+
}
|
|
5188
|
+
try {
|
|
5189
|
+
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
5190
|
+
transferredCanvases.set(canvas, offscreenCanvas);
|
|
5191
|
+
return offscreenCanvas;
|
|
5192
|
+
}
|
|
5193
|
+
catch {
|
|
5194
|
+
throw new TypeError("OffscreenCanvas transfer failed");
|
|
5195
|
+
}
|
|
5196
|
+
}, isHtmlCanvasElement = (canvas) => {
|
|
5197
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
5198
|
+
};
|
|
5174
5199
|
function setStyle(canvas, style, important = false) {
|
|
5175
5200
|
if (!style) {
|
|
5176
5201
|
return;
|
|
@@ -5201,8 +5226,9 @@
|
|
|
5201
5226
|
}
|
|
5202
5227
|
}
|
|
5203
5228
|
class CanvasManager {
|
|
5204
|
-
|
|
5229
|
+
domElement;
|
|
5205
5230
|
render;
|
|
5231
|
+
renderCanvas;
|
|
5206
5232
|
size;
|
|
5207
5233
|
zoom = defaultZoom;
|
|
5208
5234
|
_container;
|
|
@@ -5237,9 +5263,10 @@
|
|
|
5237
5263
|
destroy() {
|
|
5238
5264
|
this.stop();
|
|
5239
5265
|
if (this._generated) {
|
|
5240
|
-
const element = this.
|
|
5266
|
+
const element = this.domElement;
|
|
5241
5267
|
element?.remove();
|
|
5242
|
-
this.
|
|
5268
|
+
this.domElement = undefined;
|
|
5269
|
+
this.renderCanvas = undefined;
|
|
5243
5270
|
}
|
|
5244
5271
|
else {
|
|
5245
5272
|
this._resetOriginalStyle();
|
|
@@ -5272,16 +5299,17 @@
|
|
|
5272
5299
|
this._initStyle();
|
|
5273
5300
|
this.initBackground();
|
|
5274
5301
|
this._safeMutationObserver(obs => {
|
|
5275
|
-
|
|
5302
|
+
const element = this.domElement;
|
|
5303
|
+
if (!element || !(element instanceof Node)) {
|
|
5276
5304
|
return;
|
|
5277
5305
|
}
|
|
5278
|
-
obs.observe(
|
|
5306
|
+
obs.observe(element, { attributes: true });
|
|
5279
5307
|
});
|
|
5280
5308
|
this.initPlugins();
|
|
5281
5309
|
this.render.init();
|
|
5282
5310
|
}
|
|
5283
5311
|
initBackground() {
|
|
5284
|
-
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.
|
|
5312
|
+
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
|
|
5285
5313
|
if (!element) {
|
|
5286
5314
|
return;
|
|
5287
5315
|
}
|
|
@@ -5306,21 +5334,30 @@
|
|
|
5306
5334
|
}
|
|
5307
5335
|
}
|
|
5308
5336
|
loadCanvas(canvas) {
|
|
5309
|
-
if (this._generated && this.
|
|
5310
|
-
this.
|
|
5337
|
+
if (this._generated && this.domElement) {
|
|
5338
|
+
this.domElement.remove();
|
|
5339
|
+
}
|
|
5340
|
+
const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
5341
|
+
this.domElement = domCanvas;
|
|
5342
|
+
this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
5343
|
+
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
5344
|
+
const domElement = this.domElement;
|
|
5345
|
+
if (domElement) {
|
|
5346
|
+
domElement.ariaHidden = "true";
|
|
5347
|
+
this._originalStyle = cloneStyle(domElement.style);
|
|
5348
|
+
}
|
|
5349
|
+
const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
|
|
5350
|
+
if (domElement) {
|
|
5351
|
+
standardSize.height = domElement.offsetHeight;
|
|
5352
|
+
standardSize.width = domElement.offsetWidth;
|
|
5353
|
+
}
|
|
5354
|
+
else {
|
|
5355
|
+
standardSize.height = renderCanvas.height;
|
|
5356
|
+
standardSize.width = renderCanvas.width;
|
|
5311
5357
|
}
|
|
5312
|
-
const container = this._container;
|
|
5313
|
-
this._generated =
|
|
5314
|
-
generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
|
|
5315
|
-
this.element = canvas;
|
|
5316
|
-
this.element.ariaHidden = "true";
|
|
5317
|
-
this._originalStyle = cloneStyle(this.element.style);
|
|
5318
|
-
const standardSize = this._standardSize;
|
|
5319
|
-
standardSize.height = canvas.offsetHeight;
|
|
5320
|
-
standardSize.width = canvas.offsetWidth;
|
|
5321
5358
|
const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
|
|
5322
|
-
|
|
5323
|
-
|
|
5359
|
+
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
5360
|
+
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
5324
5361
|
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
5325
5362
|
this.render.setContextSettings({
|
|
5326
5363
|
alpha: true,
|
|
@@ -5328,42 +5365,48 @@
|
|
|
5328
5365
|
desynchronized: true,
|
|
5329
5366
|
willReadFrequently: false,
|
|
5330
5367
|
});
|
|
5331
|
-
this.render.setContext(
|
|
5368
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
5332
5369
|
this._safeMutationObserver(obs => {
|
|
5333
5370
|
obs.disconnect();
|
|
5334
5371
|
});
|
|
5335
5372
|
container.retina.init();
|
|
5336
5373
|
this.initBackground();
|
|
5337
5374
|
this._safeMutationObserver(obs => {
|
|
5338
|
-
|
|
5375
|
+
const element = this.domElement;
|
|
5376
|
+
if (!element || !(element instanceof Node)) {
|
|
5339
5377
|
return;
|
|
5340
5378
|
}
|
|
5341
|
-
obs.observe(
|
|
5379
|
+
obs.observe(element, { attributes: true });
|
|
5342
5380
|
});
|
|
5343
5381
|
}
|
|
5344
5382
|
resize() {
|
|
5345
|
-
|
|
5383
|
+
const element = this.domElement;
|
|
5384
|
+
if (!element) {
|
|
5385
|
+
return false;
|
|
5386
|
+
}
|
|
5387
|
+
const container = this._container, renderCanvas = this.renderCanvas;
|
|
5388
|
+
if (renderCanvas === undefined) {
|
|
5346
5389
|
return false;
|
|
5347
5390
|
}
|
|
5348
|
-
const
|
|
5349
|
-
width:
|
|
5350
|
-
height:
|
|
5391
|
+
const currentSize = container.canvas._standardSize, newSize = {
|
|
5392
|
+
width: element.offsetWidth,
|
|
5393
|
+
height: element.offsetHeight,
|
|
5351
5394
|
}, pxRatio = container.retina.pixelRatio, retinaSize = {
|
|
5352
5395
|
width: newSize.width * pxRatio,
|
|
5353
5396
|
height: newSize.height * pxRatio,
|
|
5354
5397
|
};
|
|
5355
5398
|
if (newSize.height === currentSize.height &&
|
|
5356
5399
|
newSize.width === currentSize.width &&
|
|
5357
|
-
retinaSize.height ===
|
|
5358
|
-
retinaSize.width ===
|
|
5400
|
+
retinaSize.height === renderCanvas.height &&
|
|
5401
|
+
retinaSize.width === renderCanvas.width) {
|
|
5359
5402
|
return false;
|
|
5360
5403
|
}
|
|
5361
5404
|
const oldSize = { ...currentSize };
|
|
5362
5405
|
currentSize.height = newSize.height;
|
|
5363
5406
|
currentSize.width = newSize.width;
|
|
5364
5407
|
const canvasSize = this.size;
|
|
5365
|
-
|
|
5366
|
-
|
|
5408
|
+
renderCanvas.width = canvasSize.width = retinaSize.width;
|
|
5409
|
+
renderCanvas.height = canvasSize.height = retinaSize.height;
|
|
5367
5410
|
if (this._container.started) {
|
|
5368
5411
|
container.particles.setResizeFactor({
|
|
5369
5412
|
width: currentSize.width / oldSize.width,
|
|
@@ -5373,7 +5416,7 @@
|
|
|
5373
5416
|
return true;
|
|
5374
5417
|
}
|
|
5375
5418
|
setPointerEvents(type) {
|
|
5376
|
-
const element = this.
|
|
5419
|
+
const element = this.domElement;
|
|
5377
5420
|
if (!element) {
|
|
5378
5421
|
return;
|
|
5379
5422
|
}
|
|
@@ -5392,7 +5435,7 @@
|
|
|
5392
5435
|
this.render.stop();
|
|
5393
5436
|
}
|
|
5394
5437
|
async windowResize() {
|
|
5395
|
-
if (!this.
|
|
5438
|
+
if (!this.domElement || !this.resize()) {
|
|
5396
5439
|
return;
|
|
5397
5440
|
}
|
|
5398
5441
|
const container = this._container, needsRefresh = container.updateActualOptions();
|
|
@@ -5408,7 +5451,7 @@
|
|
|
5408
5451
|
}
|
|
5409
5452
|
};
|
|
5410
5453
|
_initStyle = () => {
|
|
5411
|
-
const element = this.
|
|
5454
|
+
const element = this.domElement, options = this._container.actualOptions;
|
|
5412
5455
|
if (!element) {
|
|
5413
5456
|
return;
|
|
5414
5457
|
}
|
|
@@ -5430,7 +5473,7 @@
|
|
|
5430
5473
|
}
|
|
5431
5474
|
};
|
|
5432
5475
|
_repairStyle = () => {
|
|
5433
|
-
const element = this.
|
|
5476
|
+
const element = this.domElement;
|
|
5434
5477
|
if (!element) {
|
|
5435
5478
|
return;
|
|
5436
5479
|
}
|
|
@@ -5450,7 +5493,7 @@
|
|
|
5450
5493
|
});
|
|
5451
5494
|
};
|
|
5452
5495
|
_resetOriginalStyle = () => {
|
|
5453
|
-
const element = this.
|
|
5496
|
+
const element = this.domElement, originalStyle = this._originalStyle;
|
|
5454
5497
|
if (!element || !originalStyle) {
|
|
5455
5498
|
return;
|
|
5456
5499
|
}
|
|
@@ -5463,7 +5506,7 @@
|
|
|
5463
5506
|
callback(this._mutationObserver);
|
|
5464
5507
|
};
|
|
5465
5508
|
_setFullScreenStyle = () => {
|
|
5466
|
-
const element = this.
|
|
5509
|
+
const element = this.domElement;
|
|
5467
5510
|
if (!element) {
|
|
5468
5511
|
return;
|
|
5469
5512
|
}
|
|
@@ -5537,7 +5580,7 @@
|
|
|
5537
5580
|
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
5538
5581
|
return;
|
|
5539
5582
|
}
|
|
5540
|
-
const canvasEl = container.canvas.
|
|
5583
|
+
const canvasEl = container.canvas.domElement;
|
|
5541
5584
|
if (this._resizeObserver && !add) {
|
|
5542
5585
|
if (canvasEl) {
|
|
5543
5586
|
this._resizeObserver.unobserve(canvasEl);
|
|
@@ -5792,8 +5835,6 @@
|
|
|
5792
5835
|
this._initPosition(position);
|
|
5793
5836
|
this.initialVelocity = this._calculateVelocity();
|
|
5794
5837
|
this.velocity = this.initialVelocity.copy();
|
|
5795
|
-
const particles = container.particles;
|
|
5796
|
-
particles.setLastZIndex(this.position.z);
|
|
5797
5838
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
5798
5839
|
this.sides = 24;
|
|
5799
5840
|
let effectDrawer, shapeDrawer;
|
|
@@ -5943,7 +5984,7 @@
|
|
|
5943
5984
|
return color;
|
|
5944
5985
|
};
|
|
5945
5986
|
_initPosition = position => {
|
|
5946
|
-
const container = this._container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5987
|
+
const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5947
5988
|
if (!initialPosition) {
|
|
5948
5989
|
throw new Error("a valid position cannot be found for particle");
|
|
5949
5990
|
}
|
|
@@ -6077,10 +6118,8 @@
|
|
|
6077
6118
|
_container;
|
|
6078
6119
|
_groupLimits;
|
|
6079
6120
|
_limit;
|
|
6080
|
-
_maxZIndex;
|
|
6081
|
-
_minZIndex;
|
|
6082
|
-
_needsSort;
|
|
6083
6121
|
_nextId;
|
|
6122
|
+
_particleBuckets;
|
|
6084
6123
|
_particleResetPlugins;
|
|
6085
6124
|
_particleUpdatePlugins;
|
|
6086
6125
|
_pluginManager;
|
|
@@ -6089,19 +6128,17 @@
|
|
|
6089
6128
|
_postUpdatePlugins;
|
|
6090
6129
|
_resizeFactor;
|
|
6091
6130
|
_updatePlugins;
|
|
6092
|
-
|
|
6131
|
+
_zBuckets;
|
|
6093
6132
|
constructor(pluginManager, container) {
|
|
6094
6133
|
this._pluginManager = pluginManager;
|
|
6095
6134
|
this._container = container;
|
|
6096
6135
|
this._nextId = 0;
|
|
6097
6136
|
this._array = [];
|
|
6098
|
-
this._zArray = [];
|
|
6099
6137
|
this._pool = [];
|
|
6100
6138
|
this._limit = 0;
|
|
6101
6139
|
this._groupLimits = new Map();
|
|
6102
|
-
this.
|
|
6103
|
-
this.
|
|
6104
|
-
this._maxZIndex = 0;
|
|
6140
|
+
this._particleBuckets = new Map();
|
|
6141
|
+
this._zBuckets = this._createBuckets(this._container.zLayers);
|
|
6105
6142
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize);
|
|
6106
6143
|
this.checkParticlePositionPlugins = [];
|
|
6107
6144
|
this._particleResetPlugins = [];
|
|
@@ -6143,7 +6180,7 @@
|
|
|
6143
6180
|
return;
|
|
6144
6181
|
}
|
|
6145
6182
|
this._array.push(particle);
|
|
6146
|
-
this.
|
|
6183
|
+
this._insertParticleIntoBucket(particle);
|
|
6147
6184
|
this._nextId++;
|
|
6148
6185
|
this._container.dispatchEvent(EventType.particleAdded, {
|
|
6149
6186
|
particle,
|
|
@@ -6157,12 +6194,14 @@
|
|
|
6157
6194
|
}
|
|
6158
6195
|
clear() {
|
|
6159
6196
|
this._array = [];
|
|
6160
|
-
this.
|
|
6197
|
+
this._particleBuckets.clear();
|
|
6198
|
+
this._resetBuckets(this._container.zLayers);
|
|
6161
6199
|
}
|
|
6162
6200
|
destroy() {
|
|
6163
6201
|
this._array = [];
|
|
6164
6202
|
this._pool.length = 0;
|
|
6165
|
-
this.
|
|
6203
|
+
this._particleBuckets.clear();
|
|
6204
|
+
this._zBuckets = [];
|
|
6166
6205
|
this.checkParticlePositionPlugins = [];
|
|
6167
6206
|
this._particleResetPlugins = [];
|
|
6168
6207
|
this._particleUpdatePlugins = [];
|
|
@@ -6171,8 +6210,14 @@
|
|
|
6171
6210
|
this._updatePlugins = [];
|
|
6172
6211
|
}
|
|
6173
6212
|
drawParticles(delta) {
|
|
6174
|
-
for (
|
|
6175
|
-
|
|
6213
|
+
for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
|
|
6214
|
+
const bucket = this._zBuckets[i];
|
|
6215
|
+
if (!bucket) {
|
|
6216
|
+
continue;
|
|
6217
|
+
}
|
|
6218
|
+
for (const particle of bucket) {
|
|
6219
|
+
particle.draw(delta);
|
|
6220
|
+
}
|
|
6176
6221
|
}
|
|
6177
6222
|
}
|
|
6178
6223
|
filter(condition) {
|
|
@@ -6186,15 +6231,14 @@
|
|
|
6186
6231
|
}
|
|
6187
6232
|
async init() {
|
|
6188
6233
|
const container = this._container, options = container.actualOptions;
|
|
6189
|
-
this._minZIndex = 0;
|
|
6190
|
-
this._maxZIndex = 0;
|
|
6191
|
-
this._needsSort = false;
|
|
6192
6234
|
this.checkParticlePositionPlugins = [];
|
|
6193
6235
|
this._updatePlugins = [];
|
|
6194
6236
|
this._particleUpdatePlugins = [];
|
|
6195
6237
|
this._postUpdatePlugins = [];
|
|
6196
6238
|
this._particleResetPlugins = [];
|
|
6197
6239
|
this._postParticleUpdatePlugins = [];
|
|
6240
|
+
this._particleBuckets.clear();
|
|
6241
|
+
this._resetBuckets(container.zLayers);
|
|
6198
6242
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
|
|
6199
6243
|
for (const plugin of container.plugins) {
|
|
6200
6244
|
if (plugin.redrawInit) {
|
|
@@ -6295,79 +6339,25 @@
|
|
|
6295
6339
|
}
|
|
6296
6340
|
this._applyDensity(options.particles, pluginsCount);
|
|
6297
6341
|
}
|
|
6298
|
-
setLastZIndex(zIndex) {
|
|
6299
|
-
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
6300
|
-
}
|
|
6301
6342
|
setResizeFactor(factor) {
|
|
6302
6343
|
this._resizeFactor = factor;
|
|
6303
6344
|
}
|
|
6304
6345
|
update(delta) {
|
|
6305
|
-
const particlesToDelete = new Set();
|
|
6306
6346
|
this.grid.clear();
|
|
6307
6347
|
for (const plugin of this._updatePlugins) {
|
|
6308
6348
|
plugin.update?.(delta);
|
|
6309
6349
|
}
|
|
6310
|
-
const
|
|
6311
|
-
for (const particle of this._array) {
|
|
6312
|
-
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6313
|
-
particle.position.x *= resizeFactor.width;
|
|
6314
|
-
particle.position.y *= resizeFactor.height;
|
|
6315
|
-
particle.initialPosition.x *= resizeFactor.width;
|
|
6316
|
-
particle.initialPosition.y *= resizeFactor.height;
|
|
6317
|
-
}
|
|
6318
|
-
particle.ignoresResizeRatio = false;
|
|
6319
|
-
for (const plugin of this._particleResetPlugins) {
|
|
6320
|
-
plugin.particleReset?.(particle);
|
|
6321
|
-
}
|
|
6322
|
-
for (const plugin of this._particleUpdatePlugins) {
|
|
6323
|
-
if (particle.destroyed) {
|
|
6324
|
-
break;
|
|
6325
|
-
}
|
|
6326
|
-
plugin.particleUpdate?.(particle, delta);
|
|
6327
|
-
}
|
|
6328
|
-
if (particle.destroyed) {
|
|
6329
|
-
particlesToDelete.add(particle);
|
|
6330
|
-
continue;
|
|
6331
|
-
}
|
|
6332
|
-
this.grid.insert(particle);
|
|
6333
|
-
}
|
|
6350
|
+
const particlesToDelete = this._updateParticlesPhase1(delta);
|
|
6334
6351
|
for (const plugin of this._postUpdatePlugins) {
|
|
6335
6352
|
plugin.postUpdate?.(delta);
|
|
6336
6353
|
}
|
|
6337
|
-
|
|
6338
|
-
if (particle.destroyed) {
|
|
6339
|
-
particlesToDelete.add(particle);
|
|
6340
|
-
continue;
|
|
6341
|
-
}
|
|
6342
|
-
for (const updater of this._container.particleUpdaters) {
|
|
6343
|
-
updater.update(particle, delta);
|
|
6344
|
-
}
|
|
6345
|
-
if (!particle.destroyed && !particle.spawning) {
|
|
6346
|
-
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6347
|
-
plugin.postParticleUpdate?.(particle, delta);
|
|
6348
|
-
}
|
|
6349
|
-
}
|
|
6350
|
-
else if (particle.destroyed) {
|
|
6351
|
-
particlesToDelete.add(particle);
|
|
6352
|
-
}
|
|
6353
|
-
}
|
|
6354
|
+
this._updateParticlesPhase2(delta, particlesToDelete);
|
|
6354
6355
|
if (particlesToDelete.size) {
|
|
6355
6356
|
for (const particle of particlesToDelete) {
|
|
6356
6357
|
this.remove(particle);
|
|
6357
6358
|
}
|
|
6358
6359
|
}
|
|
6359
6360
|
delete this._resizeFactor;
|
|
6360
|
-
if (this._needsSort) {
|
|
6361
|
-
const zArray = this._zArray;
|
|
6362
|
-
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
6363
|
-
const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
|
|
6364
|
-
if (!firstItem || !lastItem) {
|
|
6365
|
-
return;
|
|
6366
|
-
}
|
|
6367
|
-
this._maxZIndex = firstItem.position.z;
|
|
6368
|
-
this._minZIndex = lastItem.position.z;
|
|
6369
|
-
this._needsSort = false;
|
|
6370
|
-
}
|
|
6371
6361
|
}
|
|
6372
6362
|
_addToPool = (...particles) => {
|
|
6373
6363
|
this._pool.push(...particles);
|
|
@@ -6397,13 +6387,52 @@
|
|
|
6397
6387
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
6398
6388
|
}
|
|
6399
6389
|
};
|
|
6390
|
+
_createBuckets = (zLayers) => {
|
|
6391
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
6392
|
+
return Array.from({ length: bucketCount }, () => []);
|
|
6393
|
+
};
|
|
6394
|
+
_getBucketIndex = (zIndex) => {
|
|
6395
|
+
const maxBucketIndex = this._zBuckets.length - one;
|
|
6396
|
+
if (maxBucketIndex <= minIndex) {
|
|
6397
|
+
return minIndex;
|
|
6398
|
+
}
|
|
6399
|
+
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
6400
|
+
};
|
|
6401
|
+
_getParticleInsertIndex = (bucket, particleId) => {
|
|
6402
|
+
let start = minIndex, end = bucket.length;
|
|
6403
|
+
while (start < end) {
|
|
6404
|
+
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
6405
|
+
if (!middleParticle) {
|
|
6406
|
+
end = middle;
|
|
6407
|
+
continue;
|
|
6408
|
+
}
|
|
6409
|
+
if (middleParticle.id < particleId) {
|
|
6410
|
+
start = middle + one;
|
|
6411
|
+
}
|
|
6412
|
+
else {
|
|
6413
|
+
end = middle;
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
return start;
|
|
6417
|
+
};
|
|
6400
6418
|
_initDensityFactor = densityOptions => {
|
|
6401
6419
|
const container = this._container;
|
|
6402
|
-
if (!
|
|
6420
|
+
if (!densityOptions.enable) {
|
|
6421
|
+
return defaultDensityFactor;
|
|
6422
|
+
}
|
|
6423
|
+
const canvasSize = container.canvas.size, pxRatio = container.retina.pixelRatio;
|
|
6424
|
+
if (!canvasSize.width || !canvasSize.height) {
|
|
6403
6425
|
return defaultDensityFactor;
|
|
6404
6426
|
}
|
|
6405
|
-
|
|
6406
|
-
|
|
6427
|
+
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
6428
|
+
};
|
|
6429
|
+
_insertParticleIntoBucket = (particle) => {
|
|
6430
|
+
const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
6431
|
+
if (!bucket) {
|
|
6432
|
+
return;
|
|
6433
|
+
}
|
|
6434
|
+
bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
|
|
6435
|
+
this._particleBuckets.set(particle.id, bucketIndex);
|
|
6407
6436
|
};
|
|
6408
6437
|
_removeParticle = (index, group, override) => {
|
|
6409
6438
|
const particle = this._array[index];
|
|
@@ -6413,9 +6442,8 @@
|
|
|
6413
6442
|
if (particle.group !== group) {
|
|
6414
6443
|
return false;
|
|
6415
6444
|
}
|
|
6416
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
6417
6445
|
this._array.splice(index, deleteCount);
|
|
6418
|
-
this.
|
|
6446
|
+
this._removeParticleFromBucket(particle);
|
|
6419
6447
|
particle.destroy(override);
|
|
6420
6448
|
this._container.dispatchEvent(EventType.particleRemoved, {
|
|
6421
6449
|
particle,
|
|
@@ -6423,6 +6451,98 @@
|
|
|
6423
6451
|
this._addToPool(particle);
|
|
6424
6452
|
return true;
|
|
6425
6453
|
};
|
|
6454
|
+
_removeParticleFromBucket = (particle) => {
|
|
6455
|
+
const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
6456
|
+
if (!bucket) {
|
|
6457
|
+
this._particleBuckets.delete(particle.id);
|
|
6458
|
+
return;
|
|
6459
|
+
}
|
|
6460
|
+
const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
|
|
6461
|
+
if (bucket[particleIndex]?.id !== particle.id) {
|
|
6462
|
+
this._particleBuckets.delete(particle.id);
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
6465
|
+
bucket.splice(particleIndex, deleteCount);
|
|
6466
|
+
this._particleBuckets.delete(particle.id);
|
|
6467
|
+
};
|
|
6468
|
+
_resetBuckets = (zLayers) => {
|
|
6469
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
6470
|
+
if (this._zBuckets.length !== bucketCount) {
|
|
6471
|
+
this._zBuckets = this._createBuckets(bucketCount);
|
|
6472
|
+
return;
|
|
6473
|
+
}
|
|
6474
|
+
for (const bucket of this._zBuckets) {
|
|
6475
|
+
bucket.length = minIndex;
|
|
6476
|
+
}
|
|
6477
|
+
};
|
|
6478
|
+
_updateParticleBucket = (particle) => {
|
|
6479
|
+
const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
|
|
6480
|
+
if (currentBucketIndex === undefined) {
|
|
6481
|
+
this._insertParticleIntoBucket(particle);
|
|
6482
|
+
return;
|
|
6483
|
+
}
|
|
6484
|
+
if (currentBucketIndex === newBucketIndex) {
|
|
6485
|
+
return;
|
|
6486
|
+
}
|
|
6487
|
+
const currentBucket = this._zBuckets[currentBucketIndex];
|
|
6488
|
+
if (currentBucket) {
|
|
6489
|
+
const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
|
|
6490
|
+
if (currentBucket[particleIndex]?.id === particle.id) {
|
|
6491
|
+
currentBucket.splice(particleIndex, deleteCount);
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
const newBucket = this._zBuckets[newBucketIndex];
|
|
6495
|
+
if (!newBucket) {
|
|
6496
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
6497
|
+
return;
|
|
6498
|
+
}
|
|
6499
|
+
newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
|
|
6500
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
6501
|
+
};
|
|
6502
|
+
_updateParticlesPhase1 = (delta) => {
|
|
6503
|
+
const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
|
|
6504
|
+
for (const particle of this._array) {
|
|
6505
|
+
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6506
|
+
particle.position.x *= resizeFactor.width;
|
|
6507
|
+
particle.position.y *= resizeFactor.height;
|
|
6508
|
+
particle.initialPosition.x *= resizeFactor.width;
|
|
6509
|
+
particle.initialPosition.y *= resizeFactor.height;
|
|
6510
|
+
}
|
|
6511
|
+
particle.ignoresResizeRatio = false;
|
|
6512
|
+
for (const plugin of this._particleResetPlugins) {
|
|
6513
|
+
plugin.particleReset?.(particle);
|
|
6514
|
+
}
|
|
6515
|
+
for (const plugin of this._particleUpdatePlugins) {
|
|
6516
|
+
if (particle.destroyed) {
|
|
6517
|
+
break;
|
|
6518
|
+
}
|
|
6519
|
+
plugin.particleUpdate?.(particle, delta);
|
|
6520
|
+
}
|
|
6521
|
+
if (particle.destroyed) {
|
|
6522
|
+
particlesToDelete.add(particle);
|
|
6523
|
+
continue;
|
|
6524
|
+
}
|
|
6525
|
+
this.grid.insert(particle);
|
|
6526
|
+
}
|
|
6527
|
+
return particlesToDelete;
|
|
6528
|
+
};
|
|
6529
|
+
_updateParticlesPhase2 = (delta, particlesToDelete) => {
|
|
6530
|
+
for (const particle of this._array) {
|
|
6531
|
+
if (particle.destroyed) {
|
|
6532
|
+
particlesToDelete.add(particle);
|
|
6533
|
+
continue;
|
|
6534
|
+
}
|
|
6535
|
+
for (const updater of this._container.particleUpdaters) {
|
|
6536
|
+
updater.update(particle, delta);
|
|
6537
|
+
}
|
|
6538
|
+
if (!particle.spawning) {
|
|
6539
|
+
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6540
|
+
plugin.postParticleUpdate?.(particle, delta);
|
|
6541
|
+
}
|
|
6542
|
+
}
|
|
6543
|
+
this._updateParticleBucket(particle);
|
|
6544
|
+
}
|
|
6545
|
+
};
|
|
6426
6546
|
}
|
|
6427
6547
|
|
|
6428
6548
|
class Retina {
|
|
@@ -6438,9 +6558,8 @@
|
|
|
6438
6558
|
const container = this.container, options = container.actualOptions;
|
|
6439
6559
|
this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
|
|
6440
6560
|
this.reduceFactor = defaultReduceFactor;
|
|
6441
|
-
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
6442
|
-
if (
|
|
6443
|
-
const element = canvas.element;
|
|
6561
|
+
const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
|
|
6562
|
+
if (element) {
|
|
6444
6563
|
canvas.size.width = element.offsetWidth * ratio;
|
|
6445
6564
|
canvas.size.height = element.offsetHeight * ratio;
|
|
6446
6565
|
}
|