@tsparticles/engine 3.0.0-alpha.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +246 -211
- package/browser/Core/Canvas.js +271 -241
- package/browser/Core/Container.js +90 -106
- package/browser/Core/Engine.js +271 -0
- package/browser/Core/Particle.js +158 -162
- package/browser/Core/Particles.js +148 -134
- package/browser/Core/Retina.js +15 -13
- package/browser/Core/Utils/Circle.js +10 -6
- package/browser/Core/Utils/Constants.js +4 -3
- package/browser/Core/Utils/EventListeners.js +259 -220
- package/browser/Core/Utils/InteractionManager.js +6 -16
- package/browser/Core/Utils/QuadTree.js +14 -20
- package/browser/Core/Utils/Vector3d.js +17 -9
- package/browser/Options/Classes/AnimatableColor.js +2 -1
- package/browser/Options/Classes/AnimationOptions.js +7 -2
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
- package/browser/Options/Classes/ColorAnimation.js +4 -0
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/browser/Options/Classes/Interactivity/Events/Events.js +5 -24
- package/browser/Options/Classes/Interactivity/Interactivity.js +1 -8
- package/browser/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/browser/Options/Classes/ManualParticle.js +5 -5
- package/browser/Options/Classes/Options.js +19 -39
- package/browser/Options/Classes/OptionsColor.js +3 -2
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +5 -0
- package/browser/Options/Classes/Particles/Move/Move.js +11 -41
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +9 -20
- package/browser/Options/Classes/Particles/Move/MoveTrail.js +2 -8
- package/browser/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/browser/Options/Classes/Particles/Move/Spin.js +3 -1
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +11 -7
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
- package/browser/Options/Classes/Particles/ParticlesOptions.js +6 -11
- package/browser/Options/Classes/Particles/Shape/Shape.js +9 -2
- package/browser/Options/Classes/Particles/Size/Size.js +11 -7
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
- package/browser/Options/Classes/ValueWithRandom.js +4 -17
- package/browser/Utils/CanvasUtils.js +18 -54
- package/browser/Utils/ColorUtils.js +17 -19
- package/browser/Utils/EventDispatcher.js +7 -6
- package/browser/Utils/HslColorManager.js +2 -4
- package/browser/Utils/NumberUtils.js +41 -45
- package/browser/Utils/RgbColorManager.js +2 -4
- package/browser/Utils/Utils.js +150 -59
- package/browser/bundle.js +4 -96
- package/browser/export-types.js +97 -0
- package/browser/exports.js +89 -0
- package/browser/index.js +8 -198
- package/browser/init.js +12 -0
- package/cjs/Core/Canvas.js +269 -239
- package/cjs/Core/Container.js +90 -106
- package/cjs/Core/Engine.js +275 -0
- package/cjs/Core/Particle.js +157 -161
- package/cjs/Core/Particles.js +148 -134
- package/cjs/Core/Retina.js +15 -13
- package/cjs/Core/Utils/Circle.js +10 -6
- package/cjs/Core/Utils/Constants.js +5 -4
- package/cjs/Core/Utils/EventListeners.js +258 -219
- package/cjs/Core/Utils/InteractionManager.js +6 -16
- package/cjs/Core/Utils/QuadTree.js +14 -20
- package/cjs/Core/Utils/Vector3d.js +17 -9
- package/cjs/Options/Classes/AnimatableColor.js +2 -1
- package/cjs/Options/Classes/AnimationOptions.js +7 -2
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
- package/cjs/Options/Classes/ColorAnimation.js +4 -0
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/cjs/Options/Classes/Interactivity/Events/Events.js +5 -24
- package/cjs/Options/Classes/Interactivity/Interactivity.js +1 -8
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/cjs/Options/Classes/ManualParticle.js +5 -5
- package/cjs/Options/Classes/Options.js +18 -38
- package/cjs/Options/Classes/OptionsColor.js +3 -2
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +11 -41
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +9 -20
- package/cjs/Options/Classes/Particles/Move/MoveTrail.js +2 -8
- package/cjs/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/cjs/Options/Classes/Particles/Move/Spin.js +3 -1
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +10 -6
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +6 -11
- package/cjs/Options/Classes/Particles/Shape/Shape.js +9 -2
- package/cjs/Options/Classes/Particles/Size/Size.js +11 -7
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
- package/cjs/Options/Classes/ValueWithRandom.js +4 -17
- package/cjs/Utils/CanvasUtils.js +21 -58
- package/cjs/Utils/ColorUtils.js +16 -18
- package/cjs/Utils/EventDispatcher.js +7 -6
- package/cjs/Utils/HslColorManager.js +2 -4
- package/cjs/Utils/NumberUtils.js +41 -45
- package/cjs/Utils/RgbColorManager.js +2 -4
- package/cjs/Utils/Utils.js +163 -63
- package/cjs/bundle.js +4 -96
- package/cjs/export-types.js +113 -0
- package/cjs/exports.js +105 -0
- package/cjs/index.js +8 -198
- package/cjs/init.js +16 -0
- package/esm/Core/Canvas.js +271 -241
- package/esm/Core/Container.js +90 -106
- package/esm/Core/Engine.js +271 -0
- package/esm/Core/Particle.js +158 -162
- package/esm/Core/Particles.js +148 -134
- package/esm/Core/Retina.js +15 -13
- package/esm/Core/Utils/Circle.js +10 -6
- package/esm/Core/Utils/Constants.js +4 -3
- package/esm/Core/Utils/EventListeners.js +259 -220
- package/esm/Core/Utils/InteractionManager.js +6 -16
- package/esm/Core/Utils/QuadTree.js +14 -20
- package/esm/Core/Utils/Vector3d.js +17 -9
- package/esm/Options/Classes/AnimatableColor.js +2 -1
- package/esm/Options/Classes/AnimationOptions.js +7 -2
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
- package/esm/Options/Classes/ColorAnimation.js +4 -0
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
- package/esm/Options/Classes/Interactivity/Events/Events.js +5 -24
- package/esm/Options/Classes/Interactivity/Interactivity.js +1 -8
- package/esm/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/esm/Options/Classes/ManualParticle.js +5 -5
- package/esm/Options/Classes/Options.js +19 -39
- package/esm/Options/Classes/OptionsColor.js +3 -2
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +5 -0
- package/esm/Options/Classes/Particles/Move/Move.js +11 -41
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +9 -20
- package/esm/Options/Classes/Particles/Move/MoveTrail.js +2 -8
- package/esm/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/esm/Options/Classes/Particles/Move/Spin.js +3 -1
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +11 -7
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
- package/esm/Options/Classes/Particles/ParticlesOptions.js +6 -11
- package/esm/Options/Classes/Particles/Shape/Shape.js +9 -2
- package/esm/Options/Classes/Particles/Size/Size.js +11 -7
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
- package/esm/Options/Classes/ValueWithRandom.js +4 -17
- package/esm/Utils/CanvasUtils.js +18 -54
- package/esm/Utils/ColorUtils.js +17 -19
- package/esm/Utils/EventDispatcher.js +7 -6
- package/esm/Utils/HslColorManager.js +2 -4
- package/esm/Utils/NumberUtils.js +41 -45
- package/esm/Utils/RgbColorManager.js +2 -4
- package/esm/Utils/Utils.js +150 -59
- package/esm/bundle.js +4 -96
- package/esm/export-types.js +97 -0
- package/esm/exports.js +89 -0
- package/esm/index.js +8 -198
- package/esm/init.js +12 -0
- package/package.json +17 -2
- package/report.html +4 -4
- package/scripts/install.js +90 -33
- package/tsparticles.engine.js +1848 -1961
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -10
- package/types/Core/Canvas.d.ts +20 -16
- package/types/Core/Container.d.ts +10 -14
- package/types/Core/Engine.d.ts +71 -0
- package/types/Core/Interfaces/IContainerPlugin.d.ts +2 -0
- package/types/Core/Interfaces/ICoordinates.d.ts +5 -3
- package/types/Core/Interfaces/IDimension.d.ts +4 -0
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +2 -1
- package/types/Core/Interfaces/IParticleUpdater.d.ts +0 -2
- package/types/Core/Interfaces/IParticleValueAnimation.d.ts +2 -0
- package/types/Core/Interfaces/IPlugin.d.ts +4 -3
- package/types/Core/Particle.d.ts +7 -7
- package/types/Core/Particles.d.ts +14 -10
- package/types/Core/Utils/Constants.d.ts +4 -3
- package/types/Core/Utils/EventListeners.d.ts +20 -14
- package/types/Core/Utils/InteractionManager.d.ts +1 -1
- package/types/Core/Utils/QuadTree.d.ts +2 -5
- package/types/Core/Utils/Vector3d.d.ts +2 -1
- package/types/Enums/Modes/AnimationMode.d.ts +6 -0
- package/types/Enums/Modes/{SizeMode.d.ts → PixelMode.d.ts} +1 -1
- package/types/Options/Classes/AnimationOptions.d.ts +3 -1
- package/types/Options/Classes/ColorAnimation.d.ts +1 -0
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -6
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -6
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +1 -3
- package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +1 -1
- package/types/Options/Classes/ManualParticle.d.ts +2 -2
- package/types/Options/Classes/Options.d.ts +5 -12
- package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +2 -0
- package/types/Options/Classes/Particles/Move/Move.d.ts +0 -11
- package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -4
- package/types/Options/Classes/Particles/Move/MoveCenter.d.ts +2 -2
- package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -3
- package/types/Options/Classes/Particles/Move/Spin.d.ts +2 -2
- package/types/Options/Classes/Particles/Number/ParticlesDensity.d.ts +0 -6
- package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +0 -2
- package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +4 -4
- package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +0 -2
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +1 -1
- package/types/Options/Classes/Particles/Shape/Shape.d.ts +2 -0
- package/types/Options/Classes/Particles/Size/Size.d.ts +4 -4
- package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +0 -2
- package/types/Options/Classes/Responsive.d.ts +3 -3
- package/types/Options/Classes/Theme/Theme.d.ts +2 -2
- package/types/Options/Classes/ValueWithRandom.d.ts +2 -6
- package/types/Options/Interfaces/IAnimation.d.ts +3 -1
- package/types/Options/Interfaces/IManualParticle.d.ts +2 -2
- package/types/Options/Interfaces/IOptions.d.ts +1 -4
- package/types/Options/Interfaces/IResponsive.d.ts +4 -3
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -3
- package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -3
- package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -1
- package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +2 -0
- package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -1
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -5
- package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -2
- package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -2
- package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Number/IParticlesDensity.d.ts +0 -3
- package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -0
- package/types/Options/Interfaces/Particles/Size/ISize.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +0 -1
- package/types/Options/Interfaces/Theme/ITheme.d.ts +3 -2
- package/types/Types/ExportResult.d.ts +5 -0
- package/types/Utils/CanvasUtils.d.ts +2 -5
- package/types/Utils/OptionsUtils.d.ts +1 -1
- package/types/Utils/Utils.d.ts +22 -4
- package/types/bundle.d.ts +2 -90
- package/types/export-types.d.ts +107 -0
- package/types/exports.d.ts +89 -0
- package/types/index.d.ts +3 -203
- package/types/init.d.ts +2 -0
- package/umd/Core/Canvas.js +269 -239
- package/umd/Core/Container.js +91 -107
- package/umd/Core/Engine.js +285 -0
- package/umd/Core/Particle.js +158 -162
- package/umd/Core/Particles.js +149 -135
- package/umd/Core/Retina.js +15 -13
- package/umd/Core/Utils/Circle.js +11 -7
- package/umd/Core/Utils/Constants.js +5 -4
- package/umd/Core/Utils/EventListeners.js +258 -219
- package/umd/Core/Utils/InteractionManager.js +6 -16
- package/umd/Core/Utils/QuadTree.js +14 -20
- package/umd/Core/Utils/Vector3d.js +18 -10
- package/umd/Options/Classes/AnimatableColor.js +3 -2
- package/umd/Options/Classes/AnimationOptions.js +7 -2
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
- package/umd/Options/Classes/ColorAnimation.js +4 -0
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +1 -25
- package/umd/Options/Classes/Interactivity/Events/Events.js +6 -25
- package/umd/Options/Classes/Interactivity/Interactivity.js +1 -8
- package/umd/Options/Classes/Interactivity/Modes/Modes.js +11 -8
- package/umd/Options/Classes/ManualParticle.js +5 -5
- package/umd/Options/Classes/Options.js +18 -38
- package/umd/Options/Classes/OptionsColor.js +4 -3
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +6 -1
- package/umd/Options/Classes/Particles/Move/Move.js +12 -42
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +9 -20
- package/umd/Options/Classes/Particles/Move/MoveTrail.js +2 -8
- package/umd/Options/Classes/Particles/Move/OutModes.js +4 -5
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -1
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +10 -6
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
- package/umd/Options/Classes/Particles/ParticlesOptions.js +6 -11
- package/umd/Options/Classes/Particles/Shape/Shape.js +9 -2
- package/umd/Options/Classes/Particles/Size/Size.js +12 -8
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
- package/umd/Options/Classes/ValueWithRandom.js +5 -18
- package/umd/Utils/CanvasUtils.js +21 -58
- package/umd/Utils/ColorUtils.js +16 -18
- package/umd/Utils/EventDispatcher.js +7 -6
- package/umd/Utils/HslColorManager.js +2 -4
- package/umd/Utils/NumberUtils.js +42 -46
- package/umd/Utils/RgbColorManager.js +2 -4
- package/umd/Utils/Utils.js +163 -63
- package/umd/bundle.js +5 -97
- package/umd/export-types.js +123 -0
- package/umd/exports.js +115 -0
- package/umd/index.js +9 -199
- package/umd/init.js +26 -0
- package/browser/Core/Utils/FrameManager.js +0 -42
- package/browser/Core/Utils/Plugins.js +0 -112
- package/browser/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
- package/browser/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
- package/browser/engine.js +0 -175
- package/cjs/Core/Utils/FrameManager.js +0 -46
- package/cjs/Core/Utils/Plugins.js +0 -116
- package/cjs/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IImageShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -2
- package/cjs/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -17
- package/cjs/Options/Interfaces/Particles/Shape/IStarShape.js +0 -2
- package/cjs/engine.js +0 -179
- package/esm/Core/Interfaces/IParticleOverride.js +0 -1
- package/esm/Core/Interfaces/IParticlesMover.js +0 -1
- package/esm/Core/Utils/FrameManager.js +0 -42
- package/esm/Core/Utils/Plugins.js +0 -112
- package/esm/Enums/Modes/SizeMode.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
- package/esm/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
- package/esm/engine.js +0 -175
- package/types/Core/Interfaces/IParticleOverride.d.ts +0 -6
- package/types/Core/Interfaces/IParticlesMover.d.ts +0 -7
- package/types/Core/Utils/FrameManager.d.ts +0 -6
- package/types/Core/Utils/Plugins.d.ts +0 -51
- package/types/Options/Interfaces/Particles/Shape/ICharacterShape.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Shape/IImageShape.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Shape/IPolygonShape.d.ts +0 -5
- package/types/Options/Interfaces/Particles/Shape/IShapeValues.d.ts +0 -1
- package/types/Options/Interfaces/Particles/Shape/IStarShape.d.ts +0 -6
- package/types/engine.d.ts +0 -39
- package/umd/Core/Utils/FrameManager.js +0 -56
- package/umd/Core/Utils/Plugins.js +0 -126
- package/umd/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IImageShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -27
- package/umd/Options/Interfaces/Particles/Shape/IStarShape.js +0 -12
- package/umd/engine.js +0 -189
- /package/browser/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
- /package/browser/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
- /package/browser/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
- /package/cjs/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
- /package/cjs/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
- /package/cjs/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
- /package/{browser/Options/Interfaces/Particles/Shape/ICharacterShape.js → esm/Enums/Modes/AnimationMode.js} +0 -0
- /package/{browser/Options/Interfaces/Particles/Shape/IImageShape.js → esm/Enums/Modes/PixelMode.js} +0 -0
- /package/{browser/Options/Interfaces/Particles/Shape/IPolygonShape.js → esm/Types/ExportResult.js} +0 -0
- /package/umd/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
- /package/umd/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
- /package/umd/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { errorPrefix } from "./Constants";
|
|
2
|
+
import { isNumber } from "../../Utils/Utils";
|
|
1
3
|
export class Vector3d {
|
|
2
4
|
constructor(xOrCoords, y, z) {
|
|
3
|
-
|
|
5
|
+
this._updateFromAngle = (angle, length) => {
|
|
6
|
+
this.x = Math.cos(angle) * length;
|
|
7
|
+
this.y = Math.sin(angle) * length;
|
|
8
|
+
};
|
|
9
|
+
if (!isNumber(xOrCoords) && xOrCoords) {
|
|
4
10
|
this.x = xOrCoords.x;
|
|
5
11
|
this.y = xOrCoords.y;
|
|
6
12
|
const coords3d = xOrCoords;
|
|
@@ -9,10 +15,10 @@ export class Vector3d {
|
|
|
9
15
|
else if (xOrCoords !== undefined && y !== undefined) {
|
|
10
16
|
this.x = xOrCoords;
|
|
11
17
|
this.y = y;
|
|
12
|
-
this.z = z
|
|
18
|
+
this.z = z ?? 0;
|
|
13
19
|
}
|
|
14
20
|
else {
|
|
15
|
-
throw new Error(
|
|
21
|
+
throw new Error(`${errorPrefix} Vector3d not initialized correctly`);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
static get origin() {
|
|
@@ -22,13 +28,13 @@ export class Vector3d {
|
|
|
22
28
|
return Math.atan2(this.y, this.x);
|
|
23
29
|
}
|
|
24
30
|
set angle(angle) {
|
|
25
|
-
this.
|
|
31
|
+
this._updateFromAngle(angle, this.length);
|
|
26
32
|
}
|
|
27
33
|
get length() {
|
|
28
34
|
return Math.sqrt(this.getLengthSq());
|
|
29
35
|
}
|
|
30
36
|
set length(length) {
|
|
31
|
-
this.
|
|
37
|
+
this._updateFromAngle(this.angle, length);
|
|
32
38
|
}
|
|
33
39
|
static clone(source) {
|
|
34
40
|
return Vector3d.create(source.x, source.y, source.z);
|
|
@@ -72,6 +78,12 @@ export class Vector3d {
|
|
|
72
78
|
this.y *= n;
|
|
73
79
|
this.z *= n;
|
|
74
80
|
}
|
|
81
|
+
normalize() {
|
|
82
|
+
const length = this.length;
|
|
83
|
+
if (length != 0) {
|
|
84
|
+
this.multTo(1.0 / length);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
75
87
|
rotate(angle) {
|
|
76
88
|
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), 0);
|
|
77
89
|
}
|
|
@@ -89,8 +101,4 @@ export class Vector3d {
|
|
|
89
101
|
this.y -= v.y;
|
|
90
102
|
this.z -= v.z;
|
|
91
103
|
}
|
|
92
|
-
updateFromAngle(angle, length) {
|
|
93
|
-
this.x = Math.cos(angle) * length;
|
|
94
|
-
this.y = Math.sin(angle) * length;
|
|
95
|
-
}
|
|
96
104
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArray, isString } from "../../Utils/Utils";
|
|
1
2
|
import { HslAnimation } from "./HslAnimation";
|
|
2
3
|
import { OptionsColor } from "./OptionsColor";
|
|
3
4
|
export class AnimatableColor extends OptionsColor {
|
|
@@ -9,7 +10,7 @@ export class AnimatableColor extends OptionsColor {
|
|
|
9
10
|
const color = new AnimatableColor();
|
|
10
11
|
color.load(source);
|
|
11
12
|
if (data !== undefined) {
|
|
12
|
-
if (
|
|
13
|
+
if (isString(data) || isArray(data)) {
|
|
13
14
|
color.load({ value: data });
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
@@ -5,6 +5,7 @@ export class AnimationOptions {
|
|
|
5
5
|
this.enable = false;
|
|
6
6
|
this.speed = 1;
|
|
7
7
|
this.decay = 0;
|
|
8
|
+
this.delay = 0;
|
|
8
9
|
this.sync = false;
|
|
9
10
|
}
|
|
10
11
|
load(data) {
|
|
@@ -23,6 +24,9 @@ export class AnimationOptions {
|
|
|
23
24
|
if (data.decay !== undefined) {
|
|
24
25
|
this.decay = setRangeValue(data.decay);
|
|
25
26
|
}
|
|
27
|
+
if (data.delay !== undefined) {
|
|
28
|
+
this.delay = setRangeValue(data.delay);
|
|
29
|
+
}
|
|
26
30
|
if (data.sync !== undefined) {
|
|
27
31
|
this.sync = data.sync;
|
|
28
32
|
}
|
|
@@ -31,6 +35,7 @@ export class AnimationOptions {
|
|
|
31
35
|
export class RangedAnimationOptions extends AnimationOptions {
|
|
32
36
|
constructor() {
|
|
33
37
|
super();
|
|
38
|
+
this.mode = "auto";
|
|
34
39
|
this.startValue = "random";
|
|
35
40
|
}
|
|
36
41
|
load(data) {
|
|
@@ -38,8 +43,8 @@ export class RangedAnimationOptions extends AnimationOptions {
|
|
|
38
43
|
if (!data) {
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
|
-
if (data.
|
|
42
|
-
this.
|
|
46
|
+
if (data.mode !== undefined) {
|
|
47
|
+
this.mode = data.mode;
|
|
43
48
|
}
|
|
44
49
|
if (data.startValue !== undefined) {
|
|
45
50
|
this.startValue = data.startValue;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BackgroundMaskCover } from "./BackgroundMaskCover";
|
|
2
|
+
import { isString } from "../../../Utils/Utils";
|
|
2
3
|
export class BackgroundMask {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.composite = "destination-out";
|
|
@@ -14,7 +15,7 @@ export class BackgroundMask {
|
|
|
14
15
|
}
|
|
15
16
|
if (data.cover !== undefined) {
|
|
16
17
|
const cover = data.cover;
|
|
17
|
-
const color = (
|
|
18
|
+
const color = (isString(data.cover) ? { color: data.cover } : data.cover);
|
|
18
19
|
this.cover.load(cover.color !== undefined ? cover : { color: color });
|
|
19
20
|
}
|
|
20
21
|
if (data.enable !== undefined) {
|
|
@@ -5,6 +5,7 @@ export class ColorAnimation {
|
|
|
5
5
|
this.enable = false;
|
|
6
6
|
this.offset = 0;
|
|
7
7
|
this.speed = 1;
|
|
8
|
+
this.delay = 0;
|
|
8
9
|
this.decay = 0;
|
|
9
10
|
this.sync = true;
|
|
10
11
|
}
|
|
@@ -27,6 +28,9 @@ export class ColorAnimation {
|
|
|
27
28
|
if (data.decay !== undefined) {
|
|
28
29
|
this.decay = setRangeValue(data.decay);
|
|
29
30
|
}
|
|
31
|
+
if (data.delay !== undefined) {
|
|
32
|
+
this.delay = setRangeValue(data.delay);
|
|
33
|
+
}
|
|
30
34
|
if (data.sync !== undefined) {
|
|
31
35
|
this.sync = data.sync;
|
|
32
36
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { executeOnSingleOrMultiple } from "../../../../Utils/Utils";
|
|
2
1
|
export class DivEvent {
|
|
3
2
|
constructor() {
|
|
4
3
|
this.selectors = [];
|
|
@@ -6,33 +5,10 @@ export class DivEvent {
|
|
|
6
5
|
this.mode = [];
|
|
7
6
|
this.type = "circle";
|
|
8
7
|
}
|
|
9
|
-
get el() {
|
|
10
|
-
return this.elementId;
|
|
11
|
-
}
|
|
12
|
-
set el(value) {
|
|
13
|
-
this.elementId = value;
|
|
14
|
-
}
|
|
15
|
-
get elementId() {
|
|
16
|
-
return this.ids;
|
|
17
|
-
}
|
|
18
|
-
set elementId(value) {
|
|
19
|
-
this.ids = value;
|
|
20
|
-
}
|
|
21
|
-
get ids() {
|
|
22
|
-
return executeOnSingleOrMultiple(this.selectors, (t) => t.replace("#", ""));
|
|
23
|
-
}
|
|
24
|
-
set ids(value) {
|
|
25
|
-
this.selectors = executeOnSingleOrMultiple(value, (t) => `#${t}`);
|
|
26
|
-
}
|
|
27
8
|
load(data) {
|
|
28
|
-
var _a, _b;
|
|
29
9
|
if (!data) {
|
|
30
10
|
return;
|
|
31
11
|
}
|
|
32
|
-
const ids = (_b = (_a = data.ids) !== null && _a !== void 0 ? _a : data.elementId) !== null && _b !== void 0 ? _b : data.el;
|
|
33
|
-
if (ids !== undefined) {
|
|
34
|
-
this.ids = ids;
|
|
35
|
-
}
|
|
36
12
|
if (data.selectors !== undefined) {
|
|
37
13
|
this.selectors = data.selectors;
|
|
38
14
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { executeOnSingleOrMultiple, isBoolean } from "../../../../Utils/Utils";
|
|
1
2
|
import { ClickEvent } from "./ClickEvent";
|
|
2
3
|
import { DivEvent } from "./DivEvent";
|
|
3
4
|
import { HoverEvent } from "./HoverEvent";
|
|
4
5
|
import { ResizeEvent } from "./ResizeEvent";
|
|
5
|
-
import { executeOnSingleOrMultiple } from "../../../../Utils/Utils";
|
|
6
6
|
export class Events {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.onClick = new ClickEvent();
|
|
@@ -10,31 +10,12 @@ export class Events {
|
|
|
10
10
|
this.onHover = new HoverEvent();
|
|
11
11
|
this.resize = new ResizeEvent();
|
|
12
12
|
}
|
|
13
|
-
get onclick() {
|
|
14
|
-
return this.onClick;
|
|
15
|
-
}
|
|
16
|
-
set onclick(value) {
|
|
17
|
-
this.onClick = value;
|
|
18
|
-
}
|
|
19
|
-
get ondiv() {
|
|
20
|
-
return this.onDiv;
|
|
21
|
-
}
|
|
22
|
-
set ondiv(value) {
|
|
23
|
-
this.onDiv = value;
|
|
24
|
-
}
|
|
25
|
-
get onhover() {
|
|
26
|
-
return this.onHover;
|
|
27
|
-
}
|
|
28
|
-
set onhover(value) {
|
|
29
|
-
this.onHover = value;
|
|
30
|
-
}
|
|
31
13
|
load(data) {
|
|
32
|
-
var _a, _b, _c;
|
|
33
14
|
if (!data) {
|
|
34
15
|
return;
|
|
35
16
|
}
|
|
36
|
-
this.onClick.load(
|
|
37
|
-
const onDiv =
|
|
17
|
+
this.onClick.load(data.onClick);
|
|
18
|
+
const onDiv = data.onDiv;
|
|
38
19
|
if (onDiv !== undefined) {
|
|
39
20
|
this.onDiv = executeOnSingleOrMultiple(onDiv, (t) => {
|
|
40
21
|
const tmp = new DivEvent();
|
|
@@ -42,8 +23,8 @@ export class Events {
|
|
|
42
23
|
return tmp;
|
|
43
24
|
});
|
|
44
25
|
}
|
|
45
|
-
this.onHover.load(
|
|
46
|
-
if (
|
|
26
|
+
this.onHover.load(data.onHover);
|
|
27
|
+
if (isBoolean(data.resize)) {
|
|
47
28
|
this.resize.enable = data.resize;
|
|
48
29
|
}
|
|
49
30
|
else {
|
|
@@ -6,18 +6,11 @@ export class Interactivity {
|
|
|
6
6
|
this.events = new Events();
|
|
7
7
|
this.modes = new Modes(engine, container);
|
|
8
8
|
}
|
|
9
|
-
get detect_on() {
|
|
10
|
-
return this.detectsOn;
|
|
11
|
-
}
|
|
12
|
-
set detect_on(value) {
|
|
13
|
-
this.detectsOn = value;
|
|
14
|
-
}
|
|
15
9
|
load(data) {
|
|
16
|
-
var _a;
|
|
17
10
|
if (!data) {
|
|
18
11
|
return;
|
|
19
12
|
}
|
|
20
|
-
const detectsOn =
|
|
13
|
+
const detectsOn = data.detectsOn;
|
|
21
14
|
if (detectsOn !== undefined) {
|
|
22
15
|
this.detectsOn = detectsOn;
|
|
23
16
|
}
|
|
@@ -7,15 +7,18 @@ export class Modes {
|
|
|
7
7
|
if (!data) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
if (this._container) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
if (!this._container) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const interactors = this._engine.interactors.get(this._container);
|
|
14
|
+
if (!interactors) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const interactor of interactors) {
|
|
18
|
+
if (!interactor.loadModeOptions) {
|
|
19
|
+
continue;
|
|
18
20
|
}
|
|
21
|
+
interactor.loadModeOptions(this, data);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { deepExtend } from "../../Utils/Utils";
|
|
2
2
|
export class ManualParticle {
|
|
3
3
|
load(data) {
|
|
4
|
-
var _a, _b;
|
|
5
4
|
if (!data) {
|
|
6
5
|
return;
|
|
7
6
|
}
|
|
8
|
-
if (data.position
|
|
7
|
+
if (data.position) {
|
|
9
8
|
this.position = {
|
|
10
|
-
x:
|
|
11
|
-
y:
|
|
9
|
+
x: data.position.x ?? 50,
|
|
10
|
+
y: data.position.y ?? 50,
|
|
11
|
+
mode: data.position.mode ?? "percent",
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
if (data.options
|
|
14
|
+
if (data.options) {
|
|
15
15
|
this.options = deepExtend({}, data.options);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { deepExtend, executeOnSingleOrMultiple, safeMatchMedia } from "../../Utils/Utils";
|
|
1
|
+
import { deepExtend, executeOnSingleOrMultiple, isBoolean, safeMatchMedia } from "../../Utils/Utils";
|
|
2
2
|
import { Background } from "./Background/Background";
|
|
3
3
|
import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
|
|
4
4
|
import { FullScreen } from "./FullScreen/FullScreen";
|
|
@@ -10,6 +10,13 @@ import { loadParticlesOptions } from "../../Utils/OptionsUtils";
|
|
|
10
10
|
import { setRangeValue } from "../../Utils/NumberUtils";
|
|
11
11
|
export class Options {
|
|
12
12
|
constructor(engine, container) {
|
|
13
|
+
this._findDefaultTheme = (mode) => {
|
|
14
|
+
return (this.themes.find((theme) => theme.default.value && theme.default.mode === mode) ??
|
|
15
|
+
this.themes.find((theme) => theme.default.value && theme.default.mode === "any"));
|
|
16
|
+
};
|
|
17
|
+
this._importPreset = (preset) => {
|
|
18
|
+
this.load(this._engine.getPreset(preset));
|
|
19
|
+
};
|
|
13
20
|
this._engine = engine;
|
|
14
21
|
this._container = container;
|
|
15
22
|
this.autoPlay = true;
|
|
@@ -23,7 +30,6 @@ export class Options {
|
|
|
23
30
|
this.fpsLimit = 120;
|
|
24
31
|
this.interactivity = new Interactivity(engine, container);
|
|
25
32
|
this.manualParticles = [];
|
|
26
|
-
this.name = "default";
|
|
27
33
|
this.particles = loadParticlesOptions(this._engine, this._container);
|
|
28
34
|
this.pauseOnBlur = true;
|
|
29
35
|
this.pauseOnOutsideViewport = true;
|
|
@@ -33,26 +39,7 @@ export class Options {
|
|
|
33
39
|
this.themes = [];
|
|
34
40
|
this.zLayers = 100;
|
|
35
41
|
}
|
|
36
|
-
get backgroundMode() {
|
|
37
|
-
return this.fullScreen;
|
|
38
|
-
}
|
|
39
|
-
set backgroundMode(value) {
|
|
40
|
-
this.fullScreen.load(value);
|
|
41
|
-
}
|
|
42
|
-
get fps_limit() {
|
|
43
|
-
return this.fpsLimit;
|
|
44
|
-
}
|
|
45
|
-
set fps_limit(value) {
|
|
46
|
-
this.fpsLimit = value;
|
|
47
|
-
}
|
|
48
|
-
get retina_detect() {
|
|
49
|
-
return this.detectRetina;
|
|
50
|
-
}
|
|
51
|
-
set retina_detect(value) {
|
|
52
|
-
this.detectRetina = value;
|
|
53
|
-
}
|
|
54
42
|
load(data) {
|
|
55
|
-
var _a, _b, _c, _d, _e;
|
|
56
43
|
if (!data) {
|
|
57
44
|
return;
|
|
58
45
|
}
|
|
@@ -65,14 +52,14 @@ export class Options {
|
|
|
65
52
|
if (data.delay !== undefined) {
|
|
66
53
|
this.delay = setRangeValue(data.delay);
|
|
67
54
|
}
|
|
68
|
-
const detectRetina =
|
|
55
|
+
const detectRetina = data.detectRetina;
|
|
69
56
|
if (detectRetina !== undefined) {
|
|
70
57
|
this.detectRetina = detectRetina;
|
|
71
58
|
}
|
|
72
59
|
if (data.duration !== undefined) {
|
|
73
60
|
this.duration = setRangeValue(data.duration);
|
|
74
61
|
}
|
|
75
|
-
const fpsLimit =
|
|
62
|
+
const fpsLimit = data.fpsLimit;
|
|
76
63
|
if (fpsLimit !== undefined) {
|
|
77
64
|
this.fpsLimit = fpsLimit;
|
|
78
65
|
}
|
|
@@ -86,8 +73,8 @@ export class Options {
|
|
|
86
73
|
this.zLayers = data.zLayers;
|
|
87
74
|
}
|
|
88
75
|
this.background.load(data.background);
|
|
89
|
-
const fullScreen =
|
|
90
|
-
if (
|
|
76
|
+
const fullScreen = data.fullScreen;
|
|
77
|
+
if (isBoolean(fullScreen)) {
|
|
91
78
|
this.fullScreen.enable = fullScreen;
|
|
92
79
|
}
|
|
93
80
|
else {
|
|
@@ -95,7 +82,7 @@ export class Options {
|
|
|
95
82
|
}
|
|
96
83
|
this.backgroundMask.load(data.backgroundMask);
|
|
97
84
|
this.interactivity.load(data.interactivity);
|
|
98
|
-
if (data.manualParticles
|
|
85
|
+
if (data.manualParticles) {
|
|
99
86
|
this.manualParticles = data.manualParticles.map((t) => {
|
|
100
87
|
const tmp = new ManualParticle();
|
|
101
88
|
tmp.load(t);
|
|
@@ -104,11 +91,11 @@ export class Options {
|
|
|
104
91
|
}
|
|
105
92
|
this.particles.load(data.particles);
|
|
106
93
|
this.style = deepExtend(this.style, data.style);
|
|
107
|
-
this._engine.
|
|
94
|
+
this._engine.loadOptions(this, data);
|
|
108
95
|
if (data.smooth !== undefined) {
|
|
109
96
|
this.smooth = data.smooth;
|
|
110
97
|
}
|
|
111
|
-
const interactors = this._engine.
|
|
98
|
+
const interactors = this._engine.interactors.get(this._container);
|
|
112
99
|
if (interactors) {
|
|
113
100
|
for (const interactor of interactors) {
|
|
114
101
|
if (interactor.loadOptions) {
|
|
@@ -137,14 +124,14 @@ export class Options {
|
|
|
137
124
|
}
|
|
138
125
|
}
|
|
139
126
|
}
|
|
140
|
-
this.defaultThemes.dark =
|
|
141
|
-
this.defaultThemes.light =
|
|
127
|
+
this.defaultThemes.dark = this._findDefaultTheme("dark")?.name;
|
|
128
|
+
this.defaultThemes.light = this._findDefaultTheme("light")?.name;
|
|
142
129
|
}
|
|
143
130
|
setResponsive(width, pxRatio, defaultOptions) {
|
|
144
131
|
this.load(defaultOptions);
|
|
145
132
|
const responsiveOptions = this.responsive.find((t) => t.mode === "screen" && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
|
|
146
|
-
this.load(responsiveOptions
|
|
147
|
-
return responsiveOptions
|
|
133
|
+
this.load(responsiveOptions?.options);
|
|
134
|
+
return responsiveOptions?.maxWidth;
|
|
148
135
|
}
|
|
149
136
|
setTheme(name) {
|
|
150
137
|
if (name) {
|
|
@@ -160,11 +147,4 @@ export class Options {
|
|
|
160
147
|
}
|
|
161
148
|
}
|
|
162
149
|
}
|
|
163
|
-
_findDefaultTheme(mode) {
|
|
164
|
-
var _a;
|
|
165
|
-
return ((_a = this.themes.find((theme) => theme.default.value && theme.default.mode === mode)) !== null && _a !== void 0 ? _a : this.themes.find((theme) => theme.default.value && theme.default.mode === "any"));
|
|
166
|
-
}
|
|
167
|
-
_importPreset(preset) {
|
|
168
|
-
this.load(this._engine.plugins.getPreset(preset));
|
|
169
|
-
}
|
|
170
150
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isArray, isString } from "../../Utils/Utils";
|
|
1
2
|
export class OptionsColor {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.value = "";
|
|
@@ -6,7 +7,7 @@ export class OptionsColor {
|
|
|
6
7
|
const color = new OptionsColor();
|
|
7
8
|
color.load(source);
|
|
8
9
|
if (data !== undefined) {
|
|
9
|
-
if (
|
|
10
|
+
if (isString(data) || isArray(data)) {
|
|
10
11
|
color.load({ value: data });
|
|
11
12
|
}
|
|
12
13
|
else {
|
|
@@ -16,7 +17,7 @@ export class OptionsColor {
|
|
|
16
17
|
return color;
|
|
17
18
|
}
|
|
18
19
|
load(data) {
|
|
19
|
-
if (
|
|
20
|
+
if (data?.value === undefined) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
this.value = data.value;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { CollisionsAbsorb } from "./CollisionsAbsorb";
|
|
2
2
|
import { CollisionsOverlap } from "./CollisionsOverlap";
|
|
3
3
|
import { ParticlesBounce } from "../Bounce/ParticlesBounce";
|
|
4
|
+
import { setRangeValue } from "../../../../Utils/NumberUtils";
|
|
4
5
|
export class Collisions {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.absorb = new CollisionsAbsorb();
|
|
7
8
|
this.bounce = new ParticlesBounce();
|
|
8
9
|
this.enable = false;
|
|
10
|
+
this.maxSpeed = 50;
|
|
9
11
|
this.mode = "bounce";
|
|
10
12
|
this.overlap = new CollisionsOverlap();
|
|
11
13
|
}
|
|
@@ -18,6 +20,9 @@ export class Collisions {
|
|
|
18
20
|
if (data.enable !== undefined) {
|
|
19
21
|
this.enable = data.enable;
|
|
20
22
|
}
|
|
23
|
+
if (data.maxSpeed !== undefined) {
|
|
24
|
+
this.maxSpeed = setRangeValue(data.maxSpeed);
|
|
25
|
+
}
|
|
21
26
|
if (data.mode !== undefined) {
|
|
22
27
|
this.mode = data.mode;
|
|
23
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNumber, isObject } from "../../../../Utils/Utils";
|
|
1
2
|
import { MoveAngle } from "./MoveAngle";
|
|
2
3
|
import { MoveAttract } from "./MoveAttract";
|
|
3
4
|
import { MoveCenter } from "./MoveCenter";
|
|
@@ -29,41 +30,11 @@ export class Move {
|
|
|
29
30
|
this.vibrate = false;
|
|
30
31
|
this.warp = false;
|
|
31
32
|
}
|
|
32
|
-
get bounce() {
|
|
33
|
-
return this.collisions;
|
|
34
|
-
}
|
|
35
|
-
set bounce(value) {
|
|
36
|
-
this.collisions = value;
|
|
37
|
-
}
|
|
38
|
-
get collisions() {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
set collisions(_) {
|
|
42
|
-
}
|
|
43
|
-
get noise() {
|
|
44
|
-
return this.path;
|
|
45
|
-
}
|
|
46
|
-
set noise(value) {
|
|
47
|
-
this.path = value;
|
|
48
|
-
}
|
|
49
|
-
get outMode() {
|
|
50
|
-
return this.outModes.default;
|
|
51
|
-
}
|
|
52
|
-
set outMode(value) {
|
|
53
|
-
this.outModes.default = value;
|
|
54
|
-
}
|
|
55
|
-
get out_mode() {
|
|
56
|
-
return this.outMode;
|
|
57
|
-
}
|
|
58
|
-
set out_mode(value) {
|
|
59
|
-
this.outMode = value;
|
|
60
|
-
}
|
|
61
33
|
load(data) {
|
|
62
|
-
var _a, _b, _c;
|
|
63
34
|
if (!data) {
|
|
64
35
|
return;
|
|
65
36
|
}
|
|
66
|
-
this.angle.load(
|
|
37
|
+
this.angle.load(isNumber(data.angle) ? { value: data.angle } : data.angle);
|
|
67
38
|
this.attract.load(data.attract);
|
|
68
39
|
this.center.load(data.center);
|
|
69
40
|
if (data.decay !== undefined) {
|
|
@@ -73,13 +44,12 @@ export class Move {
|
|
|
73
44
|
this.direction = data.direction;
|
|
74
45
|
}
|
|
75
46
|
if (data.distance !== undefined) {
|
|
76
|
-
this.distance =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
: Object.assign({}, data.distance);
|
|
47
|
+
this.distance = isNumber(data.distance)
|
|
48
|
+
? {
|
|
49
|
+
horizontal: data.distance,
|
|
50
|
+
vertical: data.distance,
|
|
51
|
+
}
|
|
52
|
+
: { ...data.distance };
|
|
83
53
|
}
|
|
84
54
|
if (data.drift !== undefined) {
|
|
85
55
|
this.drift = setRangeValue(data.drift);
|
|
@@ -88,9 +58,9 @@ export class Move {
|
|
|
88
58
|
this.enable = data.enable;
|
|
89
59
|
}
|
|
90
60
|
this.gravity.load(data.gravity);
|
|
91
|
-
const outModes =
|
|
61
|
+
const outModes = data.outModes;
|
|
92
62
|
if (outModes !== undefined) {
|
|
93
|
-
if (
|
|
63
|
+
if (isObject(outModes)) {
|
|
94
64
|
this.outModes.load(outModes);
|
|
95
65
|
}
|
|
96
66
|
else {
|
|
@@ -99,7 +69,7 @@ export class Move {
|
|
|
99
69
|
});
|
|
100
70
|
}
|
|
101
71
|
}
|
|
102
|
-
this.path.load(
|
|
72
|
+
this.path.load(data.path);
|
|
103
73
|
if (data.random !== undefined) {
|
|
104
74
|
this.random = data.random;
|
|
105
75
|
}
|
|
@@ -8,20 +8,7 @@ export class MoveAttract {
|
|
|
8
8
|
y: 3000,
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
get rotateX() {
|
|
12
|
-
return this.rotate.x;
|
|
13
|
-
}
|
|
14
|
-
set rotateX(value) {
|
|
15
|
-
this.rotate.x = value;
|
|
16
|
-
}
|
|
17
|
-
get rotateY() {
|
|
18
|
-
return this.rotate.y;
|
|
19
|
-
}
|
|
20
|
-
set rotateY(value) {
|
|
21
|
-
this.rotate.y = value;
|
|
22
|
-
}
|
|
23
11
|
load(data) {
|
|
24
|
-
var _a, _b, _c, _d;
|
|
25
12
|
if (!data) {
|
|
26
13
|
return;
|
|
27
14
|
}
|
|
@@ -31,13 +18,15 @@ export class MoveAttract {
|
|
|
31
18
|
if (data.enable !== undefined) {
|
|
32
19
|
this.enable = data.enable;
|
|
33
20
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
if (data.rotate) {
|
|
22
|
+
const rotateX = data.rotate.x;
|
|
23
|
+
if (rotateX !== undefined) {
|
|
24
|
+
this.rotate.x = rotateX;
|
|
25
|
+
}
|
|
26
|
+
const rotateY = data.rotate.y;
|
|
27
|
+
if (rotateY !== undefined) {
|
|
28
|
+
this.rotate.y = rotateY;
|
|
29
|
+
}
|
|
41
30
|
}
|
|
42
31
|
}
|
|
43
32
|
}
|
|
@@ -5,12 +5,6 @@ export class MoveTrail {
|
|
|
5
5
|
this.length = 10;
|
|
6
6
|
this.fill = new MoveTrailFill();
|
|
7
7
|
}
|
|
8
|
-
get fillColor() {
|
|
9
|
-
return this.fill.color;
|
|
10
|
-
}
|
|
11
|
-
set fillColor(value) {
|
|
12
|
-
this.fill.load({ color: value });
|
|
13
|
-
}
|
|
14
8
|
load(data) {
|
|
15
9
|
if (!data) {
|
|
16
10
|
return;
|
|
@@ -18,8 +12,8 @@ export class MoveTrail {
|
|
|
18
12
|
if (data.enable !== undefined) {
|
|
19
13
|
this.enable = data.enable;
|
|
20
14
|
}
|
|
21
|
-
if (data.fill !== undefined
|
|
22
|
-
this.fill.load(data.fill
|
|
15
|
+
if (data.fill !== undefined) {
|
|
16
|
+
this.fill.load(data.fill);
|
|
23
17
|
}
|
|
24
18
|
if (data.length !== undefined) {
|
|
25
19
|
this.length = data.length;
|
|
@@ -3,16 +3,15 @@ export class OutModes {
|
|
|
3
3
|
this.default = "out";
|
|
4
4
|
}
|
|
5
5
|
load(data) {
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
6
|
if (!data) {
|
|
8
7
|
return;
|
|
9
8
|
}
|
|
10
9
|
if (data.default !== undefined) {
|
|
11
10
|
this.default = data.default;
|
|
12
11
|
}
|
|
13
|
-
this.bottom =
|
|
14
|
-
this.left =
|
|
15
|
-
this.right =
|
|
16
|
-
this.top =
|
|
12
|
+
this.bottom = data.bottom ?? data.default;
|
|
13
|
+
this.left = data.left ?? data.default;
|
|
14
|
+
this.right = data.right ?? data.default;
|
|
15
|
+
this.top = data.top ?? data.default;
|
|
17
16
|
}
|
|
18
17
|
}
|