@tsparticles/engine 4.0.0-alpha.1 → 4.0.0-alpha.14
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.
- package/219.min.js +1 -0
- package/README.md +2 -5
- package/browser/Core/Canvas.js +238 -154
- package/browser/Core/Container.js +111 -227
- package/browser/Core/Engine.js +84 -124
- package/browser/Core/Particle.js +236 -140
- package/browser/Core/Particles.js +212 -123
- package/browser/Core/Retina.js +5 -0
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +69 -310
- package/browser/Core/Utils/Point.js +2 -0
- package/browser/Core/Utils/QuadTree.js +13 -8
- package/browser/Core/Utils/Ranges.js +4 -0
- package/browser/Core/Utils/Vectors.js +7 -4
- package/browser/Enums/Types/EasingType.js +18 -3
- package/browser/Options/Classes/AnimatableColor.js +1 -0
- package/browser/Options/Classes/AnimationOptions.js +8 -0
- package/browser/Options/Classes/Background/Background.js +6 -0
- package/browser/Options/Classes/ColorAnimation.js +1 -0
- package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/browser/Options/Classes/HslAnimation.js +3 -5
- package/browser/Options/Classes/Options.js +32 -78
- package/browser/Options/Classes/OptionsColor.js +1 -0
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/browser/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/browser/Options/Classes/Particles/Move/Move.js +18 -0
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/browser/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/browser/Options/Classes/Particles/Size/Size.js +1 -0
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/browser/Options/Classes/Particles/Stroke.js +3 -0
- package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +3 -1
- package/browser/Options/Classes/ValueWithRandom.js +3 -4
- package/browser/Utils/CanvasUtils.js +31 -106
- package/browser/Utils/ColorUtils.js +17 -2
- package/browser/Utils/EventDispatcher.js +1 -0
- package/browser/Utils/MathUtils.js +3 -2
- package/browser/Utils/Utils.js +53 -44
- package/browser/exports.js +1 -21
- package/cjs/Core/Canvas.js +238 -154
- package/cjs/Core/Container.js +111 -227
- package/cjs/Core/Engine.js +84 -124
- package/cjs/Core/Particle.js +236 -140
- package/cjs/Core/Particles.js +212 -123
- package/cjs/Core/Retina.js +5 -0
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +69 -310
- package/cjs/Core/Utils/Point.js +2 -0
- package/cjs/Core/Utils/QuadTree.js +13 -8
- package/cjs/Core/Utils/Ranges.js +4 -0
- package/cjs/Core/Utils/Vectors.js +7 -4
- package/cjs/Enums/Types/EasingType.js +18 -3
- package/cjs/Options/Classes/AnimatableColor.js +1 -0
- package/cjs/Options/Classes/AnimationOptions.js +8 -0
- package/cjs/Options/Classes/Background/Background.js +6 -0
- package/cjs/Options/Classes/ColorAnimation.js +1 -0
- package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/cjs/Options/Classes/HslAnimation.js +3 -5
- package/cjs/Options/Classes/Options.js +32 -78
- package/cjs/Options/Classes/OptionsColor.js +1 -0
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/cjs/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +18 -0
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/cjs/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/Stroke.js +3 -0
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +3 -1
- package/cjs/Options/Classes/ValueWithRandom.js +3 -4
- package/cjs/Utils/CanvasUtils.js +31 -106
- package/cjs/Utils/ColorUtils.js +17 -2
- package/cjs/Utils/EventDispatcher.js +1 -0
- package/cjs/Utils/MathUtils.js +3 -2
- package/cjs/Utils/Utils.js +53 -44
- package/cjs/exports.js +1 -21
- package/dist_browser_Core_Container_js.js +8 -18
- package/esm/Core/Canvas.js +238 -154
- package/esm/Core/Container.js +111 -227
- package/esm/Core/Engine.js +84 -124
- package/esm/Core/Particle.js +236 -140
- package/esm/Core/Particles.js +212 -123
- package/esm/Core/Retina.js +5 -0
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +69 -310
- package/esm/Core/Utils/Point.js +2 -0
- package/esm/Core/Utils/QuadTree.js +13 -8
- package/esm/Core/Utils/Ranges.js +4 -0
- package/esm/Core/Utils/Vectors.js +7 -4
- package/esm/Enums/Types/EasingType.js +18 -3
- package/esm/Options/Classes/AnimatableColor.js +1 -0
- package/esm/Options/Classes/AnimationOptions.js +8 -0
- package/esm/Options/Classes/Background/Background.js +6 -0
- package/esm/Options/Classes/ColorAnimation.js +1 -0
- package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/esm/Options/Classes/HslAnimation.js +3 -5
- package/esm/Options/Classes/Options.js +32 -78
- package/esm/Options/Classes/OptionsColor.js +1 -0
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/esm/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/esm/Options/Classes/Particles/Move/Move.js +18 -0
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/esm/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/esm/Options/Classes/Particles/Size/Size.js +1 -0
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/esm/Options/Classes/Particles/Stroke.js +3 -0
- package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +3 -1
- package/esm/Options/Classes/ValueWithRandom.js +3 -4
- package/esm/Utils/CanvasUtils.js +31 -106
- package/esm/Utils/ColorUtils.js +17 -2
- package/esm/Utils/EventDispatcher.js +1 -0
- package/esm/Utils/MathUtils.js +3 -2
- package/esm/Utils/Utils.js +53 -44
- package/esm/exports.js +1 -21
- package/package.json +1 -1
- package/report.html +3 -3
- package/scripts/install.js +28 -9
- package/tsparticles.engine.js +67 -247
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Canvas.d.ts +15 -4
- package/types/Core/Container.d.ts +5 -20
- package/types/Core/Engine.d.ts +18 -32
- package/types/Core/Interfaces/IColorManager.d.ts +0 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +12 -2
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +1 -2
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleRotateData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleTransformValues.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +1 -1
- package/types/Core/Interfaces/IPlugin.d.ts +5 -1
- package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
- package/types/Core/Particle.d.ts +13 -2
- package/types/Core/Particles.d.ts +17 -8
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +0 -14
- package/types/Enums/Types/EasingType.d.ts +20 -5
- package/types/Options/Classes/HslAnimation.d.ts +3 -4
- package/types/Options/Classes/Options.d.ts +2 -11
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -2
- package/types/Options/Classes/ResizeEvent.d.ts +9 -0
- package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
- package/types/Options/Interfaces/IOptions.d.ts +2 -8
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
- package/types/Types/CustomEventListener.d.ts +1 -1
- package/types/Types/EngineInitializers.d.ts +19 -0
- package/types/Utils/CanvasUtils.d.ts +6 -25
- package/types/Utils/EventDispatcher.d.ts +1 -1
- package/types/Utils/Utils.d.ts +5 -7
- package/types/export-types.d.ts +3 -19
- package/types/exports.d.ts +1 -21
- package/umd/Core/Canvas.js +236 -152
- package/umd/Core/Container.js +111 -227
- package/umd/Core/Engine.js +83 -123
- package/umd/Core/Particle.js +236 -140
- package/umd/Core/Particles.js +213 -124
- package/umd/Core/Retina.js +5 -0
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +69 -310
- package/umd/Core/Utils/Point.js +2 -0
- package/umd/Core/Utils/QuadTree.js +13 -8
- package/umd/Core/Utils/Ranges.js +4 -0
- package/umd/Core/Utils/Vectors.js +7 -4
- package/umd/Enums/Types/EasingType.js +18 -3
- package/umd/Options/Classes/AnimatableColor.js +1 -0
- package/umd/Options/Classes/AnimationOptions.js +8 -0
- package/umd/Options/Classes/Background/Background.js +6 -0
- package/umd/Options/Classes/ColorAnimation.js +1 -0
- package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/umd/Options/Classes/HslAnimation.js +3 -5
- package/umd/Options/Classes/Options.js +32 -78
- package/umd/Options/Classes/OptionsColor.js +1 -0
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/umd/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/umd/Options/Classes/Particles/Move/Move.js +18 -0
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/umd/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/umd/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/umd/Options/Classes/Particles/Size/Size.js +1 -0
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/umd/Options/Classes/Particles/Stroke.js +3 -0
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +4 -2
- package/umd/Options/Classes/ValueWithRandom.js +3 -4
- package/umd/Utils/CanvasUtils.js +30 -108
- package/umd/Utils/ColorUtils.js +17 -2
- package/umd/Utils/EventDispatcher.js +1 -0
- package/umd/Utils/MathUtils.js +3 -2
- package/umd/Utils/Utils.js +55 -48
- package/umd/exports.js +2 -22
- package/638.min.js +0 -2
- package/638.min.js.LICENSE.txt +0 -1
- package/browser/Core/Utils/ExternalInteractorBase.js +0 -7
- package/browser/Core/Utils/InteractionManager.js +0 -60
- package/browser/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/browser/Enums/InteractivityDetect.js +0 -6
- package/browser/Enums/Modes/ResponsiveMode.js +0 -5
- package/browser/Enums/Modes/ThemeMode.js +0 -6
- package/browser/Enums/Types/DivType.js +0 -5
- package/browser/Enums/Types/InteractorType.js +0 -5
- package/browser/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/browser/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/browser/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/browser/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/browser/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/browser/Options/Classes/ManualParticle.js +0 -21
- package/browser/Options/Classes/Responsive.js +0 -29
- package/browser/Options/Classes/Theme/Theme.js +0 -21
- package/browser/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/browser/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/browser/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/browser/Options/Interfaces/Theme/ITheme.js +0 -1
- package/browser/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/cjs/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/cjs/Core/Interfaces/IExternalInteractor.js +0 -1
- package/cjs/Core/Interfaces/IInteractor.js +0 -1
- package/cjs/Core/Interfaces/IMouseData.js +0 -1
- package/cjs/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/cjs/Core/Utils/ExternalInteractorBase.js +0 -7
- package/cjs/Core/Utils/InteractionManager.js +0 -60
- package/cjs/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/cjs/Enums/InteractivityDetect.js +0 -6
- package/cjs/Enums/Modes/ResponsiveMode.js +0 -5
- package/cjs/Enums/Modes/ThemeMode.js +0 -6
- package/cjs/Enums/Types/DivType.js +0 -5
- package/cjs/Enums/Types/InteractorType.js +0 -5
- package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/cjs/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/cjs/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/cjs/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/cjs/Options/Classes/ManualParticle.js +0 -21
- package/cjs/Options/Classes/Responsive.js +0 -29
- package/cjs/Options/Classes/Theme/Theme.js +0 -21
- package/cjs/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/cjs/Options/Interfaces/IManualParticle.js +0 -1
- package/cjs/Options/Interfaces/IResponsive.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/cjs/Options/Interfaces/Theme/ITheme.js +0 -1
- package/cjs/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/esm/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/esm/Core/Interfaces/IExternalInteractor.js +0 -1
- package/esm/Core/Interfaces/IInteractor.js +0 -1
- package/esm/Core/Interfaces/IMouseData.js +0 -1
- package/esm/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/esm/Core/Utils/ExternalInteractorBase.js +0 -7
- package/esm/Core/Utils/InteractionManager.js +0 -60
- package/esm/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/esm/Enums/InteractivityDetect.js +0 -6
- package/esm/Enums/Modes/ResponsiveMode.js +0 -5
- package/esm/Enums/Modes/ThemeMode.js +0 -6
- package/esm/Enums/Types/DivType.js +0 -5
- package/esm/Enums/Types/InteractorType.js +0 -5
- package/esm/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/esm/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/esm/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/esm/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/esm/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/esm/Options/Classes/ManualParticle.js +0 -21
- package/esm/Options/Classes/Responsive.js +0 -29
- package/esm/Options/Classes/Theme/Theme.js +0 -21
- package/esm/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/esm/Options/Interfaces/IManualParticle.js +0 -1
- package/esm/Options/Interfaces/IResponsive.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/esm/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/esm/Options/Interfaces/Theme/ITheme.js +0 -1
- package/esm/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/tsparticles.engine.min.js.LICENSE.txt +0 -1
- package/types/Core/Interfaces/IContainerInteractivity.d.ts +0 -6
- package/types/Core/Interfaces/IExternalInteractor.d.ts +0 -12
- package/types/Core/Interfaces/IInteractor.d.ts +0 -16
- package/types/Core/Interfaces/IMouseData.d.ts +0 -9
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +0 -7
- package/types/Core/Utils/ExternalInteractorBase.d.ts +0 -15
- package/types/Core/Utils/InteractionManager.d.ts +0 -17
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +0 -15
- package/types/Enums/InteractivityDetect.d.ts +0 -5
- package/types/Enums/Modes/ResponsiveMode.d.ts +0 -4
- package/types/Enums/Modes/ThemeMode.d.ts +0 -5
- package/types/Enums/Types/DivType.d.ts +0 -4
- package/types/Enums/Types/InteractorType.d.ts +0 -4
- package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -13
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +0 -12
- package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +0 -9
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +0 -12
- package/types/Options/Classes/ManualParticle.d.ts +0 -10
- package/types/Options/Classes/Responsive.d.ts +0 -12
- package/types/Options/Classes/Theme/Theme.d.ts +0 -12
- package/types/Options/Classes/Theme/ThemeDefault.d.ts +0 -11
- package/types/Options/Interfaces/IManualParticle.d.ts +0 -7
- package/types/Options/Interfaces/IResponsive.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -8
- package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -11
- package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IParallax.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -9
- package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -4
- package/types/Options/Interfaces/Interactivity/Modes/IModes.d.ts +0 -1
- package/types/Options/Interfaces/Theme/ITheme.d.ts +0 -7
- package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +0 -6
- package/umd/Core/Interfaces/IMouseData.js +0 -12
- package/umd/Core/Interfaces/IParticlesInteractor.js +0 -12
- package/umd/Core/Utils/ExternalInteractorBase.js +0 -21
- package/umd/Core/Utils/InteractionManager.js +0 -74
- package/umd/Core/Utils/ParticlesInteractorBase.js +0 -21
- package/umd/Enums/InteractivityDetect.js +0 -19
- package/umd/Enums/Modes/ResponsiveMode.js +0 -18
- package/umd/Enums/Modes/ThemeMode.js +0 -19
- package/umd/Enums/Types/DivType.js +0 -18
- package/umd/Enums/Types/InteractorType.js +0 -18
- package/umd/Options/Classes/Interactivity/Events/ClickEvent.js +0 -32
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +0 -41
- package/umd/Options/Classes/Interactivity/Events/Events.js +0 -44
- package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +0 -35
- package/umd/Options/Classes/Interactivity/Events/Parallax.js +0 -36
- package/umd/Options/Classes/Interactivity/Interactivity.js +0 -36
- package/umd/Options/Classes/Interactivity/Modes/Modes.js +0 -39
- package/umd/Options/Classes/ManualParticle.js +0 -35
- package/umd/Options/Classes/Responsive.js +0 -43
- package/umd/Options/Classes/Theme/Theme.js +0 -35
- package/umd/Options/Classes/Theme/ThemeDefault.js +0 -37
- package/umd/Options/Interfaces/IManualParticle.js +0 -12
- package/umd/Options/Interfaces/IResponsive.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IEvents.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IParallax.js +0 -12
- package/umd/Options/Interfaces/Interactivity/IInteractivity.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModes.js +0 -12
- package/umd/Options/Interfaces/Theme/ITheme.js +0 -12
- package/umd/Options/Interfaces/Theme/IThemeDefault.js +0 -12
- /package/browser/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/browser/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/browser/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
- /package/{browser/Core/Interfaces/IMouseData.js → cjs/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Core/Interfaces/IParticlesInteractor.js → cjs/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/IManualParticle.js → cjs/Types/EngineInitializers.js} +0 -0
- /package/{browser/Options/Interfaces/IResponsive.js → esm/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IClickEvent.js → esm/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IDivEvent.js → esm/Types/EngineInitializers.js} +0 -0
- /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
- /package/umd/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/umd/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/umd/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
package/cjs/Core/Particles.js
CHANGED
|
@@ -1,104 +1,43 @@
|
|
|
1
1
|
import { countOffset, defaultDensityFactor, defaultRemoveQuantity, deleteCount, lengthOffset, minCount, minIndex, minLimit, posOffset, qTreeCapacity, sizeFactor, squareExp, } from "./Utils/Constants.js";
|
|
2
2
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
3
|
-
import { InteractionManager } from "./Utils/InteractionManager.js";
|
|
4
3
|
import { LimitMode } from "../Enums/Modes/LimitMode.js";
|
|
5
4
|
import { Particle } from "./Particle.js";
|
|
6
5
|
import { Point } from "./Utils/Point.js";
|
|
7
6
|
import { QuadTree } from "./Utils/QuadTree.js";
|
|
8
7
|
import { Rectangle } from "./Utils/Ranges.js";
|
|
9
8
|
import { getLogger } from "../Utils/LogUtils.js";
|
|
10
|
-
import { getPosition } from "../Utils/Utils.js";
|
|
11
9
|
import { loadParticlesOptions } from "../Utils/OptionsUtils.js";
|
|
12
10
|
const qTreeRectangle = (canvasSize) => {
|
|
13
11
|
const { height, width } = canvasSize;
|
|
14
12
|
return new Rectangle(posOffset * width, posOffset * height, sizeFactor * width, sizeFactor * height);
|
|
15
13
|
};
|
|
16
14
|
export class Particles {
|
|
15
|
+
availablePathGenerators;
|
|
16
|
+
checkParticlePositionPlugins;
|
|
17
|
+
effectDrawers;
|
|
18
|
+
movers;
|
|
19
|
+
pathGenerators;
|
|
20
|
+
quadTree;
|
|
21
|
+
shapeDrawers;
|
|
22
|
+
updaters;
|
|
23
|
+
_array;
|
|
24
|
+
_container;
|
|
25
|
+
_engine;
|
|
26
|
+
_groupLimits;
|
|
27
|
+
_limit;
|
|
28
|
+
_maxZIndex;
|
|
29
|
+
_minZIndex;
|
|
30
|
+
_needsSort;
|
|
31
|
+
_nextId;
|
|
32
|
+
_particleResetPlugins;
|
|
33
|
+
_particleUpdatePlugins;
|
|
34
|
+
_pool;
|
|
35
|
+
_postParticleUpdatePlugins;
|
|
36
|
+
_postUpdatePlugins;
|
|
37
|
+
_resizeFactor;
|
|
38
|
+
_updatePlugins;
|
|
39
|
+
_zArray;
|
|
17
40
|
constructor(engine, container) {
|
|
18
|
-
this._addToPool = (...particles) => {
|
|
19
|
-
this._pool.push(...particles);
|
|
20
|
-
};
|
|
21
|
-
this._applyDensity = (options, manualCount, group, groupOptions) => {
|
|
22
|
-
const numberOptions = options.number;
|
|
23
|
-
if (!numberOptions.density.enable) {
|
|
24
|
-
if (group === undefined) {
|
|
25
|
-
this._limit = numberOptions.limit.value;
|
|
26
|
-
}
|
|
27
|
-
else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
|
|
28
|
-
this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
|
|
29
|
-
}
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const densityFactor = this._initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > minLimit ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + manualCount, particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
|
|
33
|
-
if (group === undefined) {
|
|
34
|
-
this._limit = numberOptions.limit.value * densityFactor;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
38
|
-
}
|
|
39
|
-
if (particlesCount < particlesNumber) {
|
|
40
|
-
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
41
|
-
}
|
|
42
|
-
else if (particlesCount > particlesNumber) {
|
|
43
|
-
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
this._initDensityFactor = densityOptions => {
|
|
47
|
-
const container = this._container;
|
|
48
|
-
if (!container.canvas.element || !densityOptions.enable) {
|
|
49
|
-
return defaultDensityFactor;
|
|
50
|
-
}
|
|
51
|
-
const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
|
|
52
|
-
return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
|
|
53
|
-
};
|
|
54
|
-
this._pushParticle = (position, overrideOptions, group, initializer) => {
|
|
55
|
-
try {
|
|
56
|
-
const particle = this._pool.pop() ?? new Particle(this._engine, this._container);
|
|
57
|
-
particle.init(this._nextId, position, overrideOptions, group);
|
|
58
|
-
let canAdd = true;
|
|
59
|
-
if (initializer) {
|
|
60
|
-
canAdd = initializer(particle);
|
|
61
|
-
}
|
|
62
|
-
if (!canAdd) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this._array.push(particle);
|
|
66
|
-
this._zArray.push(particle);
|
|
67
|
-
this._nextId++;
|
|
68
|
-
this._engine.dispatchEvent(EventType.particleAdded, {
|
|
69
|
-
container: this._container,
|
|
70
|
-
data: {
|
|
71
|
-
particle,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
return particle;
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
getLogger().warning(`error adding particle: ${e}`);
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
80
|
-
};
|
|
81
|
-
this._removeParticle = (index, group, override) => {
|
|
82
|
-
const particle = this._array[index];
|
|
83
|
-
if (!particle) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (particle.group !== group) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
90
|
-
this._array.splice(index, deleteCount);
|
|
91
|
-
this._zArray.splice(zIdx, deleteCount);
|
|
92
|
-
particle.destroy(override);
|
|
93
|
-
this._engine.dispatchEvent(EventType.particleRemoved, {
|
|
94
|
-
container: this._container,
|
|
95
|
-
data: {
|
|
96
|
-
particle,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
this._addToPool(particle);
|
|
100
|
-
return true;
|
|
101
|
-
};
|
|
102
41
|
this._engine = engine;
|
|
103
42
|
this._container = container;
|
|
104
43
|
this._nextId = 0;
|
|
@@ -108,21 +47,26 @@ export class Particles {
|
|
|
108
47
|
this._limit = 0;
|
|
109
48
|
this._groupLimits = new Map();
|
|
110
49
|
this._needsSort = false;
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
this._pluginsInitialized = false;
|
|
50
|
+
this._minZIndex = 0;
|
|
51
|
+
this._maxZIndex = 0;
|
|
114
52
|
const canvasSize = container.canvas.size;
|
|
115
53
|
this.quadTree = new QuadTree(qTreeRectangle(canvasSize), qTreeCapacity);
|
|
54
|
+
this.effectDrawers = new Map();
|
|
116
55
|
this.movers = [];
|
|
56
|
+
this.availablePathGenerators = new Map();
|
|
57
|
+
this.pathGenerators = new Map();
|
|
58
|
+
this.shapeDrawers = new Map();
|
|
117
59
|
this.updaters = [];
|
|
60
|
+
this.checkParticlePositionPlugins = [];
|
|
61
|
+
this._particleResetPlugins = [];
|
|
62
|
+
this._particleUpdatePlugins = [];
|
|
63
|
+
this._postUpdatePlugins = [];
|
|
64
|
+
this._postParticleUpdatePlugins = [];
|
|
65
|
+
this._updatePlugins = [];
|
|
118
66
|
}
|
|
119
67
|
get count() {
|
|
120
68
|
return this._array.length;
|
|
121
69
|
}
|
|
122
|
-
addManualParticles() {
|
|
123
|
-
const container = this._container, options = container.actualOptions;
|
|
124
|
-
options.manualParticles.forEach(p => this.addParticle(p.position ? getPosition(p.position, container.canvas.size) : undefined, p.options));
|
|
125
|
-
}
|
|
126
70
|
addParticle(position, overrideOptions, group, initializer) {
|
|
127
71
|
const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
|
|
128
72
|
if (limit > minLimit) {
|
|
@@ -139,20 +83,64 @@ export class Particles {
|
|
|
139
83
|
return;
|
|
140
84
|
}
|
|
141
85
|
break;
|
|
86
|
+
default:
|
|
87
|
+
break;
|
|
142
88
|
}
|
|
143
89
|
}
|
|
144
|
-
|
|
90
|
+
try {
|
|
91
|
+
const particle = this._pool.pop() ?? new Particle(this._engine, this._container);
|
|
92
|
+
particle.init(this._nextId, position, overrideOptions, group);
|
|
93
|
+
let canAdd = true;
|
|
94
|
+
if (initializer) {
|
|
95
|
+
canAdd = initializer(particle);
|
|
96
|
+
}
|
|
97
|
+
if (!canAdd) {
|
|
98
|
+
this._pool.push(particle);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this._array.push(particle);
|
|
102
|
+
this._zArray.push(particle);
|
|
103
|
+
this._nextId++;
|
|
104
|
+
this._engine.dispatchEvent(EventType.particleAdded, {
|
|
105
|
+
container: this._container,
|
|
106
|
+
data: {
|
|
107
|
+
particle,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
return particle;
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
getLogger().warning(`error adding particle: ${e}`);
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
145
116
|
}
|
|
146
117
|
clear() {
|
|
147
118
|
this._array = [];
|
|
148
119
|
this._zArray = [];
|
|
149
|
-
this._pluginsInitialized = false;
|
|
150
120
|
}
|
|
151
121
|
destroy() {
|
|
122
|
+
const container = this._container;
|
|
123
|
+
for (const [, effectDrawer] of this.effectDrawers) {
|
|
124
|
+
effectDrawer.destroy?.(container);
|
|
125
|
+
}
|
|
126
|
+
for (const [, shapeDrawer] of this.shapeDrawers) {
|
|
127
|
+
shapeDrawer.destroy?.(container);
|
|
128
|
+
}
|
|
152
129
|
this._array = [];
|
|
130
|
+
this._pool.length = 0;
|
|
153
131
|
this._zArray = [];
|
|
132
|
+
this.effectDrawers = new Map();
|
|
154
133
|
this.movers = [];
|
|
134
|
+
this.availablePathGenerators = new Map();
|
|
135
|
+
this.pathGenerators = new Map();
|
|
136
|
+
this.shapeDrawers = new Map();
|
|
155
137
|
this.updaters = [];
|
|
138
|
+
this.checkParticlePositionPlugins = [];
|
|
139
|
+
this._particleResetPlugins = [];
|
|
140
|
+
this._particleUpdatePlugins = [];
|
|
141
|
+
this._postUpdatePlugins = [];
|
|
142
|
+
this._postParticleUpdatePlugins = [];
|
|
143
|
+
this._updatePlugins = [];
|
|
156
144
|
}
|
|
157
145
|
drawParticles(delta) {
|
|
158
146
|
for (const particle of this._zArray) {
|
|
@@ -168,22 +156,54 @@ export class Particles {
|
|
|
168
156
|
get(index) {
|
|
169
157
|
return this._array[index];
|
|
170
158
|
}
|
|
171
|
-
handleClickMode(mode) {
|
|
172
|
-
this._interactionManager.handleClickMode(mode);
|
|
173
|
-
}
|
|
174
159
|
async init() {
|
|
175
160
|
const container = this._container, options = container.actualOptions;
|
|
176
|
-
this.
|
|
161
|
+
this._minZIndex = 0;
|
|
162
|
+
this._maxZIndex = 0;
|
|
177
163
|
this._needsSort = false;
|
|
164
|
+
this.checkParticlePositionPlugins = [];
|
|
165
|
+
this._updatePlugins = [];
|
|
166
|
+
this._particleUpdatePlugins = [];
|
|
167
|
+
this._postUpdatePlugins = [];
|
|
168
|
+
this._particleResetPlugins = [];
|
|
169
|
+
this._postParticleUpdatePlugins = [];
|
|
170
|
+
for (const plugin of container.plugins) {
|
|
171
|
+
if (plugin.redrawInit) {
|
|
172
|
+
await plugin.redrawInit();
|
|
173
|
+
}
|
|
174
|
+
if (plugin.checkParticlePosition) {
|
|
175
|
+
this.checkParticlePositionPlugins.push(plugin);
|
|
176
|
+
}
|
|
177
|
+
if (plugin.update) {
|
|
178
|
+
this._updatePlugins.push(plugin);
|
|
179
|
+
}
|
|
180
|
+
if (plugin.particleUpdate) {
|
|
181
|
+
this._particleUpdatePlugins.push(plugin);
|
|
182
|
+
}
|
|
183
|
+
if (plugin.postUpdate) {
|
|
184
|
+
this._postUpdatePlugins.push(plugin);
|
|
185
|
+
}
|
|
186
|
+
if (plugin.particleReset) {
|
|
187
|
+
this._particleResetPlugins.push(plugin);
|
|
188
|
+
}
|
|
189
|
+
if (plugin.postParticleUpdate) {
|
|
190
|
+
this._postParticleUpdatePlugins.push(plugin);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
178
193
|
await this.initPlugins();
|
|
194
|
+
for (const drawer of this.effectDrawers.values()) {
|
|
195
|
+
await drawer.init?.(container);
|
|
196
|
+
}
|
|
197
|
+
for (const drawer of this.shapeDrawers.values()) {
|
|
198
|
+
await drawer.init?.(container);
|
|
199
|
+
}
|
|
179
200
|
let handled = false;
|
|
180
|
-
for (const plugin of container.plugins
|
|
201
|
+
for (const plugin of container.plugins) {
|
|
181
202
|
handled = plugin.particlesInitialization?.() ?? handled;
|
|
182
203
|
if (handled) {
|
|
183
204
|
break;
|
|
184
205
|
}
|
|
185
206
|
}
|
|
186
|
-
this.addManualParticles();
|
|
187
207
|
if (!handled) {
|
|
188
208
|
const particlesOptions = options.particles, groups = particlesOptions.groups;
|
|
189
209
|
for (const group in groups) {
|
|
@@ -201,20 +221,20 @@ export class Particles {
|
|
|
201
221
|
}
|
|
202
222
|
}
|
|
203
223
|
async initPlugins() {
|
|
204
|
-
if (this._pluginsInitialized) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
224
|
const container = this._container;
|
|
225
|
+
this.effectDrawers = await this._engine.getEffectDrawers(container, true);
|
|
208
226
|
this.movers = await this._engine.getMovers(container, true);
|
|
227
|
+
this.availablePathGenerators = await this._engine.getPathGenerators(container, true);
|
|
228
|
+
this.pathGenerators = new Map();
|
|
229
|
+
this.shapeDrawers = await this._engine.getShapeDrawers(container, true);
|
|
209
230
|
this.updaters = await this._engine.getUpdaters(container, true);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
pathGenerator.init(container);
|
|
231
|
+
for (const pathGenerator of this.pathGenerators.values()) {
|
|
232
|
+
pathGenerator.init();
|
|
213
233
|
}
|
|
214
234
|
}
|
|
215
|
-
push(nb,
|
|
235
|
+
push(nb, position, overrideOptions, group) {
|
|
216
236
|
for (let i = 0; i < nb; i++) {
|
|
217
|
-
this.addParticle(
|
|
237
|
+
this.addParticle(position, overrideOptions, group);
|
|
218
238
|
}
|
|
219
239
|
}
|
|
220
240
|
async redraw() {
|
|
@@ -241,20 +261,25 @@ export class Particles {
|
|
|
241
261
|
this.removeAt(minIndex, quantity, group);
|
|
242
262
|
}
|
|
243
263
|
setDensity() {
|
|
244
|
-
const options = this._container.actualOptions, groups = options.particles.groups
|
|
264
|
+
const options = this._container.actualOptions, groups = options.particles.groups;
|
|
265
|
+
let pluginsCount = 0;
|
|
266
|
+
for (const plugin of this._container.plugins) {
|
|
267
|
+
if (plugin.particlesDensityCount) {
|
|
268
|
+
pluginsCount += plugin.particlesDensityCount();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
245
271
|
for (const group in groups) {
|
|
246
272
|
const groupData = groups[group];
|
|
247
273
|
if (!groupData) {
|
|
248
274
|
continue;
|
|
249
275
|
}
|
|
250
276
|
const groupDataOptions = loadParticlesOptions(this._engine, this._container, groupData);
|
|
251
|
-
this._applyDensity(groupDataOptions,
|
|
277
|
+
this._applyDensity(groupDataOptions, pluginsCount, group);
|
|
252
278
|
}
|
|
253
|
-
this._applyDensity(options.particles,
|
|
279
|
+
this._applyDensity(options.particles, pluginsCount);
|
|
254
280
|
}
|
|
255
281
|
setLastZIndex(zIndex) {
|
|
256
|
-
this.
|
|
257
|
-
this._needsSort = this._needsSort || this._lastZIndex < zIndex;
|
|
282
|
+
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
258
283
|
}
|
|
259
284
|
setResizeFactor(factor) {
|
|
260
285
|
this._resizeFactor = factor;
|
|
@@ -262,10 +287,10 @@ export class Particles {
|
|
|
262
287
|
update(delta) {
|
|
263
288
|
const container = this._container, particlesToDelete = new Set();
|
|
264
289
|
this.quadTree = new QuadTree(qTreeRectangle(container.canvas.size), qTreeCapacity);
|
|
265
|
-
for (const pathGenerator of
|
|
290
|
+
for (const pathGenerator of this.pathGenerators.values()) {
|
|
266
291
|
pathGenerator.update();
|
|
267
292
|
}
|
|
268
|
-
for (const plugin of
|
|
293
|
+
for (const plugin of this._updatePlugins) {
|
|
269
294
|
plugin.update?.(delta);
|
|
270
295
|
}
|
|
271
296
|
const resizeFactor = this._resizeFactor;
|
|
@@ -277,8 +302,10 @@ export class Particles {
|
|
|
277
302
|
particle.initialPosition.y *= resizeFactor.height;
|
|
278
303
|
}
|
|
279
304
|
particle.ignoresResizeRatio = false;
|
|
280
|
-
this.
|
|
281
|
-
|
|
305
|
+
for (const plugin of this._particleResetPlugins) {
|
|
306
|
+
plugin.particleReset?.(particle);
|
|
307
|
+
}
|
|
308
|
+
for (const plugin of this._particleUpdatePlugins) {
|
|
282
309
|
if (particle.destroyed) {
|
|
283
310
|
break;
|
|
284
311
|
}
|
|
@@ -309,25 +336,87 @@ export class Particles {
|
|
|
309
336
|
}
|
|
310
337
|
this._addToPool(...particlesToDelete);
|
|
311
338
|
}
|
|
312
|
-
this.
|
|
339
|
+
for (const plugin of this._postUpdatePlugins) {
|
|
340
|
+
plugin.postUpdate?.(delta);
|
|
341
|
+
}
|
|
313
342
|
for (const particle of this._array) {
|
|
314
343
|
for (const updater of this.updaters) {
|
|
315
344
|
updater.update(particle, delta);
|
|
316
345
|
}
|
|
317
346
|
if (!particle.destroyed && !particle.spawning) {
|
|
318
|
-
this.
|
|
347
|
+
for (const plugin of this._postParticleUpdatePlugins) {
|
|
348
|
+
plugin.postParticleUpdate?.(particle, delta);
|
|
349
|
+
}
|
|
319
350
|
}
|
|
320
351
|
}
|
|
321
352
|
delete this._resizeFactor;
|
|
322
353
|
if (this._needsSort) {
|
|
323
354
|
const zArray = this._zArray;
|
|
324
355
|
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
325
|
-
const lastItem = zArray[zArray.length - lengthOffset];
|
|
326
|
-
if (!lastItem) {
|
|
356
|
+
const firstItem = zArray[minIndex], lastItem = zArray[zArray.length - lengthOffset];
|
|
357
|
+
if (!firstItem || !lastItem) {
|
|
327
358
|
return;
|
|
328
359
|
}
|
|
329
|
-
this.
|
|
360
|
+
this._maxZIndex = firstItem.position.z;
|
|
361
|
+
this._minZIndex = lastItem.position.z;
|
|
330
362
|
this._needsSort = false;
|
|
331
363
|
}
|
|
332
364
|
}
|
|
365
|
+
_addToPool = (...particles) => {
|
|
366
|
+
this._pool.push(...particles);
|
|
367
|
+
};
|
|
368
|
+
_applyDensity = (options, pluginsCount, group, groupOptions) => {
|
|
369
|
+
const numberOptions = options.number;
|
|
370
|
+
if (!numberOptions.density.enable) {
|
|
371
|
+
if (group === undefined) {
|
|
372
|
+
this._limit = numberOptions.limit.value;
|
|
373
|
+
}
|
|
374
|
+
else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
|
|
375
|
+
this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
|
|
376
|
+
}
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const densityFactor = this._initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > minLimit ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + pluginsCount, particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
|
|
380
|
+
if (group === undefined) {
|
|
381
|
+
this._limit = numberOptions.limit.value * densityFactor;
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
385
|
+
}
|
|
386
|
+
if (particlesCount < particlesNumber) {
|
|
387
|
+
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
388
|
+
}
|
|
389
|
+
else if (particlesCount > particlesNumber) {
|
|
390
|
+
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
_initDensityFactor = densityOptions => {
|
|
394
|
+
const container = this._container;
|
|
395
|
+
if (!container.canvas.element || !densityOptions.enable) {
|
|
396
|
+
return defaultDensityFactor;
|
|
397
|
+
}
|
|
398
|
+
const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
|
|
399
|
+
return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** squareExp);
|
|
400
|
+
};
|
|
401
|
+
_removeParticle = (index, group, override) => {
|
|
402
|
+
const particle = this._array[index];
|
|
403
|
+
if (!particle) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
if (particle.group !== group) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
const zIdx = this._zArray.indexOf(particle);
|
|
410
|
+
this._array.splice(index, deleteCount);
|
|
411
|
+
this._zArray.splice(zIdx, deleteCount);
|
|
412
|
+
particle.destroy(override);
|
|
413
|
+
this._engine.dispatchEvent(EventType.particleRemoved, {
|
|
414
|
+
container: this._container,
|
|
415
|
+
data: {
|
|
416
|
+
particle,
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
this._addToPool(particle);
|
|
420
|
+
return true;
|
|
421
|
+
};
|
|
333
422
|
}
|
package/cjs/Core/Retina.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { defaultRatio, defaultReduceFactor } from "./Utils/Constants.js";
|
|
2
2
|
import { getRangeValue } from "../Utils/MathUtils.js";
|
|
3
3
|
export class Retina {
|
|
4
|
+
container;
|
|
5
|
+
maxSpeed;
|
|
6
|
+
pixelRatio;
|
|
7
|
+
reduceFactor;
|
|
8
|
+
sizeAnimationSpeed;
|
|
4
9
|
constructor(container) {
|
|
5
10
|
this.container = container;
|
|
6
11
|
this.pixelRatio = defaultRatio;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const generatedAttribute = "generated",
|
|
1
|
+
export const generatedAttribute = "generated", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
|
|
2
2
|
x: 0,
|
|
3
3
|
y: 0,
|
|
4
4
|
z: 0,
|
|
@@ -7,4 +7,4 @@ export const generatedAttribute = "generated", mouseDownEvent = "pointerdown", m
|
|
|
7
7
|
b: 0,
|
|
8
8
|
c: 0,
|
|
9
9
|
d: 1,
|
|
10
|
-
}, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0,
|
|
10
|
+
}, randomColorValue = "random", midColorValue = "mid", double = 2, doublePI = Math.PI * double, defaultFps = 60, defaultAlpha = 1, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, qTreeCapacity = 4, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, subdivideCount = 4, inverseFactorNumerator = 1.0, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, minimumLength = 0, zIndexFactorOffset = 1, defaultOpacity = 1, clickRadius = 1, touchEndLengthOffset = 1, minCoordinate = 0, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minRetries = 0, minZ = 0, defaultRadius = 0, posOffset = -quarter, sizeFactor = 1.5, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, touchDelay = 500, manualDefaultPosition = 50, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultVelocity = 0, defaultLoops = 0, defaultTime = 0;
|