@tsparticles/engine 3.9.1 → 4.0.0-alpha.1
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/638.min.js +2 -0
- package/638.min.js.LICENSE.txt +1 -0
- package/browser/Core/Canvas.js +126 -181
- package/browser/Core/Container.js +22 -18
- package/browser/Core/Engine.js +64 -54
- package/browser/Core/Particle.js +43 -48
- package/browser/Core/Particles.js +33 -24
- package/browser/Core/Retina.js +2 -3
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +74 -64
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Core/Utils/Ranges.js +2 -2
- package/browser/Core/Utils/Vectors.js +15 -21
- package/browser/Options/Classes/AnimatableColor.js +3 -3
- package/browser/Options/Classes/AnimationOptions.js +1 -1
- package/browser/Options/Classes/ColorAnimation.js +1 -1
- package/browser/Options/Classes/Options.js +13 -10
- package/browser/Options/Classes/Particles/Move/Move.js +1 -4
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/browser/Options/Classes/Particles/Move/Spin.js +1 -1
- package/browser/Options/Classes/Particles/ParticlesOptions.js +0 -6
- package/browser/Options/Classes/Particles/Stroke.js +1 -1
- package/browser/Options/Classes/ValueWithRandom.js +1 -1
- package/browser/Utils/CanvasUtils.js +65 -21
- package/browser/Utils/ColorUtils.js +61 -45
- package/browser/Utils/EventDispatcher.js +3 -1
- package/browser/Utils/LogUtils.js +22 -0
- package/browser/Utils/{NumberUtils.js → MathUtils.js} +14 -7
- package/browser/Utils/Utils.js +23 -125
- package/browser/bundle.js +3 -3
- package/browser/export-types.js +1 -99
- package/browser/exports.js +2 -9
- package/browser/index.js +3 -7
- package/browser/initEngine.js +4 -0
- package/cjs/Core/Canvas.js +136 -195
- package/cjs/Core/Container.js +57 -57
- package/cjs/Core/Engine.js +77 -71
- package/cjs/Core/Interfaces/Colors.js +1 -2
- package/cjs/Core/Interfaces/IBounds.js +1 -2
- package/cjs/Core/Interfaces/IBubbleParticleData.js +1 -2
- package/cjs/Core/Interfaces/ICircleBouncer.js +1 -2
- package/cjs/Core/Interfaces/IColorManager.js +1 -2
- package/cjs/Core/Interfaces/IContainerInteractivity.js +1 -2
- package/cjs/Core/Interfaces/IContainerPlugin.js +1 -2
- package/cjs/Core/Interfaces/ICoordinates.js +1 -2
- package/cjs/Core/Interfaces/IDelta.js +1 -2
- package/cjs/Core/Interfaces/IDimension.js +1 -2
- package/cjs/Core/Interfaces/IDistance.js +1 -2
- package/cjs/Core/Interfaces/IDrawParticleParams.js +1 -2
- package/cjs/Core/Interfaces/IEffectDrawer.js +1 -2
- package/cjs/Core/Interfaces/IExternalInteractor.js +1 -2
- package/cjs/Core/Interfaces/IInteractor.js +1 -2
- package/cjs/Core/Interfaces/ILoadParams.js +1 -2
- package/cjs/Core/Interfaces/IMouseData.js +1 -2
- package/cjs/Core/Interfaces/IMovePathGenerator.js +1 -2
- package/cjs/Core/Interfaces/IParticleColorStyle.js +1 -2
- package/cjs/Core/Interfaces/IParticleHslAnimation.js +1 -2
- package/cjs/Core/Interfaces/IParticleLife.js +1 -2
- package/cjs/Core/Interfaces/IParticleMover.js +1 -2
- package/cjs/Core/Interfaces/IParticleRetinaProps.js +1 -2
- package/cjs/Core/Interfaces/IParticleRoll.js +1 -2
- package/cjs/Core/Interfaces/IParticleTransformValues.js +1 -2
- package/cjs/Core/Interfaces/IParticleUpdater.js +1 -2
- package/cjs/Core/Interfaces/IParticleValueAnimation.js +1 -2
- package/cjs/Core/Interfaces/IParticlesInteractor.js +1 -2
- package/cjs/Core/Interfaces/IPlugin.js +1 -2
- package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -2
- package/cjs/Core/Interfaces/IRangeValue.js +1 -2
- package/cjs/Core/Interfaces/IShapeDrawData.js +1 -2
- package/cjs/Core/Interfaces/IShapeDrawer.js +1 -2
- package/cjs/Core/Interfaces/IShapeValues.js +1 -2
- package/cjs/Core/Interfaces/ISlowParticleData.js +1 -2
- package/cjs/Core/Particle.js +99 -108
- package/cjs/Core/Particles.js +63 -58
- package/cjs/Core/Retina.js +13 -18
- package/cjs/Core/Utils/Constants.js +3 -7
- package/cjs/Core/Utils/EventListeners.js +94 -88
- package/cjs/Core/Utils/ExternalInteractorBase.js +3 -7
- package/cjs/Core/Utils/InteractionManager.js +4 -8
- package/cjs/Core/Utils/ParticlesInteractorBase.js +3 -7
- package/cjs/Core/Utils/Point.js +1 -5
- package/cjs/Core/Utils/QuadTree.js +10 -14
- package/cjs/Core/Utils/Ranges.js +14 -20
- package/cjs/Core/Utils/Vectors.js +24 -35
- package/cjs/Enums/AnimationStatus.js +2 -5
- package/cjs/Enums/Directions/MoveDirection.js +2 -5
- package/cjs/Enums/Directions/OutModeDirection.js +2 -5
- package/cjs/Enums/Directions/RotateDirection.js +2 -5
- package/cjs/Enums/InteractivityDetect.js +2 -5
- package/cjs/Enums/Modes/AnimationMode.js +2 -5
- package/cjs/Enums/Modes/LimitMode.js +2 -5
- package/cjs/Enums/Modes/OutMode.js +2 -5
- package/cjs/Enums/Modes/PixelMode.js +2 -5
- package/cjs/Enums/Modes/ResponsiveMode.js +2 -5
- package/cjs/Enums/Modes/ThemeMode.js +2 -5
- package/cjs/Enums/Types/AlterType.js +2 -5
- package/cjs/Enums/Types/DestroyType.js +2 -5
- package/cjs/Enums/Types/DivType.js +2 -5
- package/cjs/Enums/Types/EasingType.js +2 -5
- package/cjs/Enums/Types/EventType.js +2 -5
- package/cjs/Enums/Types/GradientType.js +2 -5
- package/cjs/Enums/Types/InteractorType.js +2 -5
- package/cjs/Enums/Types/ParticleOutType.js +2 -5
- package/cjs/Enums/Types/StartValueType.js +2 -5
- package/cjs/Options/Classes/AnimatableColor.js +10 -14
- package/cjs/Options/Classes/AnimationOptions.js +14 -19
- package/cjs/Options/Classes/Background/Background.js +6 -10
- package/cjs/Options/Classes/ColorAnimation.js +6 -10
- package/cjs/Options/Classes/FullScreen/FullScreen.js +3 -7
- package/cjs/Options/Classes/HslAnimation.js +7 -11
- package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +3 -7
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +5 -9
- package/cjs/Options/Classes/Interactivity/Events/Events.js +14 -18
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +5 -9
- package/cjs/Options/Classes/Interactivity/Events/Parallax.js +3 -7
- package/cjs/Options/Classes/Interactivity/Events/ResizeEvent.js +3 -7
- package/cjs/Options/Classes/Interactivity/Interactivity.js +9 -13
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +3 -7
- package/cjs/Options/Classes/ManualParticle.js +10 -14
- package/cjs/Options/Classes/Options.js +41 -42
- package/cjs/Options/Classes/OptionsColor.js +5 -9
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +6 -10
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -6
- package/cjs/Options/Classes/Particles/Effect/Effect.js +5 -9
- package/cjs/Options/Classes/Particles/Move/Move.js +26 -33
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +6 -10
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +5 -9
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +5 -9
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +6 -10
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -9
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +7 -11
- package/cjs/Options/Classes/Particles/Move/Spin.js +7 -11
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -7
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +7 -11
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +5 -9
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +6 -10
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +6 -10
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -39
- package/cjs/Options/Classes/Particles/Shape/Shape.js +5 -9
- package/cjs/Options/Classes/Particles/Size/Size.js +6 -10
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +6 -10
- package/cjs/Options/Classes/Particles/Stroke.js +8 -12
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +4 -8
- package/cjs/Options/Classes/Responsive.js +13 -17
- package/cjs/Options/Classes/Theme/Theme.js +7 -11
- package/cjs/Options/Classes/Theme/ThemeDefault.js +5 -9
- package/cjs/Options/Classes/ValueWithRandom.js +12 -18
- package/cjs/Options/Interfaces/Background/IBackground.js +1 -2
- package/cjs/Options/Interfaces/FullScreen/IFullScreen.js +1 -2
- package/cjs/Options/Interfaces/IAnimatable.js +1 -2
- package/cjs/Options/Interfaces/IAnimatableColor.js +1 -2
- package/cjs/Options/Interfaces/IAnimation.js +1 -2
- package/cjs/Options/Interfaces/IColorAnimation.js +1 -2
- package/cjs/Options/Interfaces/IHslAnimation.js +1 -2
- package/cjs/Options/Interfaces/IManualParticle.js +1 -2
- package/cjs/Options/Interfaces/IOptionLoader.js +1 -2
- package/cjs/Options/Interfaces/IOptions.js +1 -2
- package/cjs/Options/Interfaces/IOptionsColor.js +1 -2
- package/cjs/Options/Interfaces/IResponsive.js +1 -2
- package/cjs/Options/Interfaces/IValueWithRandom.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IResizeEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +1 -2
- package/cjs/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +1 -2
- package/cjs/Options/Interfaces/Particles/Effect/IEffect.js +1 -2
- package/cjs/Options/Interfaces/Particles/IParticlesOptions.js +1 -2
- package/cjs/Options/Interfaces/Particles/IStroke.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMove.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveAngle.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveAttract.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveCenter.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveGravity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IOutModes.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/ISpin.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/Path/IMovePath.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesDensity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesNumber.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +1 -2
- package/cjs/Options/Interfaces/Particles/Opacity/IOpacity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +1 -2
- package/cjs/Options/Interfaces/Particles/Shape/IShape.js +1 -2
- package/cjs/Options/Interfaces/Particles/Size/ISize.js +1 -2
- package/cjs/Options/Interfaces/Particles/Size/ISizeAnimation.js +1 -2
- package/cjs/Options/Interfaces/Particles/ZIndex/IZIndex.js +1 -2
- package/cjs/Options/Interfaces/Theme/ITheme.js +1 -2
- package/cjs/Options/Interfaces/Theme/IThemeDefault.js +1 -2
- package/cjs/Types/CustomEventArgs.js +1 -2
- package/cjs/Types/CustomEventListener.js +1 -2
- package/cjs/Types/EasingFunction.js +1 -2
- package/cjs/Types/ExportResult.js +1 -2
- package/cjs/Types/ISourceOptions.js +1 -2
- package/cjs/Types/ParticlesGroups.js +1 -2
- package/cjs/Types/PathOptions.js +1 -2
- package/cjs/Types/RangeValue.js +1 -2
- package/cjs/Types/RecursivePartial.js +1 -2
- package/cjs/Types/ShapeData.js +1 -2
- package/cjs/Types/SingleOrMultiple.js +1 -2
- package/cjs/Utils/CanvasUtils.js +86 -55
- package/cjs/Utils/ColorUtils.js +136 -141
- package/cjs/Utils/EventDispatcher.js +8 -10
- package/cjs/Utils/LogUtils.js +22 -0
- package/{esm/Utils/NumberUtils.js → cjs/Utils/MathUtils.js} +14 -7
- package/cjs/Utils/OptionsUtils.js +4 -8
- package/cjs/Utils/TypeUtils.js +7 -16
- package/cjs/Utils/Utils.js +104 -239
- package/cjs/bundle.js +5 -22
- package/cjs/export-types.js +1 -115
- package/cjs/exports.js +77 -100
- package/cjs/index.js +5 -26
- package/cjs/initEngine.js +4 -0
- package/dist_browser_Core_Container_js.js +102 -0
- package/esm/Core/Canvas.js +126 -181
- package/esm/Core/Container.js +22 -18
- package/esm/Core/Engine.js +64 -54
- package/esm/Core/Particle.js +43 -48
- package/esm/Core/Particles.js +33 -24
- package/esm/Core/Retina.js +2 -3
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +74 -64
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Core/Utils/Ranges.js +2 -2
- package/esm/Core/Utils/Vectors.js +15 -21
- package/esm/Enums/RangeType.js +5 -0
- package/esm/Options/Classes/AnimatableColor.js +3 -3
- package/esm/Options/Classes/AnimationOptions.js +1 -1
- package/esm/Options/Classes/ColorAnimation.js +1 -1
- package/esm/Options/Classes/Options.js +13 -10
- package/esm/Options/Classes/Particles/Move/Move.js +1 -4
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/esm/Options/Classes/Particles/Move/Spin.js +1 -1
- package/esm/Options/Classes/Particles/ParticlesOptions.js +0 -6
- package/esm/Options/Classes/Particles/Stroke.js +1 -1
- package/esm/Options/Classes/ValueWithRandom.js +1 -1
- package/esm/Utils/CanvasUtils.js +65 -21
- package/esm/Utils/ColorUtils.js +61 -45
- package/esm/Utils/EventDispatcher.js +3 -1
- package/esm/Utils/LogUtils.js +22 -0
- package/esm/Utils/MathUtils.js +158 -0
- package/esm/Utils/Utils.js +23 -125
- package/esm/bundle.js +3 -3
- package/esm/export-types.js +1 -99
- package/esm/exports.js +2 -9
- package/esm/index.js +3 -7
- package/esm/initEngine.js +4 -0
- package/package.json +3 -2
- package/report.html +5 -4
- package/scripts/install.js +204 -118
- package/tsparticles.engine.js +492 -451
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +6 -9
- package/types/Core/Container.d.ts +1 -0
- package/types/Core/Engine.d.ts +20 -16
- package/types/Core/Interfaces/Colors.d.ts +46 -2
- package/types/Core/Interfaces/IColorManager.d.ts +1 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -0
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +0 -4
- package/types/Core/Interfaces/IEffectDrawer.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -0
- package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
- package/types/Core/Particle.d.ts +4 -5
- package/types/Core/Particles.d.ts +1 -1
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +1 -0
- package/types/Core/Utils/Vectors.d.ts +3 -3
- package/types/Options/Classes/Options.d.ts +1 -2
- package/types/Options/Classes/OptionsColor.d.ts +2 -2
- package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -4
- package/types/Options/Interfaces/IOptions.d.ts +1 -2
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -4
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
- package/types/Utils/CanvasUtils.d.ts +4 -1
- package/types/Utils/ColorUtils.d.ts +2 -2
- package/types/Utils/LogUtils.d.ts +11 -0
- package/types/Utils/{NumberUtils.d.ts → MathUtils.d.ts} +2 -1
- package/types/Utils/TypeUtils.d.ts +2 -2
- package/types/Utils/Utils.d.ts +4 -16
- package/types/export-types.d.ts +91 -101
- package/types/exports.d.ts +2 -9
- package/types/index.d.ts +1 -1
- package/types/initEngine.d.ts +2 -0
- package/umd/Core/Canvas.js +123 -178
- package/umd/Core/Container.js +25 -21
- package/umd/Core/Engine.js +97 -53
- package/umd/Core/Particle.js +54 -59
- package/umd/Core/Particles.js +33 -24
- package/umd/Core/Retina.js +9 -10
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +72 -62
- package/umd/Core/Utils/QuadTree.js +3 -3
- package/umd/Core/Utils/Ranges.js +4 -4
- package/umd/Core/Utils/Vectors.js +15 -21
- package/umd/Options/Classes/AnimatableColor.js +3 -3
- package/umd/Options/Classes/AnimationOptions.js +6 -6
- package/umd/Options/Classes/ColorAnimation.js +3 -3
- package/umd/Options/Classes/Options.js +16 -13
- package/umd/Options/Classes/Particles/Move/Move.js +5 -8
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -3
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -3
- package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -7
- package/umd/Options/Classes/Particles/Stroke.js +4 -4
- package/umd/Options/Classes/ValueWithRandom.js +3 -3
- package/umd/Utils/CanvasUtils.js +69 -22
- package/umd/Utils/ColorUtils.js +72 -56
- package/umd/Utils/EventDispatcher.js +3 -1
- package/umd/Utils/LogUtils.js +36 -0
- package/umd/Utils/{NumberUtils.js → MathUtils.js} +16 -8
- package/umd/Utils/Utils.js +36 -141
- package/umd/bundle.js +4 -4
- package/umd/export-types.js +1 -114
- package/umd/exports.js +3 -10
- package/umd/index.js +4 -8
- package/umd/{init.js → initEngine.js} +3 -5
- package/browser/Core/Interfaces/IRectSideResult.js +0 -1
- package/browser/Core/Interfaces/ITrailFillData.js +0 -1
- package/browser/Enums/Modes/CollisionMode.js +0 -6
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
- package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +0 -33
- package/browser/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
- package/browser/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
- package/browser/Options/Classes/Particles/Move/MoveTrail.js +0 -23
- package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
- package/browser/Options/Classes/Particles/Shadow.js +0 -35
- package/browser/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
- package/browser/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
- package/browser/Options/Interfaces/Particles/IShadow.js +0 -1
- package/browser/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
- package/browser/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
- package/browser/init.js +0 -6
- package/cjs/Core/Interfaces/IRectSideResult.js +0 -2
- package/cjs/Core/Interfaces/ITrailFillData.js +0 -2
- package/cjs/Enums/Modes/CollisionMode.js +0 -9
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +0 -28
- package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -25
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +0 -37
- package/cjs/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -18
- package/cjs/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -22
- package/cjs/Options/Classes/Particles/Move/MoveTrail.js +0 -27
- package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +0 -19
- package/cjs/Options/Classes/Particles/Shadow.js +0 -39
- package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -2
- package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -2
- package/cjs/Options/Interfaces/Particles/IShadow.js +0 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -2
- package/cjs/Types/RangeType.js +0 -8
- package/cjs/Utils/NumberUtils.js +0 -177
- package/cjs/init.js +0 -9
- package/esm/Core/Interfaces/IRectSideResult.js +0 -1
- package/esm/Core/Interfaces/ITrailFillData.js +0 -1
- package/esm/Enums/Modes/CollisionMode.js +0 -6
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
- package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +0 -33
- package/esm/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
- package/esm/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
- package/esm/Options/Classes/Particles/Move/MoveTrail.js +0 -23
- package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
- package/esm/Options/Classes/Particles/Shadow.js +0 -35
- package/esm/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
- package/esm/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
- package/esm/Options/Interfaces/Particles/IShadow.js +0 -1
- package/esm/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
- package/esm/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
- package/esm/init.js +0 -6
- package/types/Core/Interfaces/IRectSideResult.d.ts +0 -5
- package/types/Core/Interfaces/ITrailFillData.d.ts +0 -6
- package/types/Enums/Modes/CollisionMode.d.ts +0 -5
- package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +0 -11
- package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +0 -11
- package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +0 -18
- package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +0 -8
- package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +0 -9
- package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -11
- package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +0 -9
- package/types/Options/Classes/Particles/Shadow.d.ts +0 -13
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +0 -8
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +0 -6
- package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +0 -13
- package/types/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.d.ts +0 -3
- package/types/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.d.ts +0 -4
- package/types/Options/Interfaces/Particles/IShadow.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -6
- package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +0 -5
- package/types/init.d.ts +0 -2
- package/umd/Core/Interfaces/IRectSideResult.js +0 -12
- package/umd/Core/Interfaces/ITrailFillData.js +0 -12
- package/umd/Enums/Modes/CollisionMode.js +0 -19
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +0 -38
- package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -35
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +0 -47
- package/umd/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -28
- package/umd/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -32
- package/umd/Options/Classes/Particles/Move/MoveTrail.js +0 -37
- package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +0 -29
- package/umd/Options/Classes/Particles/Shadow.js +0 -49
- package/umd/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -12
- package/umd/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -12
- package/umd/Options/Interfaces/Particles/IShadow.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -12
- /package/browser/{Types → Enums}/RangeType.js +0 -0
- /package/{esm/Types → cjs/Enums}/RangeType.js +0 -0
- /package/types/{Types → Enums}/RangeType.d.ts +0 -0
- /package/umd/{Types → Enums}/RangeType.js +0 -0
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
6
|
-
const InteractivityDetect_js_1 = require("../../Enums/InteractivityDetect.js");
|
|
7
|
-
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
1
|
+
import { double, lengthOffset, millisecondsToSeconds, mouseDownEvent, mouseLeaveEvent, mouseMoveEvent, mouseOutEvent, mouseUpEvent, resizeEvent, touchCancelEvent, touchDelay, touchEndEvent, touchMoveEvent, touchStartEvent, visibilityChangeEvent, } from "./Constants.js";
|
|
2
|
+
import { executeOnSingleOrMultiple, safeDocument, safeMatchMedia } from "../../Utils/Utils.js";
|
|
3
|
+
import { InteractivityDetect } from "../../Enums/InteractivityDetect.js";
|
|
4
|
+
import { isBoolean } from "../../Utils/TypeUtils.js";
|
|
8
5
|
function manageListener(element, event, handler, add, options) {
|
|
9
6
|
if (add) {
|
|
10
7
|
let addOptions = { passive: true };
|
|
11
|
-
if (
|
|
8
|
+
if (isBoolean(options)) {
|
|
12
9
|
addOptions.capture = options;
|
|
13
10
|
}
|
|
14
11
|
else if (options !== undefined) {
|
|
@@ -21,9 +18,10 @@ function manageListener(element, event, handler, add, options) {
|
|
|
21
18
|
element.removeEventListener(event, handler, removeOptions);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
class EventListeners {
|
|
21
|
+
export class EventListeners {
|
|
25
22
|
constructor(container) {
|
|
26
23
|
this.container = container;
|
|
24
|
+
this._canPush = true;
|
|
27
25
|
this._doMouseTouchClick = e => {
|
|
28
26
|
const container = this.container, options = container.actualOptions;
|
|
29
27
|
if (this._canPush) {
|
|
@@ -32,12 +30,16 @@ class EventListeners {
|
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
32
|
mouseInteractivity.clickPosition = { ...mousePos };
|
|
35
|
-
mouseInteractivity.clickTime =
|
|
33
|
+
mouseInteractivity.clickTime = Date.now();
|
|
36
34
|
const onClick = options.interactivity.events.onClick;
|
|
37
|
-
|
|
35
|
+
executeOnSingleOrMultiple(onClick.mode, mode => {
|
|
36
|
+
this.container.handleClickMode(mode);
|
|
37
|
+
});
|
|
38
38
|
}
|
|
39
39
|
if (e.type === "touchend") {
|
|
40
|
-
setTimeout(() =>
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
this._mouseTouchFinish();
|
|
42
|
+
}, touchDelay);
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
this._handleThemeChange = (e) => {
|
|
@@ -52,17 +54,17 @@ class EventListeners {
|
|
|
52
54
|
if (!options.pauseOnBlur) {
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
|
-
if (
|
|
57
|
+
if (safeDocument().hidden) {
|
|
56
58
|
container.pageHidden = true;
|
|
57
59
|
container.pause();
|
|
58
60
|
}
|
|
59
61
|
else {
|
|
60
62
|
container.pageHidden = false;
|
|
61
63
|
if (container.animationStatus) {
|
|
62
|
-
|
|
64
|
+
container.play(true);
|
|
63
65
|
}
|
|
64
66
|
else {
|
|
65
|
-
|
|
67
|
+
container.draw(true);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
};
|
|
@@ -73,9 +75,9 @@ class EventListeners {
|
|
|
73
75
|
}
|
|
74
76
|
const handleResize = async () => {
|
|
75
77
|
const canvas = this.container.canvas;
|
|
76
|
-
await canvas
|
|
78
|
+
await canvas.windowResize();
|
|
77
79
|
};
|
|
78
|
-
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay *
|
|
80
|
+
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.interactivity.events.resize.delay * millisecondsToSeconds);
|
|
79
81
|
};
|
|
80
82
|
this._manageInteractivityListeners = (mouseLeaveTmpEvent, add) => {
|
|
81
83
|
const handlers = this._handlers, container = this.container, options = container.actualOptions, interactivityEl = container.interactivity.element;
|
|
@@ -87,28 +89,28 @@ class EventListeners {
|
|
|
87
89
|
if (!(options.interactivity.events.onHover.enable || options.interactivity.events.onClick.enable)) {
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
|
-
manageListener(interactivityEl,
|
|
91
|
-
manageListener(interactivityEl,
|
|
92
|
-
manageListener(interactivityEl,
|
|
93
|
-
if (
|
|
94
|
-
manageListener(interactivityEl,
|
|
92
|
+
manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
|
|
93
|
+
manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
|
|
94
|
+
manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
|
|
95
|
+
if (options.interactivity.events.onClick.enable) {
|
|
96
|
+
manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add);
|
|
97
|
+
manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
|
|
98
|
+
manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
|
|
95
99
|
}
|
|
96
100
|
else {
|
|
97
|
-
manageListener(interactivityEl,
|
|
98
|
-
manageListener(interactivityEl, Constants_js_1.mouseUpEvent, handlers.mouseUp, add);
|
|
99
|
-
manageListener(interactivityEl, Constants_js_1.mouseDownEvent, handlers.mouseDown, add);
|
|
101
|
+
manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add);
|
|
100
102
|
}
|
|
101
103
|
manageListener(interactivityEl, mouseLeaveTmpEvent, handlers.mouseLeave, add);
|
|
102
|
-
manageListener(interactivityEl,
|
|
104
|
+
manageListener(interactivityEl, touchCancelEvent, handlers.touchCancel, add);
|
|
103
105
|
};
|
|
104
106
|
this._manageListeners = add => {
|
|
105
107
|
const handlers = this._handlers, container = this.container, options = container.actualOptions, detectType = options.interactivity.detectsOn, canvasEl = container.canvas.element;
|
|
106
|
-
let mouseLeaveTmpEvent =
|
|
107
|
-
if (detectType ===
|
|
108
|
+
let mouseLeaveTmpEvent = mouseLeaveEvent;
|
|
109
|
+
if (detectType === InteractivityDetect.window) {
|
|
108
110
|
container.interactivity.element = window;
|
|
109
|
-
mouseLeaveTmpEvent =
|
|
111
|
+
mouseLeaveTmpEvent = mouseOutEvent;
|
|
110
112
|
}
|
|
111
|
-
else if (detectType ===
|
|
113
|
+
else if (detectType === InteractivityDetect.parent && canvasEl) {
|
|
112
114
|
container.interactivity.element = canvasEl.parentElement ?? canvasEl.parentNode;
|
|
113
115
|
}
|
|
114
116
|
else {
|
|
@@ -117,36 +119,22 @@ class EventListeners {
|
|
|
117
119
|
this._manageMediaMatch(add);
|
|
118
120
|
this._manageResize(add);
|
|
119
121
|
this._manageInteractivityListeners(mouseLeaveTmpEvent, add);
|
|
120
|
-
|
|
121
|
-
manageListener(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
122
|
-
}
|
|
122
|
+
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
123
123
|
};
|
|
124
124
|
this._manageMediaMatch = add => {
|
|
125
|
-
const handlers = this._handlers
|
|
126
|
-
if (!
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (mediaMatch.addEventListener !== undefined) {
|
|
130
|
-
manageListener(mediaMatch, "change", handlers.themeChange, add);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (mediaMatch.addListener === undefined) {
|
|
125
|
+
const handlers = this._handlers;
|
|
126
|
+
if (!this._matchMedia) {
|
|
134
127
|
return;
|
|
135
128
|
}
|
|
136
|
-
|
|
137
|
-
mediaMatch.addListener(handlers.oldThemeChange);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
mediaMatch.removeListener(handlers.oldThemeChange);
|
|
141
|
-
}
|
|
129
|
+
manageListener(this._matchMedia, "change", handlers.themeChange, add);
|
|
142
130
|
};
|
|
143
131
|
this._manageResize = add => {
|
|
144
132
|
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
145
|
-
if (!options.interactivity.events.resize) {
|
|
133
|
+
if (!options.interactivity.events.resize.enable) {
|
|
146
134
|
return;
|
|
147
135
|
}
|
|
148
136
|
if (typeof ResizeObserver === "undefined") {
|
|
149
|
-
manageListener(
|
|
137
|
+
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
150
138
|
return;
|
|
151
139
|
}
|
|
152
140
|
const canvasEl = container.canvas.element;
|
|
@@ -169,11 +157,7 @@ class EventListeners {
|
|
|
169
157
|
}
|
|
170
158
|
};
|
|
171
159
|
this._mouseDown = () => {
|
|
172
|
-
const { interactivity } = this.container;
|
|
173
|
-
if (!interactivity) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const { mouse } = interactivity;
|
|
160
|
+
const { interactivity } = this.container, { mouse } = interactivity;
|
|
177
161
|
mouse.clicking = true;
|
|
178
162
|
mouse.downPosition = mouse.position;
|
|
179
163
|
};
|
|
@@ -200,21 +184,17 @@ class EventListeners {
|
|
|
200
184
|
mouse.clicking = false;
|
|
201
185
|
};
|
|
202
186
|
this._mouseTouchFinish = () => {
|
|
203
|
-
const interactivity = this.container
|
|
204
|
-
if (!interactivity) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const mouse = interactivity.mouse;
|
|
187
|
+
const { interactivity } = this.container, { mouse } = interactivity;
|
|
208
188
|
delete mouse.position;
|
|
209
189
|
delete mouse.clickPosition;
|
|
210
190
|
delete mouse.downPosition;
|
|
211
|
-
interactivity.status =
|
|
191
|
+
interactivity.status = mouseLeaveEvent;
|
|
212
192
|
mouse.inside = false;
|
|
213
193
|
mouse.clicking = false;
|
|
214
194
|
};
|
|
215
195
|
this._mouseTouchMove = e => {
|
|
216
196
|
const container = this.container, options = container.actualOptions, interactivity = container.interactivity, canvasEl = container.canvas.element;
|
|
217
|
-
if (!interactivity
|
|
197
|
+
if (!interactivity.element) {
|
|
218
198
|
return;
|
|
219
199
|
}
|
|
220
200
|
interactivity.mouse.inside = true;
|
|
@@ -231,36 +211,39 @@ class EventListeners {
|
|
|
231
211
|
};
|
|
232
212
|
}
|
|
233
213
|
}
|
|
234
|
-
else if (options.interactivity.detectsOn ===
|
|
214
|
+
else if (options.interactivity.detectsOn === InteractivityDetect.parent) {
|
|
235
215
|
const source = mouseEvent.target, target = mouseEvent.currentTarget;
|
|
236
|
-
if (
|
|
216
|
+
if (canvasEl) {
|
|
237
217
|
const sourceRect = source.getBoundingClientRect(), targetRect = target.getBoundingClientRect(), canvasRect = canvasEl.getBoundingClientRect();
|
|
238
218
|
pos = {
|
|
239
|
-
x: mouseEvent.offsetX +
|
|
240
|
-
y: mouseEvent.offsetY +
|
|
219
|
+
x: mouseEvent.offsetX + double * sourceRect.left - (targetRect.left + canvasRect.left),
|
|
220
|
+
y: mouseEvent.offsetY + double * sourceRect.top - (targetRect.top + canvasRect.top),
|
|
241
221
|
};
|
|
242
222
|
}
|
|
243
223
|
else {
|
|
244
224
|
pos = {
|
|
245
|
-
x: mouseEvent.offsetX
|
|
246
|
-
y: mouseEvent.offsetY
|
|
225
|
+
x: mouseEvent.offsetX,
|
|
226
|
+
y: mouseEvent.offsetY,
|
|
247
227
|
};
|
|
248
228
|
}
|
|
249
229
|
}
|
|
250
230
|
else if (mouseEvent.target === canvasEl) {
|
|
251
231
|
pos = {
|
|
252
|
-
x: mouseEvent.offsetX
|
|
253
|
-
y: mouseEvent.offsetY
|
|
232
|
+
x: mouseEvent.offsetX,
|
|
233
|
+
y: mouseEvent.offsetY,
|
|
254
234
|
};
|
|
255
235
|
}
|
|
256
236
|
}
|
|
257
237
|
else {
|
|
258
238
|
this._canPush = e.type !== "touchmove";
|
|
259
239
|
if (canvasEl) {
|
|
260
|
-
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length -
|
|
240
|
+
const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - lengthOffset], canvasRect = canvasEl.getBoundingClientRect();
|
|
241
|
+
if (!lastTouch) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
261
244
|
pos = {
|
|
262
|
-
x: lastTouch.clientX -
|
|
263
|
-
y: lastTouch.clientY -
|
|
245
|
+
x: lastTouch.clientX - canvasRect.left,
|
|
246
|
+
y: lastTouch.clientY - canvasRect.top,
|
|
264
247
|
};
|
|
265
248
|
}
|
|
266
249
|
}
|
|
@@ -270,7 +253,7 @@ class EventListeners {
|
|
|
270
253
|
pos.y *= pxRatio;
|
|
271
254
|
}
|
|
272
255
|
interactivity.mouse.position = pos;
|
|
273
|
-
interactivity.status =
|
|
256
|
+
interactivity.status = mouseMoveEvent;
|
|
274
257
|
};
|
|
275
258
|
this._touchEnd = e => {
|
|
276
259
|
const evt = e, touches = Array.from(evt.changedTouches);
|
|
@@ -293,21 +276,45 @@ class EventListeners {
|
|
|
293
276
|
}
|
|
294
277
|
this._mouseTouchMove(e);
|
|
295
278
|
};
|
|
296
|
-
this.
|
|
279
|
+
this._matchMedia = safeMatchMedia("(prefers-color-scheme: dark)");
|
|
297
280
|
this._touches = new Map();
|
|
298
281
|
this._handlers = {
|
|
299
|
-
mouseDown: () =>
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
282
|
+
mouseDown: () => {
|
|
283
|
+
this._mouseDown();
|
|
284
|
+
},
|
|
285
|
+
mouseLeave: () => {
|
|
286
|
+
this._mouseTouchFinish();
|
|
287
|
+
},
|
|
288
|
+
mouseMove: (e) => {
|
|
289
|
+
this._mouseTouchMove(e);
|
|
290
|
+
},
|
|
291
|
+
mouseUp: (e) => {
|
|
292
|
+
this._mouseTouchClick(e);
|
|
293
|
+
},
|
|
294
|
+
touchStart: (e) => {
|
|
295
|
+
this._touchStart(e);
|
|
296
|
+
},
|
|
297
|
+
touchMove: (e) => {
|
|
298
|
+
this._mouseTouchMove(e);
|
|
299
|
+
},
|
|
300
|
+
touchEnd: (e) => {
|
|
301
|
+
this._touchEnd(e);
|
|
302
|
+
},
|
|
303
|
+
touchCancel: (e) => {
|
|
304
|
+
this._touchEnd(e);
|
|
305
|
+
},
|
|
306
|
+
touchEndClick: (e) => {
|
|
307
|
+
this._touchEndClick(e);
|
|
308
|
+
},
|
|
309
|
+
visibilityChange: () => {
|
|
310
|
+
this._handleVisibilityChange();
|
|
311
|
+
},
|
|
312
|
+
themeChange: (e) => {
|
|
313
|
+
this._handleThemeChange(e);
|
|
314
|
+
},
|
|
315
|
+
oldThemeChange: (e) => {
|
|
316
|
+
this._handleThemeChange(e);
|
|
317
|
+
},
|
|
311
318
|
resize: () => {
|
|
312
319
|
this._handleWindowResize();
|
|
313
320
|
},
|
|
@@ -320,4 +327,3 @@ class EventListeners {
|
|
|
320
327
|
this._manageListeners(false);
|
|
321
328
|
}
|
|
322
329
|
}
|
|
323
|
-
exports.EventListeners = EventListeners;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ExternalInteractorBase = void 0;
|
|
4
|
-
const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
|
|
5
|
-
class ExternalInteractorBase {
|
|
1
|
+
import { InteractorType } from "../../Enums/Types/InteractorType.js";
|
|
2
|
+
export class ExternalInteractorBase {
|
|
6
3
|
constructor(container) {
|
|
7
|
-
this.type =
|
|
4
|
+
this.type = InteractorType.external;
|
|
8
5
|
this.container = container;
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.ExternalInteractorBase = ExternalInteractorBase;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.InteractionManager = void 0;
|
|
4
|
-
const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
|
|
5
|
-
class InteractionManager {
|
|
1
|
+
import { InteractorType } from "../../Enums/Types/InteractorType.js";
|
|
2
|
+
export class InteractionManager {
|
|
6
3
|
constructor(engine, container) {
|
|
7
4
|
this.container = container;
|
|
8
5
|
this._engine = engine;
|
|
@@ -28,10 +25,10 @@ class InteractionManager {
|
|
|
28
25
|
this._particleInteractors = [];
|
|
29
26
|
for (const interactor of this._interactors) {
|
|
30
27
|
switch (interactor.type) {
|
|
31
|
-
case
|
|
28
|
+
case InteractorType.external:
|
|
32
29
|
this._externalInteractors.push(interactor);
|
|
33
30
|
break;
|
|
34
|
-
case
|
|
31
|
+
case InteractorType.particles:
|
|
35
32
|
this._particleInteractors.push(interactor);
|
|
36
33
|
break;
|
|
37
34
|
}
|
|
@@ -61,4 +58,3 @@ class InteractionManager {
|
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
|
-
exports.InteractionManager = InteractionManager;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ParticlesInteractorBase = void 0;
|
|
4
|
-
const InteractorType_js_1 = require("../../Enums/Types/InteractorType.js");
|
|
5
|
-
class ParticlesInteractorBase {
|
|
1
|
+
import { InteractorType } from "../../Enums/Types/InteractorType.js";
|
|
2
|
+
export class ParticlesInteractorBase {
|
|
6
3
|
constructor(container) {
|
|
7
|
-
this.type =
|
|
4
|
+
this.type = InteractorType.particles;
|
|
8
5
|
this.container = container;
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.ParticlesInteractorBase = ParticlesInteractorBase;
|
package/cjs/Core/Utils/Point.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Point = void 0;
|
|
4
|
-
class Point {
|
|
1
|
+
export class Point {
|
|
5
2
|
constructor(position, particle) {
|
|
6
3
|
this.position = position;
|
|
7
4
|
this.particle = particle;
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
exports.Point = Point;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const Constants_js_1 = require("./Constants.js");
|
|
6
|
-
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
7
|
-
class QuadTree {
|
|
1
|
+
import { Circle, Rectangle } from "./Ranges.js";
|
|
2
|
+
import { double, half, subdivideCount } from "./Constants.js";
|
|
3
|
+
import { getDistance } from "../../Utils/MathUtils.js";
|
|
4
|
+
export class QuadTree {
|
|
8
5
|
constructor(rectangle, capacity) {
|
|
9
6
|
this.rectangle = rectangle;
|
|
10
7
|
this.capacity = capacity;
|
|
11
8
|
this._subdivide = () => {
|
|
12
9
|
const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
|
|
13
|
-
for (let i = 0; i <
|
|
14
|
-
const fixedIndex = i %
|
|
15
|
-
this._subs.push(new QuadTree(new
|
|
10
|
+
for (let i = 0; i < subdivideCount; i++) {
|
|
11
|
+
const fixedIndex = i % double;
|
|
12
|
+
this._subs.push(new QuadTree(new Rectangle(x + width * half * fixedIndex, y + height * half * (Math.round(i * half) - fixedIndex), width * half, height * half), capacity));
|
|
16
13
|
}
|
|
17
14
|
this._divided = true;
|
|
18
15
|
};
|
|
@@ -40,7 +37,7 @@ class QuadTree {
|
|
|
40
37
|
}
|
|
41
38
|
for (const p of this._points) {
|
|
42
39
|
if (!range.contains(p.position) &&
|
|
43
|
-
|
|
40
|
+
getDistance(range.position, p.position) > p.particle.getRadius() &&
|
|
44
41
|
(!check || check(p.particle))) {
|
|
45
42
|
continue;
|
|
46
43
|
}
|
|
@@ -54,10 +51,9 @@ class QuadTree {
|
|
|
54
51
|
return res;
|
|
55
52
|
}
|
|
56
53
|
queryCircle(position, radius, check) {
|
|
57
|
-
return this.query(new
|
|
54
|
+
return this.query(new Circle(position.x, position.y, radius), check);
|
|
58
55
|
}
|
|
59
56
|
queryRectangle(position, size, check) {
|
|
60
|
-
return this.query(new
|
|
57
|
+
return this.query(new Rectangle(position.x, position.y, size.width, size.height), check);
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
exports.QuadTree = QuadTree;
|
package/cjs/Core/Utils/Ranges.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const NumberUtils_js_1 = require("../../Utils/NumberUtils.js");
|
|
6
|
-
const Constants_js_1 = require("./Constants.js");
|
|
7
|
-
class BaseRange {
|
|
1
|
+
import { RangeType } from "../../Enums/RangeType.js";
|
|
2
|
+
import { getDistance } from "../../Utils/MathUtils.js";
|
|
3
|
+
import { squareExp } from "./Constants.js";
|
|
4
|
+
export class BaseRange {
|
|
8
5
|
constructor(x, y, type) {
|
|
9
6
|
this.position = {
|
|
10
7
|
x: x,
|
|
@@ -13,24 +10,23 @@ class BaseRange {
|
|
|
13
10
|
this.type = type;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
class Circle extends BaseRange {
|
|
13
|
+
export class Circle extends BaseRange {
|
|
18
14
|
constructor(x, y, radius) {
|
|
19
|
-
super(x, y,
|
|
15
|
+
super(x, y, RangeType.circle);
|
|
20
16
|
this.radius = radius;
|
|
21
17
|
}
|
|
22
18
|
contains(point) {
|
|
23
|
-
return
|
|
19
|
+
return getDistance(point, this.position) <= this.radius;
|
|
24
20
|
}
|
|
25
21
|
intersects(range) {
|
|
26
22
|
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
27
|
-
if (range instanceof Circle || range.type ===
|
|
28
|
-
const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x **
|
|
23
|
+
if (range instanceof Circle || range.type === RangeType.circle) {
|
|
24
|
+
const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
29
25
|
return rSum > dist;
|
|
30
26
|
}
|
|
31
|
-
else if (range instanceof Rectangle || range.type ===
|
|
32
|
-
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width,
|
|
33
|
-
return (edges <= r **
|
|
27
|
+
else if (range instanceof Rectangle || range.type === RangeType.rectangle) {
|
|
28
|
+
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
29
|
+
return (edges <= r ** squareExp ||
|
|
34
30
|
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
35
31
|
distPos.x <= width ||
|
|
36
32
|
distPos.y <= height);
|
|
@@ -38,10 +34,9 @@ class Circle extends BaseRange {
|
|
|
38
34
|
return false;
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
class Rectangle extends BaseRange {
|
|
37
|
+
export class Rectangle extends BaseRange {
|
|
43
38
|
constructor(x, y, width, height) {
|
|
44
|
-
super(x, y,
|
|
39
|
+
super(x, y, RangeType.rectangle);
|
|
45
40
|
this.size = {
|
|
46
41
|
height: height,
|
|
47
42
|
width: width,
|
|
@@ -59,4 +54,3 @@ class Rectangle extends BaseRange {
|
|
|
59
54
|
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
|
-
exports.Rectangle = Rectangle;
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Constants_js_1 = require("./Constants.js");
|
|
5
|
-
const TypeUtils_js_1 = require("../../Utils/TypeUtils.js");
|
|
6
|
-
class Vector3d {
|
|
7
|
-
constructor(xOrCoords, y, z) {
|
|
1
|
+
import { inverseFactorNumerator, none, originPoint, squareExp } from "./Constants.js";
|
|
2
|
+
export class Vector3d {
|
|
3
|
+
constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
|
|
8
4
|
this._updateFromAngle = (angle, length) => {
|
|
9
5
|
this.x = Math.cos(angle) * length;
|
|
10
6
|
this.y = Math.sin(angle) * length;
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const coords3d = xOrCoords;
|
|
16
|
-
this.z = coords3d.z ? coords3d.z : Constants_js_1.originPoint.z;
|
|
17
|
-
}
|
|
18
|
-
else if (xOrCoords !== undefined && y !== undefined) {
|
|
19
|
-
this.x = xOrCoords;
|
|
20
|
-
this.y = y;
|
|
21
|
-
this.z = z ?? Constants_js_1.originPoint.z;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw new Error(`${Constants_js_1.errorPrefix} Vector3d not initialized correctly`);
|
|
25
|
-
}
|
|
8
|
+
this.x = x;
|
|
9
|
+
this.y = y;
|
|
10
|
+
this.z = z;
|
|
26
11
|
}
|
|
27
12
|
static get origin() {
|
|
28
|
-
return Vector3d.create(
|
|
13
|
+
return Vector3d.create(originPoint.x, originPoint.y, originPoint.z);
|
|
29
14
|
}
|
|
30
15
|
get angle() {
|
|
31
16
|
return Math.atan2(this.y, this.x);
|
|
@@ -43,7 +28,10 @@ class Vector3d {
|
|
|
43
28
|
return Vector3d.create(source.x, source.y, source.z);
|
|
44
29
|
}
|
|
45
30
|
static create(x, y, z) {
|
|
46
|
-
|
|
31
|
+
if (typeof x === "number") {
|
|
32
|
+
return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
|
|
33
|
+
}
|
|
34
|
+
return new Vector3d(x.x, x.y, Object.hasOwn(x, "z") ? x.z : originPoint.z);
|
|
47
35
|
}
|
|
48
36
|
add(v) {
|
|
49
37
|
return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v.z);
|
|
@@ -71,7 +59,7 @@ class Vector3d {
|
|
|
71
59
|
this.z /= n;
|
|
72
60
|
}
|
|
73
61
|
getLengthSq() {
|
|
74
|
-
return this.x **
|
|
62
|
+
return this.x ** squareExp + this.y ** squareExp;
|
|
75
63
|
}
|
|
76
64
|
mult(n) {
|
|
77
65
|
return Vector3d.create(this.x * n, this.y * n, this.z * n);
|
|
@@ -83,18 +71,18 @@ class Vector3d {
|
|
|
83
71
|
}
|
|
84
72
|
normalize() {
|
|
85
73
|
const length = this.length;
|
|
86
|
-
if (length !=
|
|
87
|
-
this.multTo(
|
|
74
|
+
if (length != none) {
|
|
75
|
+
this.multTo(inverseFactorNumerator / length);
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
rotate(angle) {
|
|
91
|
-
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle),
|
|
79
|
+
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), originPoint.z);
|
|
92
80
|
}
|
|
93
81
|
setTo(c) {
|
|
94
82
|
this.x = c.x;
|
|
95
83
|
this.y = c.y;
|
|
96
84
|
const v3d = c;
|
|
97
|
-
this.z = v3d.z ? v3d.z :
|
|
85
|
+
this.z = v3d.z ? v3d.z : originPoint.z;
|
|
98
86
|
}
|
|
99
87
|
sub(v) {
|
|
100
88
|
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v.z);
|
|
@@ -105,19 +93,20 @@ class Vector3d {
|
|
|
105
93
|
this.z -= v.z;
|
|
106
94
|
}
|
|
107
95
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
super(xOrCoords, y, Constants_js_1.originPoint.z);
|
|
96
|
+
export class Vector extends Vector3d {
|
|
97
|
+
constructor(x = originPoint.x, y = originPoint.y) {
|
|
98
|
+
super(x, y, originPoint.z);
|
|
112
99
|
}
|
|
113
100
|
static get origin() {
|
|
114
|
-
return Vector.create(
|
|
101
|
+
return Vector.create(originPoint.x, originPoint.y);
|
|
115
102
|
}
|
|
116
103
|
static clone(source) {
|
|
117
104
|
return Vector.create(source.x, source.y);
|
|
118
105
|
}
|
|
119
106
|
static create(x, y) {
|
|
120
|
-
|
|
107
|
+
if (typeof x === "number") {
|
|
108
|
+
return new Vector(x, y ?? originPoint.y);
|
|
109
|
+
}
|
|
110
|
+
return new Vector(x.x, x.y);
|
|
121
111
|
}
|
|
122
112
|
}
|
|
123
|
-
exports.Vector = Vector;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnimationStatus = void 0;
|
|
4
|
-
var AnimationStatus;
|
|
1
|
+
export var AnimationStatus;
|
|
5
2
|
(function (AnimationStatus) {
|
|
6
3
|
AnimationStatus["increasing"] = "increasing";
|
|
7
4
|
AnimationStatus["decreasing"] = "decreasing";
|
|
8
|
-
})(AnimationStatus || (
|
|
5
|
+
})(AnimationStatus || (AnimationStatus = {}));
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MoveDirection = void 0;
|
|
4
|
-
var MoveDirection;
|
|
1
|
+
export var MoveDirection;
|
|
5
2
|
(function (MoveDirection) {
|
|
6
3
|
MoveDirection["bottom"] = "bottom";
|
|
7
4
|
MoveDirection["bottomLeft"] = "bottom-left";
|
|
@@ -14,4 +11,4 @@ var MoveDirection;
|
|
|
14
11
|
MoveDirection["topRight"] = "top-right";
|
|
15
12
|
MoveDirection["outside"] = "outside";
|
|
16
13
|
MoveDirection["inside"] = "inside";
|
|
17
|
-
})(MoveDirection || (
|
|
14
|
+
})(MoveDirection || (MoveDirection = {}));
|