@tsparticles/preset-confetti-falling 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) {
|
|
@@ -965,7 +965,7 @@
|
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
967
|
else {
|
|
968
|
-
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases
|
|
968
|
+
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
|
|
969
969
|
if (foundCanvas) {
|
|
970
970
|
canvasEl = foundCanvas;
|
|
971
971
|
canvasEl.dataset[generatedAttribute] = generatedFalse;
|
|
@@ -1002,7 +1002,7 @@
|
|
|
1002
1002
|
return this._domArray;
|
|
1003
1003
|
}
|
|
1004
1004
|
get version() {
|
|
1005
|
-
return "4.0.0
|
|
1005
|
+
return "4.0.0";
|
|
1006
1006
|
}
|
|
1007
1007
|
addEventListener(type, listener) {
|
|
1008
1008
|
this._eventDispatcher.addEventListener(type, listener);
|
|
@@ -1033,7 +1033,11 @@
|
|
|
1033
1033
|
}
|
|
1034
1034
|
async load(params) {
|
|
1035
1035
|
await this.init();
|
|
1036
|
-
|
|
1036
|
+
let domSourceElement;
|
|
1037
|
+
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
1038
|
+
domSourceElement = params.element;
|
|
1039
|
+
}
|
|
1040
|
+
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({
|
|
1037
1041
|
dispatchCallback: (eventType, args) => {
|
|
1038
1042
|
this.dispatchEvent(eventType, args);
|
|
1039
1043
|
},
|
|
@@ -1060,8 +1064,10 @@
|
|
|
1060
1064
|
else {
|
|
1061
1065
|
items.push(newItem);
|
|
1062
1066
|
}
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1067
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
1068
|
+
? params.element
|
|
1069
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
1070
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
1065
1071
|
await newItem.start();
|
|
1066
1072
|
return newItem;
|
|
1067
1073
|
}
|
|
@@ -2854,7 +2860,7 @@
|
|
|
2854
2860
|
}
|
|
2855
2861
|
|
|
2856
2862
|
async function loadCircleShape(engine) {
|
|
2857
|
-
engine.checkVersion("4.0.0
|
|
2863
|
+
engine.checkVersion("4.0.0");
|
|
2858
2864
|
await engine.pluginManager.register(e => {
|
|
2859
2865
|
e.pluginManager.addShape(["circle"], () => {
|
|
2860
2866
|
return Promise.resolve(new CircleDrawer());
|
|
@@ -2902,7 +2908,7 @@
|
|
|
2902
2908
|
}
|
|
2903
2909
|
|
|
2904
2910
|
async function loadHexColorPlugin(engine) {
|
|
2905
|
-
engine.checkVersion("4.0.0
|
|
2911
|
+
engine.checkVersion("4.0.0");
|
|
2906
2912
|
await engine.pluginManager.register(e => {
|
|
2907
2913
|
e.pluginManager.addColorManager("hex", new HexColorManager());
|
|
2908
2914
|
});
|
|
@@ -2955,7 +2961,7 @@
|
|
|
2955
2961
|
}
|
|
2956
2962
|
|
|
2957
2963
|
async function loadHslColorPlugin(engine) {
|
|
2958
|
-
engine.checkVersion("4.0.0
|
|
2964
|
+
engine.checkVersion("4.0.0");
|
|
2959
2965
|
await engine.pluginManager.register(e => {
|
|
2960
2966
|
e.pluginManager.addColorManager("hsl", new HslColorManager());
|
|
2961
2967
|
});
|
|
@@ -2979,7 +2985,7 @@
|
|
|
2979
2985
|
}
|
|
2980
2986
|
|
|
2981
2987
|
async function loadMovePlugin(engine) {
|
|
2982
|
-
engine.checkVersion("4.0.0
|
|
2988
|
+
engine.checkVersion("4.0.0");
|
|
2983
2989
|
await engine.pluginManager.register(e => {
|
|
2984
2990
|
const moveEngine = e, movePluginManager = moveEngine.pluginManager;
|
|
2985
2991
|
movePluginManager.initializers.pathGenerators ??= new Map();
|
|
@@ -3040,7 +3046,7 @@
|
|
|
3040
3046
|
}
|
|
3041
3047
|
|
|
3042
3048
|
async function loadOpacityUpdater(engine) {
|
|
3043
|
-
engine.checkVersion("4.0.0
|
|
3049
|
+
engine.checkVersion("4.0.0");
|
|
3044
3050
|
await engine.pluginManager.register(e => {
|
|
3045
3051
|
e.pluginManager.addParticleUpdater("opacity", container => {
|
|
3046
3052
|
return Promise.resolve(new OpacityUpdater(container));
|
|
@@ -3392,7 +3398,7 @@
|
|
|
3392
3398
|
}
|
|
3393
3399
|
|
|
3394
3400
|
async function loadOutModesUpdater(engine) {
|
|
3395
|
-
engine.checkVersion("4.0.0
|
|
3401
|
+
engine.checkVersion("4.0.0");
|
|
3396
3402
|
await engine.pluginManager.register(e => {
|
|
3397
3403
|
e.pluginManager.addParticleUpdater("outModes", container => {
|
|
3398
3404
|
return Promise.resolve(new OutOfCanvasUpdater(container));
|
|
@@ -3463,7 +3469,7 @@
|
|
|
3463
3469
|
}
|
|
3464
3470
|
|
|
3465
3471
|
async function loadPaintUpdater(engine) {
|
|
3466
|
-
engine.checkVersion("4.0.0
|
|
3472
|
+
engine.checkVersion("4.0.0");
|
|
3467
3473
|
await engine.pluginManager.register(e => {
|
|
3468
3474
|
e.pluginManager.addParticleUpdater("paint", container => {
|
|
3469
3475
|
return Promise.resolve(new PaintUpdater(e.pluginManager, container));
|
|
@@ -3518,7 +3524,7 @@
|
|
|
3518
3524
|
}
|
|
3519
3525
|
|
|
3520
3526
|
async function loadRgbColorPlugin(engine) {
|
|
3521
|
-
engine.checkVersion("4.0.0
|
|
3527
|
+
engine.checkVersion("4.0.0");
|
|
3522
3528
|
await engine.pluginManager.register(e => {
|
|
3523
3529
|
e.pluginManager.addColorManager("rgb", new RgbColorManager());
|
|
3524
3530
|
});
|
|
@@ -3561,7 +3567,7 @@
|
|
|
3561
3567
|
}
|
|
3562
3568
|
|
|
3563
3569
|
async function loadSizeUpdater(engine) {
|
|
3564
|
-
engine.checkVersion("4.0.0
|
|
3570
|
+
engine.checkVersion("4.0.0");
|
|
3565
3571
|
await engine.pluginManager.register(e => {
|
|
3566
3572
|
e.pluginManager.addParticleUpdater("size", container => {
|
|
3567
3573
|
return Promise.resolve(new SizeUpdater(container));
|
|
@@ -3570,7 +3576,7 @@
|
|
|
3570
3576
|
}
|
|
3571
3577
|
|
|
3572
3578
|
async function loadBasic(engine) {
|
|
3573
|
-
engine.checkVersion("4.0.0
|
|
3579
|
+
engine.checkVersion("4.0.0");
|
|
3574
3580
|
await engine.pluginManager.register(async (e) => {
|
|
3575
3581
|
await Promise.all([
|
|
3576
3582
|
loadHexColorPlugin(e),
|
|
@@ -3676,7 +3682,7 @@
|
|
|
3676
3682
|
}
|
|
3677
3683
|
|
|
3678
3684
|
async function loadMotionPlugin(engine) {
|
|
3679
|
-
engine.checkVersion("4.0.0
|
|
3685
|
+
engine.checkVersion("4.0.0");
|
|
3680
3686
|
await engine.pluginManager.register(e => {
|
|
3681
3687
|
e.pluginManager.addPlugin(new MotionPlugin());
|
|
3682
3688
|
});
|
|
@@ -3833,7 +3839,7 @@
|
|
|
3833
3839
|
}
|
|
3834
3840
|
|
|
3835
3841
|
async function loadRollUpdater(engine) {
|
|
3836
|
-
engine.checkVersion("4.0.0
|
|
3842
|
+
engine.checkVersion("4.0.0");
|
|
3837
3843
|
await engine.pluginManager.register(e => {
|
|
3838
3844
|
e.pluginManager.addParticleUpdater("roll", () => {
|
|
3839
3845
|
return Promise.resolve(new RollUpdater(e.pluginManager));
|
|
@@ -3967,7 +3973,7 @@
|
|
|
3967
3973
|
}
|
|
3968
3974
|
|
|
3969
3975
|
async function loadRotateUpdater(engine) {
|
|
3970
|
-
engine.checkVersion("4.0.0
|
|
3976
|
+
engine.checkVersion("4.0.0");
|
|
3971
3977
|
await engine.pluginManager.register(e => {
|
|
3972
3978
|
e.pluginManager.addParticleUpdater("rotate", container => {
|
|
3973
3979
|
return Promise.resolve(new RotateUpdater(container));
|
|
@@ -3991,7 +3997,7 @@
|
|
|
3991
3997
|
}
|
|
3992
3998
|
|
|
3993
3999
|
async function loadSquareShape(engine) {
|
|
3994
|
-
engine.checkVersion("4.0.0
|
|
4000
|
+
engine.checkVersion("4.0.0");
|
|
3995
4001
|
await engine.pluginManager.register(e => {
|
|
3996
4002
|
e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
|
|
3997
4003
|
});
|
|
@@ -4128,7 +4134,7 @@
|
|
|
4128
4134
|
}
|
|
4129
4135
|
|
|
4130
4136
|
async function loadTiltUpdater(engine) {
|
|
4131
|
-
engine.checkVersion("4.0.0
|
|
4137
|
+
engine.checkVersion("4.0.0");
|
|
4132
4138
|
await engine.pluginManager.register(e => {
|
|
4133
4139
|
e.pluginManager.addParticleUpdater("tilt", container => {
|
|
4134
4140
|
return Promise.resolve(new TiltUpdater(container));
|
|
@@ -4250,7 +4256,7 @@
|
|
|
4250
4256
|
}
|
|
4251
4257
|
|
|
4252
4258
|
async function loadWobbleUpdater(engine) {
|
|
4253
|
-
engine.checkVersion("4.0.0
|
|
4259
|
+
engine.checkVersion("4.0.0");
|
|
4254
4260
|
await engine.pluginManager.register(e => {
|
|
4255
4261
|
e.pluginManager.addParticleUpdater("wobble", container => {
|
|
4256
4262
|
return Promise.resolve(new WobbleUpdater(container));
|
|
@@ -4670,6 +4676,25 @@
|
|
|
4670
4676
|
};
|
|
4671
4677
|
}
|
|
4672
4678
|
|
|
4679
|
+
const transferredCanvases = new WeakMap(), getTransferredCanvas = (canvas) => {
|
|
4680
|
+
const transferredCanvas = transferredCanvases.get(canvas);
|
|
4681
|
+
if (transferredCanvas) {
|
|
4682
|
+
return transferredCanvas;
|
|
4683
|
+
}
|
|
4684
|
+
if (typeof canvas.transferControlToOffscreen !== "function") {
|
|
4685
|
+
throw new TypeError("OffscreenCanvas is required but not supported by this browser");
|
|
4686
|
+
}
|
|
4687
|
+
try {
|
|
4688
|
+
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
4689
|
+
transferredCanvases.set(canvas, offscreenCanvas);
|
|
4690
|
+
return offscreenCanvas;
|
|
4691
|
+
}
|
|
4692
|
+
catch {
|
|
4693
|
+
throw new TypeError("OffscreenCanvas transfer failed");
|
|
4694
|
+
}
|
|
4695
|
+
}, isHtmlCanvasElement = (canvas) => {
|
|
4696
|
+
return typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement;
|
|
4697
|
+
};
|
|
4673
4698
|
function setStyle(canvas, style, important = false) {
|
|
4674
4699
|
if (!style) {
|
|
4675
4700
|
return;
|
|
@@ -4700,8 +4725,9 @@
|
|
|
4700
4725
|
}
|
|
4701
4726
|
}
|
|
4702
4727
|
class CanvasManager {
|
|
4703
|
-
|
|
4728
|
+
domElement;
|
|
4704
4729
|
render;
|
|
4730
|
+
renderCanvas;
|
|
4705
4731
|
size;
|
|
4706
4732
|
zoom = defaultZoom;
|
|
4707
4733
|
_container;
|
|
@@ -4736,9 +4762,10 @@
|
|
|
4736
4762
|
destroy() {
|
|
4737
4763
|
this.stop();
|
|
4738
4764
|
if (this._generated) {
|
|
4739
|
-
const element = this.
|
|
4765
|
+
const element = this.domElement;
|
|
4740
4766
|
element?.remove();
|
|
4741
|
-
this.
|
|
4767
|
+
this.domElement = undefined;
|
|
4768
|
+
this.renderCanvas = undefined;
|
|
4742
4769
|
}
|
|
4743
4770
|
else {
|
|
4744
4771
|
this._resetOriginalStyle();
|
|
@@ -4771,16 +4798,17 @@
|
|
|
4771
4798
|
this._initStyle();
|
|
4772
4799
|
this.initBackground();
|
|
4773
4800
|
this._safeMutationObserver(obs => {
|
|
4774
|
-
|
|
4801
|
+
const element = this.domElement;
|
|
4802
|
+
if (!element || !(element instanceof Node)) {
|
|
4775
4803
|
return;
|
|
4776
4804
|
}
|
|
4777
|
-
obs.observe(
|
|
4805
|
+
obs.observe(element, { attributes: true });
|
|
4778
4806
|
});
|
|
4779
4807
|
this.initPlugins();
|
|
4780
4808
|
this.render.init();
|
|
4781
4809
|
}
|
|
4782
4810
|
initBackground() {
|
|
4783
|
-
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.
|
|
4811
|
+
const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
|
|
4784
4812
|
if (!element) {
|
|
4785
4813
|
return;
|
|
4786
4814
|
}
|
|
@@ -4805,21 +4833,30 @@
|
|
|
4805
4833
|
}
|
|
4806
4834
|
}
|
|
4807
4835
|
loadCanvas(canvas) {
|
|
4808
|
-
if (this._generated && this.
|
|
4809
|
-
this.
|
|
4836
|
+
if (this._generated && this.domElement) {
|
|
4837
|
+
this.domElement.remove();
|
|
4838
|
+
}
|
|
4839
|
+
const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
|
|
4840
|
+
this.domElement = domCanvas;
|
|
4841
|
+
this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
|
|
4842
|
+
this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
|
|
4843
|
+
const domElement = this.domElement;
|
|
4844
|
+
if (domElement) {
|
|
4845
|
+
domElement.ariaHidden = "true";
|
|
4846
|
+
this._originalStyle = cloneStyle(domElement.style);
|
|
4847
|
+
}
|
|
4848
|
+
const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
|
|
4849
|
+
if (domElement) {
|
|
4850
|
+
standardSize.height = domElement.offsetHeight;
|
|
4851
|
+
standardSize.width = domElement.offsetWidth;
|
|
4852
|
+
}
|
|
4853
|
+
else {
|
|
4854
|
+
standardSize.height = renderCanvas.height;
|
|
4855
|
+
standardSize.width = renderCanvas.width;
|
|
4810
4856
|
}
|
|
4811
|
-
const container = this._container;
|
|
4812
|
-
this._generated =
|
|
4813
|
-
generatedAttribute in canvas.dataset ? canvas.dataset[generatedAttribute] === "true" : this._generated;
|
|
4814
|
-
this.element = canvas;
|
|
4815
|
-
this.element.ariaHidden = "true";
|
|
4816
|
-
this._originalStyle = cloneStyle(this.element.style);
|
|
4817
|
-
const standardSize = this._standardSize;
|
|
4818
|
-
standardSize.height = canvas.offsetHeight;
|
|
4819
|
-
standardSize.width = canvas.offsetWidth;
|
|
4820
4857
|
const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
|
|
4821
|
-
|
|
4822
|
-
|
|
4858
|
+
renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
4859
|
+
renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
4823
4860
|
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
4824
4861
|
this.render.setContextSettings({
|
|
4825
4862
|
alpha: true,
|
|
@@ -4827,42 +4864,48 @@
|
|
|
4827
4864
|
desynchronized: true,
|
|
4828
4865
|
willReadFrequently: false,
|
|
4829
4866
|
});
|
|
4830
|
-
this.render.setContext(
|
|
4867
|
+
this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
|
|
4831
4868
|
this._safeMutationObserver(obs => {
|
|
4832
4869
|
obs.disconnect();
|
|
4833
4870
|
});
|
|
4834
4871
|
container.retina.init();
|
|
4835
4872
|
this.initBackground();
|
|
4836
4873
|
this._safeMutationObserver(obs => {
|
|
4837
|
-
|
|
4874
|
+
const element = this.domElement;
|
|
4875
|
+
if (!element || !(element instanceof Node)) {
|
|
4838
4876
|
return;
|
|
4839
4877
|
}
|
|
4840
|
-
obs.observe(
|
|
4878
|
+
obs.observe(element, { attributes: true });
|
|
4841
4879
|
});
|
|
4842
4880
|
}
|
|
4843
4881
|
resize() {
|
|
4844
|
-
|
|
4882
|
+
const element = this.domElement;
|
|
4883
|
+
if (!element) {
|
|
4884
|
+
return false;
|
|
4885
|
+
}
|
|
4886
|
+
const container = this._container, renderCanvas = this.renderCanvas;
|
|
4887
|
+
if (renderCanvas === undefined) {
|
|
4845
4888
|
return false;
|
|
4846
4889
|
}
|
|
4847
|
-
const
|
|
4848
|
-
width:
|
|
4849
|
-
height:
|
|
4890
|
+
const currentSize = container.canvas._standardSize, newSize = {
|
|
4891
|
+
width: element.offsetWidth,
|
|
4892
|
+
height: element.offsetHeight,
|
|
4850
4893
|
}, pxRatio = container.retina.pixelRatio, retinaSize = {
|
|
4851
4894
|
width: newSize.width * pxRatio,
|
|
4852
4895
|
height: newSize.height * pxRatio,
|
|
4853
4896
|
};
|
|
4854
4897
|
if (newSize.height === currentSize.height &&
|
|
4855
4898
|
newSize.width === currentSize.width &&
|
|
4856
|
-
retinaSize.height ===
|
|
4857
|
-
retinaSize.width ===
|
|
4899
|
+
retinaSize.height === renderCanvas.height &&
|
|
4900
|
+
retinaSize.width === renderCanvas.width) {
|
|
4858
4901
|
return false;
|
|
4859
4902
|
}
|
|
4860
4903
|
const oldSize = { ...currentSize };
|
|
4861
4904
|
currentSize.height = newSize.height;
|
|
4862
4905
|
currentSize.width = newSize.width;
|
|
4863
4906
|
const canvasSize = this.size;
|
|
4864
|
-
|
|
4865
|
-
|
|
4907
|
+
renderCanvas.width = canvasSize.width = retinaSize.width;
|
|
4908
|
+
renderCanvas.height = canvasSize.height = retinaSize.height;
|
|
4866
4909
|
if (this._container.started) {
|
|
4867
4910
|
container.particles.setResizeFactor({
|
|
4868
4911
|
width: currentSize.width / oldSize.width,
|
|
@@ -4872,7 +4915,7 @@
|
|
|
4872
4915
|
return true;
|
|
4873
4916
|
}
|
|
4874
4917
|
setPointerEvents(type) {
|
|
4875
|
-
const element = this.
|
|
4918
|
+
const element = this.domElement;
|
|
4876
4919
|
if (!element) {
|
|
4877
4920
|
return;
|
|
4878
4921
|
}
|
|
@@ -4891,7 +4934,7 @@
|
|
|
4891
4934
|
this.render.stop();
|
|
4892
4935
|
}
|
|
4893
4936
|
async windowResize() {
|
|
4894
|
-
if (!this.
|
|
4937
|
+
if (!this.domElement || !this.resize()) {
|
|
4895
4938
|
return;
|
|
4896
4939
|
}
|
|
4897
4940
|
const container = this._container, needsRefresh = container.updateActualOptions();
|
|
@@ -4907,7 +4950,7 @@
|
|
|
4907
4950
|
}
|
|
4908
4951
|
};
|
|
4909
4952
|
_initStyle = () => {
|
|
4910
|
-
const element = this.
|
|
4953
|
+
const element = this.domElement, options = this._container.actualOptions;
|
|
4911
4954
|
if (!element) {
|
|
4912
4955
|
return;
|
|
4913
4956
|
}
|
|
@@ -4929,7 +4972,7 @@
|
|
|
4929
4972
|
}
|
|
4930
4973
|
};
|
|
4931
4974
|
_repairStyle = () => {
|
|
4932
|
-
const element = this.
|
|
4975
|
+
const element = this.domElement;
|
|
4933
4976
|
if (!element) {
|
|
4934
4977
|
return;
|
|
4935
4978
|
}
|
|
@@ -4949,7 +4992,7 @@
|
|
|
4949
4992
|
});
|
|
4950
4993
|
};
|
|
4951
4994
|
_resetOriginalStyle = () => {
|
|
4952
|
-
const element = this.
|
|
4995
|
+
const element = this.domElement, originalStyle = this._originalStyle;
|
|
4953
4996
|
if (!element || !originalStyle) {
|
|
4954
4997
|
return;
|
|
4955
4998
|
}
|
|
@@ -4962,7 +5005,7 @@
|
|
|
4962
5005
|
callback(this._mutationObserver);
|
|
4963
5006
|
};
|
|
4964
5007
|
_setFullScreenStyle = () => {
|
|
4965
|
-
const element = this.
|
|
5008
|
+
const element = this.domElement;
|
|
4966
5009
|
if (!element) {
|
|
4967
5010
|
return;
|
|
4968
5011
|
}
|
|
@@ -5036,7 +5079,7 @@
|
|
|
5036
5079
|
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
5037
5080
|
return;
|
|
5038
5081
|
}
|
|
5039
|
-
const canvasEl = container.canvas.
|
|
5082
|
+
const canvasEl = container.canvas.domElement;
|
|
5040
5083
|
if (this._resizeObserver && !add) {
|
|
5041
5084
|
if (canvasEl) {
|
|
5042
5085
|
this._resizeObserver.unobserve(canvasEl);
|
|
@@ -5291,8 +5334,6 @@
|
|
|
5291
5334
|
this._initPosition(position);
|
|
5292
5335
|
this.initialVelocity = this._calculateVelocity();
|
|
5293
5336
|
this.velocity = this.initialVelocity.copy();
|
|
5294
|
-
const particles = container.particles;
|
|
5295
|
-
particles.setLastZIndex(this.position.z);
|
|
5296
5337
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
5297
5338
|
this.sides = 24;
|
|
5298
5339
|
let effectDrawer, shapeDrawer;
|
|
@@ -5442,7 +5483,7 @@
|
|
|
5442
5483
|
return color;
|
|
5443
5484
|
};
|
|
5444
5485
|
_initPosition = position => {
|
|
5445
|
-
const container = this._container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5486
|
+
const container = this._container, zIndexValue = Math.floor(getRangeValue(this.options.zIndex.value)), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
5446
5487
|
if (!initialPosition) {
|
|
5447
5488
|
throw new Error("a valid position cannot be found for particle");
|
|
5448
5489
|
}
|
|
@@ -5576,10 +5617,8 @@
|
|
|
5576
5617
|
_container;
|
|
5577
5618
|
_groupLimits;
|
|
5578
5619
|
_limit;
|
|
5579
|
-
_maxZIndex;
|
|
5580
|
-
_minZIndex;
|
|
5581
|
-
_needsSort;
|
|
5582
5620
|
_nextId;
|
|
5621
|
+
_particleBuckets;
|
|
5583
5622
|
_particleResetPlugins;
|
|
5584
5623
|
_particleUpdatePlugins;
|
|
5585
5624
|
_pluginManager;
|
|
@@ -5588,19 +5627,17 @@
|
|
|
5588
5627
|
_postUpdatePlugins;
|
|
5589
5628
|
_resizeFactor;
|
|
5590
5629
|
_updatePlugins;
|
|
5591
|
-
|
|
5630
|
+
_zBuckets;
|
|
5592
5631
|
constructor(pluginManager, container) {
|
|
5593
5632
|
this._pluginManager = pluginManager;
|
|
5594
5633
|
this._container = container;
|
|
5595
5634
|
this._nextId = 0;
|
|
5596
5635
|
this._array = [];
|
|
5597
|
-
this._zArray = [];
|
|
5598
5636
|
this._pool = [];
|
|
5599
5637
|
this._limit = 0;
|
|
5600
5638
|
this._groupLimits = new Map();
|
|
5601
|
-
this.
|
|
5602
|
-
this.
|
|
5603
|
-
this._maxZIndex = 0;
|
|
5639
|
+
this._particleBuckets = new Map();
|
|
5640
|
+
this._zBuckets = this._createBuckets(this._container.zLayers);
|
|
5604
5641
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize);
|
|
5605
5642
|
this.checkParticlePositionPlugins = [];
|
|
5606
5643
|
this._particleResetPlugins = [];
|
|
@@ -5642,7 +5679,7 @@
|
|
|
5642
5679
|
return;
|
|
5643
5680
|
}
|
|
5644
5681
|
this._array.push(particle);
|
|
5645
|
-
this.
|
|
5682
|
+
this._insertParticleIntoBucket(particle);
|
|
5646
5683
|
this._nextId++;
|
|
5647
5684
|
this._container.dispatchEvent(EventType.particleAdded, {
|
|
5648
5685
|
particle,
|
|
@@ -5656,12 +5693,14 @@
|
|
|
5656
5693
|
}
|
|
5657
5694
|
clear() {
|
|
5658
5695
|
this._array = [];
|
|
5659
|
-
this.
|
|
5696
|
+
this._particleBuckets.clear();
|
|
5697
|
+
this._resetBuckets(this._container.zLayers);
|
|
5660
5698
|
}
|
|
5661
5699
|
destroy() {
|
|
5662
5700
|
this._array = [];
|
|
5663
5701
|
this._pool.length = 0;
|
|
5664
|
-
this.
|
|
5702
|
+
this._particleBuckets.clear();
|
|
5703
|
+
this._zBuckets = [];
|
|
5665
5704
|
this.checkParticlePositionPlugins = [];
|
|
5666
5705
|
this._particleResetPlugins = [];
|
|
5667
5706
|
this._particleUpdatePlugins = [];
|
|
@@ -5670,8 +5709,14 @@
|
|
|
5670
5709
|
this._updatePlugins = [];
|
|
5671
5710
|
}
|
|
5672
5711
|
drawParticles(delta) {
|
|
5673
|
-
for (
|
|
5674
|
-
|
|
5712
|
+
for (let i = this._zBuckets.length - one; i >= minIndex; i--) {
|
|
5713
|
+
const bucket = this._zBuckets[i];
|
|
5714
|
+
if (!bucket) {
|
|
5715
|
+
continue;
|
|
5716
|
+
}
|
|
5717
|
+
for (const particle of bucket) {
|
|
5718
|
+
particle.draw(delta);
|
|
5719
|
+
}
|
|
5675
5720
|
}
|
|
5676
5721
|
}
|
|
5677
5722
|
filter(condition) {
|
|
@@ -5685,15 +5730,14 @@
|
|
|
5685
5730
|
}
|
|
5686
5731
|
async init() {
|
|
5687
5732
|
const container = this._container, options = container.actualOptions;
|
|
5688
|
-
this._minZIndex = 0;
|
|
5689
|
-
this._maxZIndex = 0;
|
|
5690
|
-
this._needsSort = false;
|
|
5691
5733
|
this.checkParticlePositionPlugins = [];
|
|
5692
5734
|
this._updatePlugins = [];
|
|
5693
5735
|
this._particleUpdatePlugins = [];
|
|
5694
5736
|
this._postUpdatePlugins = [];
|
|
5695
5737
|
this._particleResetPlugins = [];
|
|
5696
5738
|
this._postParticleUpdatePlugins = [];
|
|
5739
|
+
this._particleBuckets.clear();
|
|
5740
|
+
this._resetBuckets(container.zLayers);
|
|
5697
5741
|
this.grid = new SpatialHashGrid(spatialHashGridCellSize * container.retina.pixelRatio);
|
|
5698
5742
|
for (const plugin of container.plugins) {
|
|
5699
5743
|
if (plugin.redrawInit) {
|
|
@@ -5794,79 +5838,25 @@
|
|
|
5794
5838
|
}
|
|
5795
5839
|
this._applyDensity(options.particles, pluginsCount);
|
|
5796
5840
|
}
|
|
5797
|
-
setLastZIndex(zIndex) {
|
|
5798
|
-
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
5799
|
-
}
|
|
5800
5841
|
setResizeFactor(factor) {
|
|
5801
5842
|
this._resizeFactor = factor;
|
|
5802
5843
|
}
|
|
5803
5844
|
update(delta) {
|
|
5804
|
-
const particlesToDelete = new Set();
|
|
5805
5845
|
this.grid.clear();
|
|
5806
5846
|
for (const plugin of this._updatePlugins) {
|
|
5807
5847
|
plugin.update?.(delta);
|
|
5808
5848
|
}
|
|
5809
|
-
const
|
|
5810
|
-
for (const particle of this._array) {
|
|
5811
|
-
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
5812
|
-
particle.position.x *= resizeFactor.width;
|
|
5813
|
-
particle.position.y *= resizeFactor.height;
|
|
5814
|
-
particle.initialPosition.x *= resizeFactor.width;
|
|
5815
|
-
particle.initialPosition.y *= resizeFactor.height;
|
|
5816
|
-
}
|
|
5817
|
-
particle.ignoresResizeRatio = false;
|
|
5818
|
-
for (const plugin of this._particleResetPlugins) {
|
|
5819
|
-
plugin.particleReset?.(particle);
|
|
5820
|
-
}
|
|
5821
|
-
for (const plugin of this._particleUpdatePlugins) {
|
|
5822
|
-
if (particle.destroyed) {
|
|
5823
|
-
break;
|
|
5824
|
-
}
|
|
5825
|
-
plugin.particleUpdate?.(particle, delta);
|
|
5826
|
-
}
|
|
5827
|
-
if (particle.destroyed) {
|
|
5828
|
-
particlesToDelete.add(particle);
|
|
5829
|
-
continue;
|
|
5830
|
-
}
|
|
5831
|
-
this.grid.insert(particle);
|
|
5832
|
-
}
|
|
5849
|
+
const particlesToDelete = this._updateParticlesPhase1(delta);
|
|
5833
5850
|
for (const plugin of this._postUpdatePlugins) {
|
|
5834
5851
|
plugin.postUpdate?.(delta);
|
|
5835
5852
|
}
|
|
5836
|
-
|
|
5837
|
-
if (particle.destroyed) {
|
|
5838
|
-
particlesToDelete.add(particle);
|
|
5839
|
-
continue;
|
|
5840
|
-
}
|
|
5841
|
-
for (const updater of this._container.particleUpdaters) {
|
|
5842
|
-
updater.update(particle, delta);
|
|
5843
|
-
}
|
|
5844
|
-
if (!particle.destroyed && !particle.spawning) {
|
|
5845
|
-
for (const plugin of this._postParticleUpdatePlugins) {
|
|
5846
|
-
plugin.postParticleUpdate?.(particle, delta);
|
|
5847
|
-
}
|
|
5848
|
-
}
|
|
5849
|
-
else if (particle.destroyed) {
|
|
5850
|
-
particlesToDelete.add(particle);
|
|
5851
|
-
}
|
|
5852
|
-
}
|
|
5853
|
+
this._updateParticlesPhase2(delta, particlesToDelete);
|
|
5853
5854
|
if (particlesToDelete.size) {
|
|
5854
5855
|
for (const particle of particlesToDelete) {
|
|
5855
5856
|
this.remove(particle);
|
|
5856
5857
|
}
|
|
5857
5858
|
}
|
|
5858
5859
|
delete this._resizeFactor;
|
|
5859
|
-
if (this._needsSort) {
|
|
5860
|
-
const zArray = this._zArray;
|
|
5861
|
-
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
5862
|
-
const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
|
|
5863
|
-
if (!firstItem || !lastItem) {
|
|
5864
|
-
return;
|
|
5865
|
-
}
|
|
5866
|
-
this._maxZIndex = firstItem.position.z;
|
|
5867
|
-
this._minZIndex = lastItem.position.z;
|
|
5868
|
-
this._needsSort = false;
|
|
5869
|
-
}
|
|
5870
5860
|
}
|
|
5871
5861
|
_addToPool = (...particles) => {
|
|
5872
5862
|
this._pool.push(...particles);
|
|
@@ -5896,13 +5886,52 @@
|
|
|
5896
5886
|
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
5897
5887
|
}
|
|
5898
5888
|
};
|
|
5889
|
+
_createBuckets = (zLayers) => {
|
|
5890
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5891
|
+
return Array.from({ length: bucketCount }, () => []);
|
|
5892
|
+
};
|
|
5893
|
+
_getBucketIndex = (zIndex) => {
|
|
5894
|
+
const maxBucketIndex = this._zBuckets.length - one;
|
|
5895
|
+
if (maxBucketIndex <= minIndex) {
|
|
5896
|
+
return minIndex;
|
|
5897
|
+
}
|
|
5898
|
+
return Math.min(Math.max(Math.floor(zIndex), minIndex), maxBucketIndex);
|
|
5899
|
+
};
|
|
5900
|
+
_getParticleInsertIndex = (bucket, particleId) => {
|
|
5901
|
+
let start = minIndex, end = bucket.length;
|
|
5902
|
+
while (start < end) {
|
|
5903
|
+
const middle = Math.floor((start + end) / double), middleParticle = bucket[middle];
|
|
5904
|
+
if (!middleParticle) {
|
|
5905
|
+
end = middle;
|
|
5906
|
+
continue;
|
|
5907
|
+
}
|
|
5908
|
+
if (middleParticle.id < particleId) {
|
|
5909
|
+
start = middle + one;
|
|
5910
|
+
}
|
|
5911
|
+
else {
|
|
5912
|
+
end = middle;
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
return start;
|
|
5916
|
+
};
|
|
5899
5917
|
_initDensityFactor = densityOptions => {
|
|
5900
5918
|
const container = this._container;
|
|
5901
|
-
if (!
|
|
5919
|
+
if (!densityOptions.enable) {
|
|
5920
|
+
return defaultDensityFactor;
|
|
5921
|
+
}
|
|
5922
|
+
const canvasSize = container.canvas.size, pxRatio = container.retina.pixelRatio;
|
|
5923
|
+
if (!canvasSize.width || !canvasSize.height) {
|
|
5902
5924
|
return defaultDensityFactor;
|
|
5903
5925
|
}
|
|
5904
|
-
|
|
5905
|
-
|
|
5926
|
+
return ((canvasSize.width * canvasSize.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp));
|
|
5927
|
+
};
|
|
5928
|
+
_insertParticleIntoBucket = (particle) => {
|
|
5929
|
+
const bucketIndex = this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
5930
|
+
if (!bucket) {
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5933
|
+
bucket.splice(this._getParticleInsertIndex(bucket, particle.id), empty, particle);
|
|
5934
|
+
this._particleBuckets.set(particle.id, bucketIndex);
|
|
5906
5935
|
};
|
|
5907
5936
|
_removeParticle = (index, group, override) => {
|
|
5908
5937
|
const particle = this._array[index];
|
|
@@ -5912,9 +5941,8 @@
|
|
|
5912
5941
|
if (particle.group !== group) {
|
|
5913
5942
|
return false;
|
|
5914
5943
|
}
|
|
5915
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
5916
5944
|
this._array.splice(index, deleteCount);
|
|
5917
|
-
this.
|
|
5945
|
+
this._removeParticleFromBucket(particle);
|
|
5918
5946
|
particle.destroy(override);
|
|
5919
5947
|
this._container.dispatchEvent(EventType.particleRemoved, {
|
|
5920
5948
|
particle,
|
|
@@ -5922,6 +5950,98 @@
|
|
|
5922
5950
|
this._addToPool(particle);
|
|
5923
5951
|
return true;
|
|
5924
5952
|
};
|
|
5953
|
+
_removeParticleFromBucket = (particle) => {
|
|
5954
|
+
const bucketIndex = this._particleBuckets.get(particle.id) ?? this._getBucketIndex(particle.position.z), bucket = this._zBuckets[bucketIndex];
|
|
5955
|
+
if (!bucket) {
|
|
5956
|
+
this._particleBuckets.delete(particle.id);
|
|
5957
|
+
return;
|
|
5958
|
+
}
|
|
5959
|
+
const particleIndex = this._getParticleInsertIndex(bucket, particle.id);
|
|
5960
|
+
if (bucket[particleIndex]?.id !== particle.id) {
|
|
5961
|
+
this._particleBuckets.delete(particle.id);
|
|
5962
|
+
return;
|
|
5963
|
+
}
|
|
5964
|
+
bucket.splice(particleIndex, deleteCount);
|
|
5965
|
+
this._particleBuckets.delete(particle.id);
|
|
5966
|
+
};
|
|
5967
|
+
_resetBuckets = (zLayers) => {
|
|
5968
|
+
const bucketCount = Math.max(Math.floor(zLayers), one);
|
|
5969
|
+
if (this._zBuckets.length !== bucketCount) {
|
|
5970
|
+
this._zBuckets = this._createBuckets(bucketCount);
|
|
5971
|
+
return;
|
|
5972
|
+
}
|
|
5973
|
+
for (const bucket of this._zBuckets) {
|
|
5974
|
+
bucket.length = minIndex;
|
|
5975
|
+
}
|
|
5976
|
+
};
|
|
5977
|
+
_updateParticleBucket = (particle) => {
|
|
5978
|
+
const newBucketIndex = this._getBucketIndex(particle.position.z), currentBucketIndex = this._particleBuckets.get(particle.id);
|
|
5979
|
+
if (currentBucketIndex === undefined) {
|
|
5980
|
+
this._insertParticleIntoBucket(particle);
|
|
5981
|
+
return;
|
|
5982
|
+
}
|
|
5983
|
+
if (currentBucketIndex === newBucketIndex) {
|
|
5984
|
+
return;
|
|
5985
|
+
}
|
|
5986
|
+
const currentBucket = this._zBuckets[currentBucketIndex];
|
|
5987
|
+
if (currentBucket) {
|
|
5988
|
+
const particleIndex = this._getParticleInsertIndex(currentBucket, particle.id);
|
|
5989
|
+
if (currentBucket[particleIndex]?.id === particle.id) {
|
|
5990
|
+
currentBucket.splice(particleIndex, deleteCount);
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
const newBucket = this._zBuckets[newBucketIndex];
|
|
5994
|
+
if (!newBucket) {
|
|
5995
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
5996
|
+
return;
|
|
5997
|
+
}
|
|
5998
|
+
newBucket.splice(this._getParticleInsertIndex(newBucket, particle.id), empty, particle);
|
|
5999
|
+
this._particleBuckets.set(particle.id, newBucketIndex);
|
|
6000
|
+
};
|
|
6001
|
+
_updateParticlesPhase1 = (delta) => {
|
|
6002
|
+
const particlesToDelete = new Set(), resizeFactor = this._resizeFactor;
|
|
6003
|
+
for (const particle of this._array) {
|
|
6004
|
+
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
6005
|
+
particle.position.x *= resizeFactor.width;
|
|
6006
|
+
particle.position.y *= resizeFactor.height;
|
|
6007
|
+
particle.initialPosition.x *= resizeFactor.width;
|
|
6008
|
+
particle.initialPosition.y *= resizeFactor.height;
|
|
6009
|
+
}
|
|
6010
|
+
particle.ignoresResizeRatio = false;
|
|
6011
|
+
for (const plugin of this._particleResetPlugins) {
|
|
6012
|
+
plugin.particleReset?.(particle);
|
|
6013
|
+
}
|
|
6014
|
+
for (const plugin of this._particleUpdatePlugins) {
|
|
6015
|
+
if (particle.destroyed) {
|
|
6016
|
+
break;
|
|
6017
|
+
}
|
|
6018
|
+
plugin.particleUpdate?.(particle, delta);
|
|
6019
|
+
}
|
|
6020
|
+
if (particle.destroyed) {
|
|
6021
|
+
particlesToDelete.add(particle);
|
|
6022
|
+
continue;
|
|
6023
|
+
}
|
|
6024
|
+
this.grid.insert(particle);
|
|
6025
|
+
}
|
|
6026
|
+
return particlesToDelete;
|
|
6027
|
+
};
|
|
6028
|
+
_updateParticlesPhase2 = (delta, particlesToDelete) => {
|
|
6029
|
+
for (const particle of this._array) {
|
|
6030
|
+
if (particle.destroyed) {
|
|
6031
|
+
particlesToDelete.add(particle);
|
|
6032
|
+
continue;
|
|
6033
|
+
}
|
|
6034
|
+
for (const updater of this._container.particleUpdaters) {
|
|
6035
|
+
updater.update(particle, delta);
|
|
6036
|
+
}
|
|
6037
|
+
if (!particle.spawning) {
|
|
6038
|
+
for (const plugin of this._postParticleUpdatePlugins) {
|
|
6039
|
+
plugin.postParticleUpdate?.(particle, delta);
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
this._updateParticleBucket(particle);
|
|
6043
|
+
}
|
|
6044
|
+
};
|
|
5925
6045
|
}
|
|
5926
6046
|
|
|
5927
6047
|
class Retina {
|
|
@@ -5937,9 +6057,8 @@
|
|
|
5937
6057
|
const container = this.container, options = container.actualOptions;
|
|
5938
6058
|
this.pixelRatio = options.detectRetina ? devicePixelRatio : defaultRatio;
|
|
5939
6059
|
this.reduceFactor = defaultReduceFactor;
|
|
5940
|
-
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
5941
|
-
if (
|
|
5942
|
-
const element = canvas.element;
|
|
6060
|
+
const ratio = this.pixelRatio, canvas = container.canvas, element = canvas.domElement;
|
|
6061
|
+
if (element) {
|
|
5943
6062
|
canvas.size.width = element.offsetWidth * ratio;
|
|
5944
6063
|
canvas.size.height = element.offsetHeight * ratio;
|
|
5945
6064
|
}
|