@tsparticles/engine 4.0.0-alpha.8 → 4.0.0-beta.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/155.min.js +1 -0
- package/README.md +41 -28
- package/browser/Core/CanvasManager.js +303 -0
- package/browser/Core/Container.js +134 -101
- package/browser/Core/Engine.js +29 -162
- package/browser/Core/Particle.js +197 -183
- package/browser/Core/ParticlesManager.js +363 -0
- package/browser/Core/RenderManager.js +303 -0
- package/browser/Core/Retina.js +6 -6
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +67 -63
- package/browser/Core/Utils/PluginManager.js +145 -0
- package/browser/Core/Utils/Ranges.js +29 -10
- package/browser/Core/Utils/SpatialHashGrid.js +102 -0
- package/browser/Core/Utils/Vectors.js +17 -18
- 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 +12 -1
- package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/browser/Options/Classes/HslAnimation.js +4 -5
- package/browser/Options/Classes/Options.js +67 -8
- 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 +3 -4
- package/browser/Options/Classes/Particles/Fill.js +28 -0
- package/browser/Options/Classes/Particles/Move/Move.js +17 -3
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -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 +29 -9
- package/browser/Options/Classes/Particles/Shape/Shape.js +3 -4
- 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/browser/Options/Classes/ResizeEvent.js +2 -0
- package/browser/Options/Classes/ValueWithRandom.js +3 -4
- package/browser/Utils/CanvasUtils.js +44 -51
- package/browser/Utils/ColorUtils.js +51 -40
- package/browser/Utils/EventDispatcher.js +1 -0
- package/browser/Utils/LogUtils.js +1 -0
- package/browser/Utils/MathUtils.js +12 -7
- package/browser/Utils/OptionsUtils.js +2 -2
- package/browser/Utils/Utils.js +109 -31
- package/browser/exports.js +1 -2
- package/cjs/Core/CanvasManager.js +303 -0
- package/cjs/Core/Container.js +134 -101
- package/cjs/Core/Engine.js +29 -162
- package/cjs/Core/Particle.js +197 -183
- package/cjs/Core/ParticlesManager.js +363 -0
- package/cjs/Core/RenderManager.js +303 -0
- package/cjs/Core/Retina.js +6 -6
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +67 -63
- package/cjs/Core/Utils/PluginManager.js +145 -0
- package/cjs/Core/Utils/Ranges.js +29 -10
- package/cjs/Core/Utils/SpatialHashGrid.js +102 -0
- package/cjs/Core/Utils/Vectors.js +17 -18
- 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 +12 -1
- package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/cjs/Options/Classes/HslAnimation.js +4 -5
- package/cjs/Options/Classes/Options.js +67 -8
- 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 +3 -4
- package/cjs/Options/Classes/Particles/Fill.js +28 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +17 -3
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -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 +29 -9
- package/cjs/Options/Classes/Particles/Shape/Shape.js +3 -4
- 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/ResizeEvent.js +2 -0
- package/cjs/Options/Classes/ValueWithRandom.js +3 -4
- package/cjs/Utils/CanvasUtils.js +44 -51
- package/cjs/Utils/ColorUtils.js +51 -40
- package/cjs/Utils/EventDispatcher.js +1 -0
- package/cjs/Utils/LogUtils.js +1 -0
- package/cjs/Utils/MathUtils.js +12 -7
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/cjs/Utils/Utils.js +109 -31
- package/cjs/exports.js +1 -2
- package/dist_browser_Core_Container_js.js +30 -20
- package/esm/Core/CanvasManager.js +303 -0
- package/esm/Core/Container.js +134 -101
- package/esm/Core/Engine.js +29 -162
- package/esm/Core/Particle.js +197 -183
- package/esm/Core/ParticlesManager.js +363 -0
- package/esm/Core/RenderManager.js +303 -0
- package/esm/Core/Retina.js +6 -6
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +67 -63
- package/esm/Core/Utils/PluginManager.js +145 -0
- package/esm/Core/Utils/Ranges.js +29 -10
- package/esm/Core/Utils/SpatialHashGrid.js +102 -0
- package/esm/Core/Utils/Vectors.js +17 -18
- 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 +12 -1
- package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/esm/Options/Classes/HslAnimation.js +4 -5
- package/esm/Options/Classes/Options.js +67 -8
- 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 +3 -4
- package/esm/Options/Classes/Particles/Fill.js +28 -0
- package/esm/Options/Classes/Particles/Move/Move.js +17 -3
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -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 +29 -9
- package/esm/Options/Classes/Particles/Shape/Shape.js +3 -4
- 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/esm/Options/Classes/ResizeEvent.js +2 -0
- package/esm/Options/Classes/ValueWithRandom.js +3 -4
- package/esm/Utils/CanvasUtils.js +44 -51
- package/esm/Utils/ColorUtils.js +51 -40
- package/esm/Utils/EventDispatcher.js +1 -0
- package/esm/Utils/LogUtils.js +1 -0
- package/esm/Utils/MathUtils.js +12 -7
- package/esm/Utils/OptionsUtils.js +2 -2
- package/esm/Utils/Utils.js +109 -31
- package/esm/exports.js +1 -2
- package/package.json +1 -1
- package/report.html +84 -29
- package/scripts/install.js +4 -20
- package/tsparticles.engine.js +98 -86
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/CanvasManager.d.ts +39 -0
- package/types/Core/Container.d.ts +29 -14
- package/types/Core/Engine.d.ts +2 -61
- package/types/Core/Interfaces/IColorManager.d.ts +0 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +10 -8
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
- package/types/Core/Interfaces/IPalette.d.ts +7 -0
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
- package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
- package/types/Core/Interfaces/IShapeDrawData.d.ts +10 -1
- package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
- package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
- package/types/Core/Particle.d.ts +7 -11
- package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +15 -14
- package/types/Core/RenderManager.d.ts +49 -0
- package/types/Core/Retina.d.ts +0 -2
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/PluginManager.d.ts +62 -0
- package/types/Core/Utils/Ranges.d.ts +4 -1
- package/types/Core/Utils/SpatialHashGrid.d.ts +25 -0
- package/types/Core/Utils/Vectors.d.ts +8 -10
- package/types/Options/Classes/ColorAnimation.d.ts +3 -1
- package/types/Options/Classes/HslAnimation.d.ts +3 -4
- package/types/Options/Classes/Options.d.ts +5 -3
- package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
- package/types/Options/Classes/Particles/Fill.d.ts +12 -0
- package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +5 -5
- package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
- package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
- package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
- package/types/Options/Interfaces/IOptions.d.ts +1 -0
- package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
- package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
- package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
- package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
- package/types/Types/CanvasContextType.d.ts +1 -0
- package/types/Types/EngineInitializers.d.ts +6 -3
- package/types/Utils/CanvasUtils.d.ts +13 -16
- package/types/Utils/ColorUtils.d.ts +11 -10
- package/types/Utils/LogUtils.d.ts +1 -0
- package/types/Utils/MathUtils.d.ts +2 -0
- package/types/Utils/OptionsUtils.d.ts +2 -2
- package/types/Utils/Utils.d.ts +8 -1
- package/types/export-types.d.ts +7 -7
- package/types/exports.d.ts +1 -2
- package/umd/Core/CanvasManager.js +317 -0
- package/umd/Core/Container.js +134 -101
- package/umd/Core/Engine.js +28 -161
- package/umd/Core/Particle.js +198 -184
- package/umd/Core/{Particles.js → ParticlesManager.js} +186 -167
- package/umd/Core/RenderManager.js +317 -0
- package/umd/Core/Retina.js +6 -6
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +67 -63
- package/umd/Core/Utils/PluginManager.js +159 -0
- package/umd/Core/Utils/Ranges.js +28 -9
- package/umd/Core/Utils/SpatialHashGrid.js +116 -0
- package/umd/Core/Utils/Vectors.js +17 -18
- 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 +12 -1
- package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/umd/Options/Classes/HslAnimation.js +5 -6
- package/umd/Options/Classes/Options.js +67 -8
- 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 +3 -4
- package/umd/Options/Classes/Particles/Fill.js +42 -0
- package/umd/Options/Classes/Particles/Move/Move.js +18 -4
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -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 +30 -10
- package/umd/Options/Classes/Particles/Shape/Shape.js +3 -4
- 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/ResizeEvent.js +2 -0
- package/umd/Options/Classes/ValueWithRandom.js +3 -4
- package/umd/Utils/CanvasUtils.js +44 -53
- package/umd/Utils/ColorUtils.js +51 -39
- package/umd/Utils/EventDispatcher.js +1 -0
- package/umd/Utils/LogUtils.js +1 -0
- package/umd/Utils/MathUtils.js +14 -7
- package/umd/Utils/OptionsUtils.js +2 -2
- package/umd/Utils/Utils.js +111 -32
- package/umd/exports.js +2 -3
- package/794.min.js +0 -2
- package/794.min.js.LICENSE.txt +0 -1
- package/browser/Core/Canvas.js +0 -469
- package/browser/Core/Particles.js +0 -344
- package/browser/Core/Utils/Point.js +0 -6
- package/browser/Core/Utils/QuadTree.js +0 -59
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/cjs/Core/Canvas.js +0 -469
- package/cjs/Core/Particles.js +0 -344
- package/cjs/Core/Utils/Point.js +0 -6
- package/cjs/Core/Utils/QuadTree.js +0 -59
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/esm/Core/Canvas.js +0 -469
- package/esm/Core/Particles.js +0 -344
- package/esm/Core/Utils/Point.js +0 -6
- package/esm/Core/Utils/QuadTree.js +0 -59
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/tsparticles.engine.min.js.LICENSE.txt +0 -1
- package/types/Core/Canvas.d.ts +0 -55
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -10
- package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
- package/types/Core/Utils/Point.d.ts +0 -7
- package/types/Core/Utils/QuadTree.d.ts +0 -18
- package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
- package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
- package/umd/Core/Canvas.js +0 -483
- package/umd/Core/Utils/Point.js +0 -20
- package/umd/Core/Utils/QuadTree.js +0 -73
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -47
- /package/browser/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/browser/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/browser/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
- /package/cjs/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/cjs/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/cjs/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
- /package/esm/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/esm/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/esm/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
- /package/umd/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/umd/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/umd/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const generatedAttribute = "generated", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
|
|
1
|
+
export const generatedAttribute = "generated", defaultCompositeValue = "source-over", 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", resizeEvent = "resize", visibilit
|
|
|
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,
|
|
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, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, minVelocity = 0, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, decayOffset = 1, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, lengthOffset = 1, defaultDensityFactor = 1, deleteCount = 1, 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, defaultZoom = 1;
|
|
@@ -1,71 +1,12 @@
|
|
|
1
1
|
import { manageListener, safeDocument } from "../../Utils/Utils.js";
|
|
2
2
|
import { millisecondsToSeconds, resizeEvent, visibilityChangeEvent } from "./Constants.js";
|
|
3
3
|
export class EventListeners {
|
|
4
|
+
container;
|
|
5
|
+
_handlers;
|
|
6
|
+
_resizeObserver;
|
|
7
|
+
_resizeTimeout;
|
|
4
8
|
constructor(container) {
|
|
5
9
|
this.container = container;
|
|
6
|
-
this._handleVisibilityChange = () => {
|
|
7
|
-
const container = this.container, options = container.actualOptions;
|
|
8
|
-
if (!options.pauseOnBlur) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (safeDocument().hidden) {
|
|
12
|
-
container.pageHidden = true;
|
|
13
|
-
container.pause();
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
container.pageHidden = false;
|
|
17
|
-
if (container.animationStatus) {
|
|
18
|
-
container.play(true);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
container.draw(true);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
this._handleWindowResize = () => {
|
|
26
|
-
if (this._resizeTimeout) {
|
|
27
|
-
clearTimeout(this._resizeTimeout);
|
|
28
|
-
delete this._resizeTimeout;
|
|
29
|
-
}
|
|
30
|
-
const handleResize = async () => {
|
|
31
|
-
const canvas = this.container.canvas;
|
|
32
|
-
await canvas.windowResize();
|
|
33
|
-
};
|
|
34
|
-
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
35
|
-
};
|
|
36
|
-
this._manageListeners = add => {
|
|
37
|
-
const handlers = this._handlers;
|
|
38
|
-
this._manageResize(add);
|
|
39
|
-
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
40
|
-
};
|
|
41
|
-
this._manageResize = add => {
|
|
42
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
43
|
-
if (!options.resize.enable) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (typeof ResizeObserver === "undefined") {
|
|
47
|
-
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const canvasEl = container.canvas.element;
|
|
51
|
-
if (this._resizeObserver && !add) {
|
|
52
|
-
if (canvasEl) {
|
|
53
|
-
this._resizeObserver.unobserve(canvasEl);
|
|
54
|
-
}
|
|
55
|
-
this._resizeObserver.disconnect();
|
|
56
|
-
delete this._resizeObserver;
|
|
57
|
-
}
|
|
58
|
-
else if (!this._resizeObserver && add && canvasEl) {
|
|
59
|
-
this._resizeObserver = new ResizeObserver((entries) => {
|
|
60
|
-
const entry = entries.find(e => e.target === canvasEl);
|
|
61
|
-
if (!entry) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this._handleWindowResize();
|
|
65
|
-
});
|
|
66
|
-
this._resizeObserver.observe(canvasEl);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
10
|
this._handlers = {
|
|
70
11
|
visibilityChange: () => {
|
|
71
12
|
this._handleVisibilityChange();
|
|
@@ -81,4 +22,67 @@ export class EventListeners {
|
|
|
81
22
|
removeListeners() {
|
|
82
23
|
this._manageListeners(false);
|
|
83
24
|
}
|
|
25
|
+
_handleVisibilityChange = () => {
|
|
26
|
+
const container = this.container, options = container.actualOptions;
|
|
27
|
+
if (!options.pauseOnBlur) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (safeDocument().hidden) {
|
|
31
|
+
container.pageHidden = true;
|
|
32
|
+
container.pause();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
container.pageHidden = false;
|
|
36
|
+
if (container.animationStatus) {
|
|
37
|
+
container.play(true);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
container.draw(true);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
_handleWindowResize = () => {
|
|
45
|
+
if (this._resizeTimeout) {
|
|
46
|
+
clearTimeout(this._resizeTimeout);
|
|
47
|
+
delete this._resizeTimeout;
|
|
48
|
+
}
|
|
49
|
+
const handleResize = async () => {
|
|
50
|
+
const canvas = this.container.canvas;
|
|
51
|
+
await canvas.windowResize();
|
|
52
|
+
};
|
|
53
|
+
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * millisecondsToSeconds);
|
|
54
|
+
};
|
|
55
|
+
_manageListeners = add => {
|
|
56
|
+
const handlers = this._handlers;
|
|
57
|
+
this._manageResize(add);
|
|
58
|
+
manageListener(document, visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
59
|
+
};
|
|
60
|
+
_manageResize = add => {
|
|
61
|
+
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
62
|
+
if (!options.resize.enable) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof ResizeObserver === "undefined") {
|
|
66
|
+
manageListener(globalThis, resizeEvent, handlers.resize, add);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const canvasEl = container.canvas.element;
|
|
70
|
+
if (this._resizeObserver && !add) {
|
|
71
|
+
if (canvasEl) {
|
|
72
|
+
this._resizeObserver.unobserve(canvasEl);
|
|
73
|
+
}
|
|
74
|
+
this._resizeObserver.disconnect();
|
|
75
|
+
delete this._resizeObserver;
|
|
76
|
+
}
|
|
77
|
+
else if (!this._resizeObserver && add && canvasEl) {
|
|
78
|
+
this._resizeObserver = new ResizeObserver((entries) => {
|
|
79
|
+
const entry = entries.find(e => e.target === canvasEl);
|
|
80
|
+
if (!entry) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this._handleWindowResize();
|
|
84
|
+
});
|
|
85
|
+
this._resizeObserver.observe(canvasEl);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
84
88
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { getItemMapFromInitializer, getItemsFromInitializer } from "../../Utils/Utils.js";
|
|
2
|
+
import { EventType } from "../../Enums/Types/EventType.js";
|
|
3
|
+
export class PluginManager {
|
|
4
|
+
colorManagers = new Map();
|
|
5
|
+
easingFunctions = new Map();
|
|
6
|
+
effectDrawers = new Map();
|
|
7
|
+
initializers = {
|
|
8
|
+
effects: new Map(),
|
|
9
|
+
shapes: new Map(),
|
|
10
|
+
updaters: new Map(),
|
|
11
|
+
};
|
|
12
|
+
palettes = new Map();
|
|
13
|
+
plugins = [];
|
|
14
|
+
presets = new Map();
|
|
15
|
+
shapeDrawers = new Map();
|
|
16
|
+
updaters = new Map();
|
|
17
|
+
_allLoadersSet = new Set();
|
|
18
|
+
_configs = new Map();
|
|
19
|
+
_engine;
|
|
20
|
+
_executedSet = new Set();
|
|
21
|
+
_initialized = false;
|
|
22
|
+
_isRunningLoaders = false;
|
|
23
|
+
_loadPromises = new Set();
|
|
24
|
+
constructor(engine) {
|
|
25
|
+
this._engine = engine;
|
|
26
|
+
}
|
|
27
|
+
get configs() {
|
|
28
|
+
const res = {};
|
|
29
|
+
for (const [name, config] of this._configs) {
|
|
30
|
+
res[name] = config;
|
|
31
|
+
}
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
addColorManager(name, manager) {
|
|
35
|
+
this.colorManagers.set(name, manager);
|
|
36
|
+
}
|
|
37
|
+
addConfig(config) {
|
|
38
|
+
const key = config.key ?? config.name ?? "default";
|
|
39
|
+
this._configs.set(key, config);
|
|
40
|
+
this._engine.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
|
|
41
|
+
}
|
|
42
|
+
addEasing(name, easing) {
|
|
43
|
+
if (this.easingFunctions.get(name)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.easingFunctions.set(name, easing);
|
|
47
|
+
}
|
|
48
|
+
addEffect(effect, drawer) {
|
|
49
|
+
this.initializers.effects.set(effect, drawer);
|
|
50
|
+
}
|
|
51
|
+
addPalette(name, palette) {
|
|
52
|
+
this.palettes.set(name, palette);
|
|
53
|
+
}
|
|
54
|
+
addParticleUpdater(name, updaterInitializer) {
|
|
55
|
+
this.initializers.updaters.set(name, updaterInitializer);
|
|
56
|
+
}
|
|
57
|
+
addPlugin(plugin) {
|
|
58
|
+
if (this.getPlugin(plugin.id)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.plugins.push(plugin);
|
|
62
|
+
}
|
|
63
|
+
addPreset(preset, options, override = false) {
|
|
64
|
+
if (!(override || !this.getPreset(preset))) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.presets.set(preset, options);
|
|
68
|
+
}
|
|
69
|
+
addShape(shapes, drawer) {
|
|
70
|
+
for (const shape of shapes) {
|
|
71
|
+
this.initializers.shapes.set(shape, drawer);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
clearPlugins(container) {
|
|
75
|
+
this.effectDrawers.delete(container);
|
|
76
|
+
this.shapeDrawers.delete(container);
|
|
77
|
+
this.updaters.delete(container);
|
|
78
|
+
}
|
|
79
|
+
getEasing(name) {
|
|
80
|
+
return this.easingFunctions.get(name) ?? ((value) => value);
|
|
81
|
+
}
|
|
82
|
+
getEffectDrawers(container, force = false) {
|
|
83
|
+
return getItemMapFromInitializer(container, this.effectDrawers, this.initializers.effects, force);
|
|
84
|
+
}
|
|
85
|
+
getPalette(name) {
|
|
86
|
+
return this.palettes.get(name);
|
|
87
|
+
}
|
|
88
|
+
getPlugin(plugin) {
|
|
89
|
+
return this.plugins.find(t => t.id === plugin);
|
|
90
|
+
}
|
|
91
|
+
getPreset(preset) {
|
|
92
|
+
return this.presets.get(preset);
|
|
93
|
+
}
|
|
94
|
+
async getShapeDrawers(container, force = false) {
|
|
95
|
+
return getItemMapFromInitializer(container, this.shapeDrawers, this.initializers.shapes, force);
|
|
96
|
+
}
|
|
97
|
+
async getUpdaters(container, force = false) {
|
|
98
|
+
return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
|
|
99
|
+
}
|
|
100
|
+
async init() {
|
|
101
|
+
if (this._initialized || this._isRunningLoaders) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this._isRunningLoaders = true;
|
|
105
|
+
this._executedSet = new Set();
|
|
106
|
+
this._allLoadersSet = new Set(this._loadPromises);
|
|
107
|
+
try {
|
|
108
|
+
for (const loader of this._allLoadersSet) {
|
|
109
|
+
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
this._loadPromises.clear();
|
|
114
|
+
this._isRunningLoaders = false;
|
|
115
|
+
this._initialized = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
loadParticlesOptions(container, options, ...sourceOptions) {
|
|
119
|
+
const updaters = this.updaters.get(container);
|
|
120
|
+
if (!updaters) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
|
|
124
|
+
}
|
|
125
|
+
async register(...loaders) {
|
|
126
|
+
if (this._initialized) {
|
|
127
|
+
throw new Error("Register plugins can only be done before calling tsParticles.load()");
|
|
128
|
+
}
|
|
129
|
+
for (const loader of loaders) {
|
|
130
|
+
if (this._isRunningLoaders) {
|
|
131
|
+
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this._loadPromises.add(loader);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async _runLoader(loader, executed, allLoaders) {
|
|
139
|
+
if (executed.has(loader))
|
|
140
|
+
return;
|
|
141
|
+
executed.add(loader);
|
|
142
|
+
allLoaders.add(loader);
|
|
143
|
+
await loader(this._engine);
|
|
144
|
+
}
|
|
145
|
+
}
|
package/cjs/Core/Utils/Ranges.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { RangeType } from "../../Enums/RangeType.js";
|
|
2
|
-
import {
|
|
2
|
+
import { checkDistance } from "../../Utils/MathUtils.js";
|
|
3
3
|
import { squareExp } from "./Constants.js";
|
|
4
4
|
export class BaseRange {
|
|
5
|
+
position;
|
|
6
|
+
type;
|
|
5
7
|
constructor(x, y, type) {
|
|
6
8
|
this.position = {
|
|
7
9
|
x: x,
|
|
@@ -9,32 +11,40 @@ export class BaseRange {
|
|
|
9
11
|
};
|
|
10
12
|
this.type = type;
|
|
11
13
|
}
|
|
14
|
+
_resetPosition(x, y) {
|
|
15
|
+
this.position.x = x;
|
|
16
|
+
this.position.y = y;
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
export class Circle extends BaseRange {
|
|
20
|
+
radius;
|
|
14
21
|
constructor(x, y, radius) {
|
|
15
22
|
super(x, y, RangeType.circle);
|
|
16
23
|
this.radius = radius;
|
|
17
24
|
}
|
|
18
25
|
contains(point) {
|
|
19
|
-
return
|
|
26
|
+
return checkDistance(point, this.position, this.radius);
|
|
20
27
|
}
|
|
21
28
|
intersects(range) {
|
|
22
|
-
const pos1 = this.position, pos2 = range.position,
|
|
29
|
+
const pos1 = this.position, pos2 = range.position, r = this.radius, dx = Math.abs(pos2.x - pos1.x), dy = Math.abs(pos2.y - pos1.y);
|
|
23
30
|
if (range instanceof Circle || range.type === RangeType.circle) {
|
|
24
|
-
const circleRange = range, rSum = r + circleRange.radius, dist = Math.
|
|
31
|
+
const circleRange = range, rSum = r + circleRange.radius, dist = Math.hypot(dx, dy);
|
|
25
32
|
return rSum > dist;
|
|
26
33
|
}
|
|
27
34
|
else if (range instanceof Rectangle || range.type === RangeType.rectangle) {
|
|
28
|
-
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(
|
|
29
|
-
return
|
|
30
|
-
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
31
|
-
distPos.x <= width ||
|
|
32
|
-
distPos.y <= height);
|
|
35
|
+
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(dx - width, squareExp) + Math.pow(dy - height, squareExp);
|
|
36
|
+
return edges <= r ** squareExp || (dx <= r + width && dy <= r + height) || dx <= width || dy <= height;
|
|
33
37
|
}
|
|
34
38
|
return false;
|
|
35
39
|
}
|
|
40
|
+
reset(x, y, radius) {
|
|
41
|
+
this._resetPosition(x, y);
|
|
42
|
+
this.radius = radius;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
36
45
|
}
|
|
37
46
|
export class Rectangle extends BaseRange {
|
|
47
|
+
size;
|
|
38
48
|
constructor(x, y, width, height) {
|
|
39
49
|
super(x, y, RangeType.rectangle);
|
|
40
50
|
this.size = {
|
|
@@ -50,7 +60,16 @@ export class Rectangle extends BaseRange {
|
|
|
50
60
|
if (range instanceof Circle) {
|
|
51
61
|
return range.intersects(this);
|
|
52
62
|
}
|
|
53
|
-
|
|
63
|
+
if (!(range instanceof Rectangle)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range.size, w2 = size2.width, h2 = size2.height;
|
|
54
67
|
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
55
68
|
}
|
|
69
|
+
reset(x, y, width, height) {
|
|
70
|
+
this._resetPosition(x, y);
|
|
71
|
+
this.size.width = width;
|
|
72
|
+
this.size.height = height;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
56
75
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Circle, Rectangle } from "./Ranges.js";
|
|
2
|
+
export class SpatialHashGrid {
|
|
3
|
+
_cellSize;
|
|
4
|
+
_cells = new Map();
|
|
5
|
+
_circlePool = [];
|
|
6
|
+
_circlePoolIdx;
|
|
7
|
+
_pendingCellSize;
|
|
8
|
+
_rectanglePool = [];
|
|
9
|
+
_rectanglePoolIdx;
|
|
10
|
+
constructor(cellSize) {
|
|
11
|
+
this._cellSize = cellSize;
|
|
12
|
+
this._circlePoolIdx = 0;
|
|
13
|
+
this._rectanglePoolIdx = 0;
|
|
14
|
+
}
|
|
15
|
+
clear() {
|
|
16
|
+
this._cells.clear();
|
|
17
|
+
const pendingCellSize = this._pendingCellSize;
|
|
18
|
+
if (pendingCellSize) {
|
|
19
|
+
this._cellSize = pendingCellSize;
|
|
20
|
+
}
|
|
21
|
+
this._pendingCellSize = undefined;
|
|
22
|
+
}
|
|
23
|
+
insert(particle) {
|
|
24
|
+
const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
|
|
25
|
+
if (!this._cells.has(key)) {
|
|
26
|
+
this._cells.set(key, []);
|
|
27
|
+
}
|
|
28
|
+
this._cells.get(key)?.push(particle);
|
|
29
|
+
}
|
|
30
|
+
query(range, check, out = []) {
|
|
31
|
+
const bounds = this._getRangeBounds(range);
|
|
32
|
+
if (!bounds) {
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
const minCellX = Math.floor(bounds.minX / this._cellSize), maxCellX = Math.floor(bounds.maxX / this._cellSize), minCellY = Math.floor(bounds.minY / this._cellSize), maxCellY = Math.floor(bounds.maxY / this._cellSize);
|
|
36
|
+
for (let cx = minCellX; cx <= maxCellX; cx++) {
|
|
37
|
+
for (let cy = minCellY; cy <= maxCellY; cy++) {
|
|
38
|
+
const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
|
|
39
|
+
if (!cellParticles) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
for (const p of cellParticles) {
|
|
43
|
+
if (check && !check(p)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (range.contains(p.getPosition())) {
|
|
47
|
+
out.push(p);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
queryCircle(position, radius, check, out = []) {
|
|
55
|
+
const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
|
|
56
|
+
this._releaseShapes();
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
queryRectangle(position, size, check, out = []) {
|
|
60
|
+
const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
|
|
61
|
+
this._releaseShapes();
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
setCellSize(cellSize) {
|
|
65
|
+
this._pendingCellSize = cellSize;
|
|
66
|
+
}
|
|
67
|
+
_acquireCircle(x, y, r) {
|
|
68
|
+
return (this._circlePool[this._circlePoolIdx++] ??= new Circle(x, y, r)).reset(x, y, r);
|
|
69
|
+
}
|
|
70
|
+
_acquireRectangle(x, y, w, h) {
|
|
71
|
+
return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Rectangle(x, y, w, h)).reset(x, y, w, h);
|
|
72
|
+
}
|
|
73
|
+
_cellKeyFromCoords(x, y) {
|
|
74
|
+
const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
|
|
75
|
+
return `${cellX}_${cellY}`;
|
|
76
|
+
}
|
|
77
|
+
_getRangeBounds(range) {
|
|
78
|
+
if (range instanceof Circle) {
|
|
79
|
+
const r = range.radius, { x, y } = range.position;
|
|
80
|
+
return {
|
|
81
|
+
minX: x - r,
|
|
82
|
+
maxX: x + r,
|
|
83
|
+
minY: y - r,
|
|
84
|
+
maxY: y + r,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (range instanceof Rectangle) {
|
|
88
|
+
const { x, y } = range.position, { width, height } = range.size;
|
|
89
|
+
return {
|
|
90
|
+
minX: x,
|
|
91
|
+
maxX: x + width,
|
|
92
|
+
minY: y,
|
|
93
|
+
maxY: y + height,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
_releaseShapes() {
|
|
99
|
+
this._circlePoolIdx = 0;
|
|
100
|
+
this._rectanglePoolIdx = 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { inverseFactorNumerator, none, originPoint, squareExp } from "./Constants.js";
|
|
2
|
+
function getZ(source) {
|
|
3
|
+
return "z" in source ? source.z : originPoint.z;
|
|
4
|
+
}
|
|
2
5
|
export class Vector3d {
|
|
6
|
+
x;
|
|
7
|
+
y;
|
|
8
|
+
z;
|
|
3
9
|
constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
|
|
4
|
-
this._updateFromAngle = (angle, length) => {
|
|
5
|
-
this.x = Math.cos(angle) * length;
|
|
6
|
-
this.y = Math.sin(angle) * length;
|
|
7
|
-
};
|
|
8
10
|
this.x = x;
|
|
9
11
|
this.y = y;
|
|
10
12
|
this.z = z;
|
|
@@ -25,31 +27,25 @@ export class Vector3d {
|
|
|
25
27
|
this._updateFromAngle(this.angle, length);
|
|
26
28
|
}
|
|
27
29
|
static clone(source) {
|
|
28
|
-
return Vector3d.create(source.x, source.y, source
|
|
30
|
+
return Vector3d.create(source.x, source.y, getZ(source));
|
|
29
31
|
}
|
|
30
32
|
static create(x, y, z) {
|
|
31
33
|
if (typeof x === "number") {
|
|
32
34
|
return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
|
|
33
35
|
}
|
|
34
|
-
return new Vector3d(x.x, x.y,
|
|
36
|
+
return new Vector3d(x.x, x.y, getZ(x));
|
|
35
37
|
}
|
|
36
38
|
add(v) {
|
|
37
|
-
return Vector3d.create(this.x + v.x, this.y + v.y, this.z + v
|
|
39
|
+
return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
|
|
38
40
|
}
|
|
39
41
|
addTo(v) {
|
|
40
42
|
this.x += v.x;
|
|
41
43
|
this.y += v.y;
|
|
42
|
-
this.z += v
|
|
44
|
+
this.z += getZ(v);
|
|
43
45
|
}
|
|
44
46
|
copy() {
|
|
45
47
|
return Vector3d.clone(this);
|
|
46
48
|
}
|
|
47
|
-
distanceTo(v) {
|
|
48
|
-
return this.sub(v).length;
|
|
49
|
-
}
|
|
50
|
-
distanceToSq(v) {
|
|
51
|
-
return this.sub(v).getLengthSq();
|
|
52
|
-
}
|
|
53
49
|
div(n) {
|
|
54
50
|
return Vector3d.create(this.x / n, this.y / n, this.z / n);
|
|
55
51
|
}
|
|
@@ -81,16 +77,19 @@ export class Vector3d {
|
|
|
81
77
|
setTo(c) {
|
|
82
78
|
this.x = c.x;
|
|
83
79
|
this.y = c.y;
|
|
84
|
-
|
|
85
|
-
this.z = v3d.z ? v3d.z : originPoint.z;
|
|
80
|
+
this.z = getZ(c);
|
|
86
81
|
}
|
|
87
82
|
sub(v) {
|
|
88
|
-
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - v
|
|
83
|
+
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
|
|
89
84
|
}
|
|
90
85
|
subFrom(v) {
|
|
91
86
|
this.x -= v.x;
|
|
92
87
|
this.y -= v.y;
|
|
93
|
-
this.z -= v
|
|
88
|
+
this.z -= getZ(v);
|
|
89
|
+
}
|
|
90
|
+
_updateFromAngle(angle, length) {
|
|
91
|
+
this.x = Math.cos(angle) * length;
|
|
92
|
+
this.y = Math.sin(angle) * length;
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
export class Vector extends Vector3d {
|
|
@@ -2,6 +2,7 @@ import { isArray, isNull, isString } from "../../Utils/TypeUtils.js";
|
|
|
2
2
|
import { HslAnimation } from "./HslAnimation.js";
|
|
3
3
|
import { OptionsColor } from "./OptionsColor.js";
|
|
4
4
|
export class AnimatableColor extends OptionsColor {
|
|
5
|
+
animation;
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
8
|
this.animation = new HslAnimation();
|
|
@@ -3,6 +3,12 @@ import { StartValueType } from "../../Enums/Types/StartValueType.js";
|
|
|
3
3
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
4
4
|
import { setRangeValue } from "../../Utils/MathUtils.js";
|
|
5
5
|
export class AnimationOptions {
|
|
6
|
+
count;
|
|
7
|
+
decay;
|
|
8
|
+
delay;
|
|
9
|
+
enable;
|
|
10
|
+
speed;
|
|
11
|
+
sync;
|
|
6
12
|
constructor() {
|
|
7
13
|
this.count = 0;
|
|
8
14
|
this.enable = false;
|
|
@@ -36,6 +42,8 @@ export class AnimationOptions {
|
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
export class RangedAnimationOptions extends AnimationOptions {
|
|
45
|
+
mode;
|
|
46
|
+
startValue;
|
|
39
47
|
constructor() {
|
|
40
48
|
super();
|
|
41
49
|
this.mode = AnimationMode.auto;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { OptionsColor } from "../OptionsColor.js";
|
|
2
2
|
import { isNull } from "../../../Utils/TypeUtils.js";
|
|
3
3
|
export class Background {
|
|
4
|
+
color;
|
|
5
|
+
image;
|
|
6
|
+
opacity;
|
|
7
|
+
position;
|
|
8
|
+
repeat;
|
|
9
|
+
size;
|
|
4
10
|
constructor() {
|
|
5
11
|
this.color = new OptionsColor();
|
|
6
12
|
this.color.value = "";
|
|
@@ -2,8 +2,13 @@ import { AnimationOptions } from "./AnimationOptions.js";
|
|
|
2
2
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
3
3
|
import { setRangeValue } from "../../Utils/MathUtils.js";
|
|
4
4
|
export class ColorAnimation extends AnimationOptions {
|
|
5
|
-
|
|
5
|
+
max;
|
|
6
|
+
min;
|
|
7
|
+
offset;
|
|
8
|
+
constructor(min, max) {
|
|
6
9
|
super();
|
|
10
|
+
this.min = min;
|
|
11
|
+
this.max = max;
|
|
7
12
|
this.offset = 0;
|
|
8
13
|
this.sync = true;
|
|
9
14
|
}
|
|
@@ -12,6 +17,12 @@ export class ColorAnimation extends AnimationOptions {
|
|
|
12
17
|
if (isNull(data)) {
|
|
13
18
|
return;
|
|
14
19
|
}
|
|
20
|
+
if (data.max !== undefined) {
|
|
21
|
+
this.max = data.max;
|
|
22
|
+
}
|
|
23
|
+
if (data.min !== undefined) {
|
|
24
|
+
this.min = data.min;
|
|
25
|
+
}
|
|
15
26
|
if (data.offset !== undefined) {
|
|
16
27
|
this.offset = setRangeValue(data.offset);
|
|
17
28
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { hMax, hMin, lMax, lMin, sMax, sMin } from "../../Core/Utils/Constants.js";
|
|
1
2
|
import { ColorAnimation } from "./ColorAnimation.js";
|
|
2
3
|
import { isNull } from "../../Utils/TypeUtils.js";
|
|
3
4
|
export class HslAnimation {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.l = new ColorAnimation();
|
|
8
|
-
}
|
|
5
|
+
h = new ColorAnimation(hMin, hMax);
|
|
6
|
+
l = new ColorAnimation(lMin, lMax);
|
|
7
|
+
s = new ColorAnimation(sMin, sMax);
|
|
9
8
|
load(data) {
|
|
10
9
|
if (isNull(data)) {
|
|
11
10
|
return;
|