@tsparticles/engine 4.0.0-beta.1 → 4.0.0-beta.2
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/browser/Core/Container.js +3 -0
- package/browser/Core/Engine.js +1 -1
- package/browser/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/browser/Core/ParticlesManager.js +1 -0
- package/cjs/Core/Container.js +3 -0
- package/cjs/Core/Engine.js +1 -1
- package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/cjs/Core/ParticlesManager.js +1 -0
- package/dist_browser_Core_Container_js.js +3 -3
- package/esm/Core/Container.js +3 -0
- package/esm/Core/Engine.js +1 -1
- package/esm/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/esm/Core/ParticlesManager.js +1 -0
- package/package.json +2 -3
- package/report.html +1 -1
- package/tsparticles.engine.js +2 -2
- package/tsparticles.engine.min.js +1 -1
- package/umd/Core/CanvasManager.js +0 -317
- package/umd/Core/Container.js +0 -383
- package/umd/Core/Engine.js +0 -183
- package/umd/Core/Interfaces/Colors.js +0 -12
- package/umd/Core/Interfaces/IBounds.js +0 -12
- package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
- package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
- package/umd/Core/Interfaces/IColorManager.js +0 -12
- package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
- package/umd/Core/Interfaces/ICoordinates.js +0 -12
- package/umd/Core/Interfaces/IDelta.js +0 -12
- package/umd/Core/Interfaces/IDimension.js +0 -12
- package/umd/Core/Interfaces/IDistance.js +0 -12
- package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
- package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
- package/umd/Core/Interfaces/ILoadParams.js +0 -12
- package/umd/Core/Interfaces/IPalette.js +0 -12
- package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
- package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
- package/umd/Core/Interfaces/IParticleLife.js +0 -12
- package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
- package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
- package/umd/Core/Interfaces/IParticleRoll.js +0 -12
- package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
- package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
- package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
- package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
- package/umd/Core/Interfaces/IPlugin.js +0 -12
- package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
- package/umd/Core/Interfaces/IRangeValue.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
- package/umd/Core/Interfaces/IShapeValues.js +0 -12
- package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
- package/umd/Core/Particle.js +0 -433
- package/umd/Core/ParticlesManager.js +0 -377
- package/umd/Core/RenderManager.js +0 -317
- package/umd/Core/Retina.js +0 -47
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/PluginManager.js +0 -159
- package/umd/Core/Utils/Ranges.js +0 -91
- package/umd/Core/Utils/SpatialHashGrid.js +0 -116
- package/umd/Core/Utils/Vectors.js +0 -126
- package/umd/Enums/AnimationStatus.js +0 -18
- package/umd/Enums/Directions/MoveDirection.js +0 -27
- package/umd/Enums/Directions/OutModeDirection.js +0 -20
- package/umd/Enums/Directions/RotateDirection.js +0 -19
- package/umd/Enums/Modes/AnimationMode.js +0 -20
- package/umd/Enums/Modes/LimitMode.js +0 -18
- package/umd/Enums/Modes/OutMode.js +0 -21
- package/umd/Enums/Modes/PixelMode.js +0 -18
- package/umd/Enums/RangeType.js +0 -18
- package/umd/Enums/Types/AlterType.js +0 -18
- package/umd/Enums/Types/DestroyType.js +0 -19
- package/umd/Enums/Types/EasingType.js +0 -58
- package/umd/Enums/Types/EventType.js +0 -28
- package/umd/Enums/Types/GradientType.js +0 -19
- package/umd/Enums/Types/ParticleOutType.js +0 -19
- package/umd/Enums/Types/StartValueType.js +0 -19
- package/umd/Options/Classes/AnimatableColor.js +0 -52
- package/umd/Options/Classes/AnimationOptions.js +0 -79
- package/umd/Options/Classes/Background/Background.js +0 -56
- package/umd/Options/Classes/ColorAnimation.js +0 -44
- package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
- package/umd/Options/Classes/HslAnimation.js +0 -30
- package/umd/Options/Classes/Options.js +0 -171
- package/umd/Options/Classes/OptionsColor.js +0 -42
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
- package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
- package/umd/Options/Classes/Particles/Fill.js +0 -42
- package/umd/Options/Classes/Particles/Move/Move.js +0 -120
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
- package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
- package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
- package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
- package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
- package/umd/Options/Classes/Particles/Size/Size.js +0 -35
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
- package/umd/Options/Classes/Particles/Stroke.js +0 -39
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
- package/umd/Options/Classes/ResizeEvent.js +0 -34
- package/umd/Options/Classes/ValueWithRandom.js +0 -56
- package/umd/Options/Interfaces/Background/IBackground.js +0 -12
- package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
- package/umd/Options/Interfaces/IAnimatable.js +0 -12
- package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
- package/umd/Options/Interfaces/IAnimation.js +0 -12
- package/umd/Options/Interfaces/IColorAnimation.js +0 -12
- package/umd/Options/Interfaces/IHslAnimation.js +0 -12
- package/umd/Options/Interfaces/IOptionLoader.js +0 -12
- package/umd/Options/Interfaces/IOptions.js +0 -12
- package/umd/Options/Interfaces/IOptionsColor.js +0 -12
- package/umd/Options/Interfaces/IResizeEvent.js +0 -12
- package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
- package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
- package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
- package/umd/Options/Interfaces/Particles/IFill.js +0 -12
- package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
- package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
- package/umd/Types/CanvasContextType.js +0 -12
- package/umd/Types/CustomEventArgs.js +0 -12
- package/umd/Types/CustomEventListener.js +0 -12
- package/umd/Types/EasingFunction.js +0 -12
- package/umd/Types/EngineInitializers.js +0 -12
- package/umd/Types/ExportResult.js +0 -12
- package/umd/Types/ISourceOptions.js +0 -12
- package/umd/Types/ParticlesGroups.js +0 -12
- package/umd/Types/PathOptions.js +0 -12
- package/umd/Types/RangeValue.js +0 -12
- package/umd/Types/RecursivePartial.js +0 -12
- package/umd/Types/ShapeData.js +0 -12
- package/umd/Types/SingleOrMultiple.js +0 -12
- package/umd/Utils/CanvasUtils.js +0 -145
- package/umd/Utils/ColorUtils.js +0 -395
- package/umd/Utils/EventDispatcher.js +0 -63
- package/umd/Utils/LogUtils.js +0 -37
- package/umd/Utils/MathUtils.js +0 -203
- package/umd/Utils/OptionsUtils.js +0 -25
- package/umd/Utils/TypeUtils.js +0 -40
- package/umd/Utils/Utils.js +0 -484
- package/umd/bundle.js +0 -32
- package/umd/export-types.js +0 -12
- package/umd/exports.js +0 -82
- package/umd/index.js +0 -32
- package/umd/initEngine.js +0 -17
package/umd/Core/Retina.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Utils/Constants.js", "../Utils/MathUtils.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Retina = void 0;
|
|
13
|
-
const Constants_js_1 = require("./Utils/Constants.js");
|
|
14
|
-
const MathUtils_js_1 = require("../Utils/MathUtils.js");
|
|
15
|
-
class Retina {
|
|
16
|
-
container;
|
|
17
|
-
pixelRatio;
|
|
18
|
-
reduceFactor;
|
|
19
|
-
constructor(container) {
|
|
20
|
-
this.container = container;
|
|
21
|
-
this.pixelRatio = Constants_js_1.defaultRatio;
|
|
22
|
-
this.reduceFactor = Constants_js_1.defaultReduceFactor;
|
|
23
|
-
}
|
|
24
|
-
init() {
|
|
25
|
-
const container = this.container, options = container.actualOptions;
|
|
26
|
-
this.pixelRatio = options.detectRetina ? devicePixelRatio : Constants_js_1.defaultRatio;
|
|
27
|
-
this.reduceFactor = Constants_js_1.defaultReduceFactor;
|
|
28
|
-
const ratio = this.pixelRatio, canvas = container.canvas;
|
|
29
|
-
if (canvas.element) {
|
|
30
|
-
const element = canvas.element;
|
|
31
|
-
canvas.size.width = element.offsetWidth * ratio;
|
|
32
|
-
canvas.size.height = element.offsetHeight * ratio;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
initParticle(particle) {
|
|
36
|
-
const options = particle.options, ratio = this.pixelRatio, moveOptions = options.move, moveDistance = moveOptions.distance, props = particle.retina;
|
|
37
|
-
props.maxSpeed = (0, MathUtils_js_1.getRangeValue)(moveOptions.gravity.maxSpeed) * ratio;
|
|
38
|
-
props.moveDrift = (0, MathUtils_js_1.getRangeValue)(moveOptions.drift) * ratio;
|
|
39
|
-
props.moveSpeed = (0, MathUtils_js_1.getRangeValue)(moveOptions.speed) * ratio;
|
|
40
|
-
props.sizeAnimationSpeed = (0, MathUtils_js_1.getRangeValue)(options.size.animation.speed) * ratio;
|
|
41
|
-
const maxDistance = props.maxDistance;
|
|
42
|
-
maxDistance.horizontal = moveDistance.horizontal === undefined ? undefined : moveDistance.horizontal * ratio;
|
|
43
|
-
maxDistance.vertical = moveDistance.vertical === undefined ? undefined : moveDistance.vertical * ratio;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.Retina = Retina;
|
|
47
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.defaultZoom = exports.defaultTime = exports.defaultLoops = exports.defaultVelocity = exports.defaultRgbMin = exports.phaseNumerator = exports.sNormalizedOffset = exports.sextuple = exports.triple = exports.lMin = exports.lFactor = exports.minStrokeWidth = exports.identity = exports.defaultAngle = exports.deleteCount = exports.defaultDensityFactor = exports.lengthOffset = exports.minIndex = exports.minCount = exports.countOffset = exports.minLimit = exports.minZ = exports.tryCountIncrement = exports.decayOffset = exports.none = exports.one = exports.loadMinIndex = exports.loadRandomFactor = exports.canvasFirstIndex = exports.minFpsLimit = exports.defaultFpsLimit = exports.removeMinIndex = exports.removeDeleteCount = exports.defaultOpacity = exports.zIndexFactorOffset = exports.minimumSize = exports.defaultTransformValue = exports.minVelocity = exports.threeQuarter = exports.quarter = exports.empty = exports.hPhase = exports.sMin = exports.hMin = exports.lMax = exports.sMax = exports.hMax = exports.rgbMax = exports.inverseFactorNumerator = exports.defaultReduceFactor = exports.defaultRatio = exports.defaultRemoveQuantity = exports.spatialHashGridCellSize = exports.squareExp = exports.defaultRetryCount = exports.canvasTag = exports.generatedFalse = exports.generatedTrue = exports.defaultAlpha = exports.defaultFps = exports.doublePI = exports.double = exports.midColorValue = exports.randomColorValue = exports.defaultTransform = exports.originPoint = exports.millisecondsToSeconds = exports.half = exports.percentDenominator = exports.visibilityChangeEvent = exports.resizeEvent = exports.defaultCompositeValue = exports.generatedAttribute = void 0;
|
|
13
|
-
exports.generatedAttribute = "generated", exports.defaultCompositeValue = "source-over", exports.resizeEvent = "resize", exports.visibilityChangeEvent = "visibilitychange", exports.percentDenominator = 100, exports.half = 0.5, exports.millisecondsToSeconds = 1000, exports.originPoint = {
|
|
14
|
-
x: 0,
|
|
15
|
-
y: 0,
|
|
16
|
-
z: 0,
|
|
17
|
-
}, exports.defaultTransform = {
|
|
18
|
-
a: 1,
|
|
19
|
-
b: 0,
|
|
20
|
-
c: 0,
|
|
21
|
-
d: 1,
|
|
22
|
-
}, exports.randomColorValue = "random", exports.midColorValue = "mid", exports.double = 2, exports.doublePI = Math.PI * exports.double, exports.defaultFps = 60, exports.defaultAlpha = 1, exports.generatedTrue = "true", exports.generatedFalse = "false", exports.canvasTag = "canvas", exports.defaultRetryCount = 0, exports.squareExp = 2, exports.spatialHashGridCellSize = 100, exports.defaultRemoveQuantity = 1, exports.defaultRatio = 1, exports.defaultReduceFactor = 1, exports.inverseFactorNumerator = 1, exports.rgbMax = 255, exports.hMax = 360, exports.sMax = 100, exports.lMax = 100, exports.hMin = 0, exports.sMin = 0, exports.hPhase = 60, exports.empty = 0, exports.quarter = 0.25, exports.threeQuarter = exports.half + exports.quarter, exports.minVelocity = 0, exports.defaultTransformValue = 1, exports.minimumSize = 0, exports.zIndexFactorOffset = 1, exports.defaultOpacity = 1, exports.removeDeleteCount = 1, exports.removeMinIndex = 0, exports.defaultFpsLimit = 120, exports.minFpsLimit = 0, exports.canvasFirstIndex = 0, exports.loadRandomFactor = 10000, exports.loadMinIndex = 0, exports.one = 1, exports.none = 0, exports.decayOffset = 1, exports.tryCountIncrement = 1, exports.minZ = 0, exports.minLimit = 0, exports.countOffset = 1, exports.minCount = 0, exports.minIndex = 0, exports.lengthOffset = 1, exports.defaultDensityFactor = 1, exports.deleteCount = 1, exports.defaultAngle = 0, exports.identity = 1, exports.minStrokeWidth = 0, exports.lFactor = 1, exports.lMin = 0, exports.triple = 3, exports.sextuple = 6, exports.sNormalizedOffset = 1, exports.phaseNumerator = 1, exports.defaultRgbMin = 0, exports.defaultVelocity = 0, exports.defaultLoops = 0, exports.defaultTime = 0, exports.defaultZoom = 1;
|
|
23
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Utils/Utils.js", "./Constants.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EventListeners = void 0;
|
|
13
|
-
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
14
|
-
const Constants_js_1 = require("./Constants.js");
|
|
15
|
-
class EventListeners {
|
|
16
|
-
container;
|
|
17
|
-
_handlers;
|
|
18
|
-
_resizeObserver;
|
|
19
|
-
_resizeTimeout;
|
|
20
|
-
constructor(container) {
|
|
21
|
-
this.container = container;
|
|
22
|
-
this._handlers = {
|
|
23
|
-
visibilityChange: () => {
|
|
24
|
-
this._handleVisibilityChange();
|
|
25
|
-
},
|
|
26
|
-
resize: () => {
|
|
27
|
-
this._handleWindowResize();
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
addListeners() {
|
|
32
|
-
this._manageListeners(true);
|
|
33
|
-
}
|
|
34
|
-
removeListeners() {
|
|
35
|
-
this._manageListeners(false);
|
|
36
|
-
}
|
|
37
|
-
_handleVisibilityChange = () => {
|
|
38
|
-
const container = this.container, options = container.actualOptions;
|
|
39
|
-
if (!options.pauseOnBlur) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if ((0, Utils_js_1.safeDocument)().hidden) {
|
|
43
|
-
container.pageHidden = true;
|
|
44
|
-
container.pause();
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
container.pageHidden = false;
|
|
48
|
-
if (container.animationStatus) {
|
|
49
|
-
container.play(true);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
container.draw(true);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
_handleWindowResize = () => {
|
|
57
|
-
if (this._resizeTimeout) {
|
|
58
|
-
clearTimeout(this._resizeTimeout);
|
|
59
|
-
delete this._resizeTimeout;
|
|
60
|
-
}
|
|
61
|
-
const handleResize = async () => {
|
|
62
|
-
const canvas = this.container.canvas;
|
|
63
|
-
await canvas.windowResize();
|
|
64
|
-
};
|
|
65
|
-
this._resizeTimeout = setTimeout(() => void handleResize(), this.container.actualOptions.resize.delay * Constants_js_1.millisecondsToSeconds);
|
|
66
|
-
};
|
|
67
|
-
_manageListeners = add => {
|
|
68
|
-
const handlers = this._handlers;
|
|
69
|
-
this._manageResize(add);
|
|
70
|
-
(0, Utils_js_1.manageListener)(document, Constants_js_1.visibilityChangeEvent, handlers.visibilityChange, add, false);
|
|
71
|
-
};
|
|
72
|
-
_manageResize = add => {
|
|
73
|
-
const handlers = this._handlers, container = this.container, options = container.actualOptions;
|
|
74
|
-
if (!options.resize.enable) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (typeof ResizeObserver === "undefined") {
|
|
78
|
-
(0, Utils_js_1.manageListener)(globalThis, Constants_js_1.resizeEvent, handlers.resize, add);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const canvasEl = container.canvas.element;
|
|
82
|
-
if (this._resizeObserver && !add) {
|
|
83
|
-
if (canvasEl) {
|
|
84
|
-
this._resizeObserver.unobserve(canvasEl);
|
|
85
|
-
}
|
|
86
|
-
this._resizeObserver.disconnect();
|
|
87
|
-
delete this._resizeObserver;
|
|
88
|
-
}
|
|
89
|
-
else if (!this._resizeObserver && add && canvasEl) {
|
|
90
|
-
this._resizeObserver = new ResizeObserver((entries) => {
|
|
91
|
-
const entry = entries.find(e => e.target === canvasEl);
|
|
92
|
-
if (!entry) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
this._handleWindowResize();
|
|
96
|
-
});
|
|
97
|
-
this._resizeObserver.observe(canvasEl);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
exports.EventListeners = EventListeners;
|
|
102
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Utils/Utils.js", "../../Enums/Types/EventType.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PluginManager = void 0;
|
|
13
|
-
const Utils_js_1 = require("../../Utils/Utils.js");
|
|
14
|
-
const EventType_js_1 = require("../../Enums/Types/EventType.js");
|
|
15
|
-
class PluginManager {
|
|
16
|
-
colorManagers = new Map();
|
|
17
|
-
easingFunctions = new Map();
|
|
18
|
-
effectDrawers = new Map();
|
|
19
|
-
initializers = {
|
|
20
|
-
effects: new Map(),
|
|
21
|
-
shapes: new Map(),
|
|
22
|
-
updaters: new Map(),
|
|
23
|
-
};
|
|
24
|
-
palettes = new Map();
|
|
25
|
-
plugins = [];
|
|
26
|
-
presets = new Map();
|
|
27
|
-
shapeDrawers = new Map();
|
|
28
|
-
updaters = new Map();
|
|
29
|
-
_allLoadersSet = new Set();
|
|
30
|
-
_configs = new Map();
|
|
31
|
-
_engine;
|
|
32
|
-
_executedSet = new Set();
|
|
33
|
-
_initialized = false;
|
|
34
|
-
_isRunningLoaders = false;
|
|
35
|
-
_loadPromises = new Set();
|
|
36
|
-
constructor(engine) {
|
|
37
|
-
this._engine = engine;
|
|
38
|
-
}
|
|
39
|
-
get configs() {
|
|
40
|
-
const res = {};
|
|
41
|
-
for (const [name, config] of this._configs) {
|
|
42
|
-
res[name] = config;
|
|
43
|
-
}
|
|
44
|
-
return res;
|
|
45
|
-
}
|
|
46
|
-
addColorManager(name, manager) {
|
|
47
|
-
this.colorManagers.set(name, manager);
|
|
48
|
-
}
|
|
49
|
-
addConfig(config) {
|
|
50
|
-
const key = config.key ?? config.name ?? "default";
|
|
51
|
-
this._configs.set(key, config);
|
|
52
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
|
|
53
|
-
}
|
|
54
|
-
addEasing(name, easing) {
|
|
55
|
-
if (this.easingFunctions.get(name)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.easingFunctions.set(name, easing);
|
|
59
|
-
}
|
|
60
|
-
addEffect(effect, drawer) {
|
|
61
|
-
this.initializers.effects.set(effect, drawer);
|
|
62
|
-
}
|
|
63
|
-
addPalette(name, palette) {
|
|
64
|
-
this.palettes.set(name, palette);
|
|
65
|
-
}
|
|
66
|
-
addParticleUpdater(name, updaterInitializer) {
|
|
67
|
-
this.initializers.updaters.set(name, updaterInitializer);
|
|
68
|
-
}
|
|
69
|
-
addPlugin(plugin) {
|
|
70
|
-
if (this.getPlugin(plugin.id)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.plugins.push(plugin);
|
|
74
|
-
}
|
|
75
|
-
addPreset(preset, options, override = false) {
|
|
76
|
-
if (!(override || !this.getPreset(preset))) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
this.presets.set(preset, options);
|
|
80
|
-
}
|
|
81
|
-
addShape(shapes, drawer) {
|
|
82
|
-
for (const shape of shapes) {
|
|
83
|
-
this.initializers.shapes.set(shape, drawer);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
clearPlugins(container) {
|
|
87
|
-
this.effectDrawers.delete(container);
|
|
88
|
-
this.shapeDrawers.delete(container);
|
|
89
|
-
this.updaters.delete(container);
|
|
90
|
-
}
|
|
91
|
-
getEasing(name) {
|
|
92
|
-
return this.easingFunctions.get(name) ?? ((value) => value);
|
|
93
|
-
}
|
|
94
|
-
getEffectDrawers(container, force = false) {
|
|
95
|
-
return (0, Utils_js_1.getItemMapFromInitializer)(container, this.effectDrawers, this.initializers.effects, force);
|
|
96
|
-
}
|
|
97
|
-
getPalette(name) {
|
|
98
|
-
return this.palettes.get(name);
|
|
99
|
-
}
|
|
100
|
-
getPlugin(plugin) {
|
|
101
|
-
return this.plugins.find(t => t.id === plugin);
|
|
102
|
-
}
|
|
103
|
-
getPreset(preset) {
|
|
104
|
-
return this.presets.get(preset);
|
|
105
|
-
}
|
|
106
|
-
async getShapeDrawers(container, force = false) {
|
|
107
|
-
return (0, Utils_js_1.getItemMapFromInitializer)(container, this.shapeDrawers, this.initializers.shapes, force);
|
|
108
|
-
}
|
|
109
|
-
async getUpdaters(container, force = false) {
|
|
110
|
-
return (0, Utils_js_1.getItemsFromInitializer)(container, this.updaters, this.initializers.updaters, force);
|
|
111
|
-
}
|
|
112
|
-
async init() {
|
|
113
|
-
if (this._initialized || this._isRunningLoaders) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
this._isRunningLoaders = true;
|
|
117
|
-
this._executedSet = new Set();
|
|
118
|
-
this._allLoadersSet = new Set(this._loadPromises);
|
|
119
|
-
try {
|
|
120
|
-
for (const loader of this._allLoadersSet) {
|
|
121
|
-
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
this._loadPromises.clear();
|
|
126
|
-
this._isRunningLoaders = false;
|
|
127
|
-
this._initialized = true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
loadParticlesOptions(container, options, ...sourceOptions) {
|
|
131
|
-
const updaters = this.updaters.get(container);
|
|
132
|
-
if (!updaters) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
|
|
136
|
-
}
|
|
137
|
-
async register(...loaders) {
|
|
138
|
-
if (this._initialized) {
|
|
139
|
-
throw new Error("Register plugins can only be done before calling tsParticles.load()");
|
|
140
|
-
}
|
|
141
|
-
for (const loader of loaders) {
|
|
142
|
-
if (this._isRunningLoaders) {
|
|
143
|
-
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
this._loadPromises.add(loader);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async _runLoader(loader, executed, allLoaders) {
|
|
151
|
-
if (executed.has(loader))
|
|
152
|
-
return;
|
|
153
|
-
executed.add(loader);
|
|
154
|
-
allLoaders.add(loader);
|
|
155
|
-
await loader(this._engine);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.PluginManager = PluginManager;
|
|
159
|
-
});
|
package/umd/Core/Utils/Ranges.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../Enums/RangeType.js", "../../Utils/MathUtils.js", "./Constants.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Rectangle = exports.Circle = exports.BaseRange = void 0;
|
|
13
|
-
const RangeType_js_1 = require("../../Enums/RangeType.js");
|
|
14
|
-
const MathUtils_js_1 = require("../../Utils/MathUtils.js");
|
|
15
|
-
const Constants_js_1 = require("./Constants.js");
|
|
16
|
-
class BaseRange {
|
|
17
|
-
position;
|
|
18
|
-
type;
|
|
19
|
-
constructor(x, y, type) {
|
|
20
|
-
this.position = {
|
|
21
|
-
x: x,
|
|
22
|
-
y: y,
|
|
23
|
-
};
|
|
24
|
-
this.type = type;
|
|
25
|
-
}
|
|
26
|
-
_resetPosition(x, y) {
|
|
27
|
-
this.position.x = x;
|
|
28
|
-
this.position.y = y;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.BaseRange = BaseRange;
|
|
32
|
-
class Circle extends BaseRange {
|
|
33
|
-
radius;
|
|
34
|
-
constructor(x, y, radius) {
|
|
35
|
-
super(x, y, RangeType_js_1.RangeType.circle);
|
|
36
|
-
this.radius = radius;
|
|
37
|
-
}
|
|
38
|
-
contains(point) {
|
|
39
|
-
return (0, MathUtils_js_1.checkDistance)(point, this.position, this.radius);
|
|
40
|
-
}
|
|
41
|
-
intersects(range) {
|
|
42
|
-
const pos1 = this.position, pos2 = range.position, r = this.radius, dx = Math.abs(pos2.x - pos1.x), dy = Math.abs(pos2.y - pos1.y);
|
|
43
|
-
if (range instanceof Circle || range.type === RangeType_js_1.RangeType.circle) {
|
|
44
|
-
const circleRange = range, rSum = r + circleRange.radius, dist = Math.hypot(dx, dy);
|
|
45
|
-
return rSum > dist;
|
|
46
|
-
}
|
|
47
|
-
else if (range instanceof Rectangle || range.type === RangeType_js_1.RangeType.rectangle) {
|
|
48
|
-
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(dx - width, Constants_js_1.squareExp) + Math.pow(dy - height, Constants_js_1.squareExp);
|
|
49
|
-
return edges <= r ** Constants_js_1.squareExp || (dx <= r + width && dy <= r + height) || dx <= width || dy <= height;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
reset(x, y, radius) {
|
|
54
|
-
this._resetPosition(x, y);
|
|
55
|
-
this.radius = radius;
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Circle = Circle;
|
|
60
|
-
class Rectangle extends BaseRange {
|
|
61
|
-
size;
|
|
62
|
-
constructor(x, y, width, height) {
|
|
63
|
-
super(x, y, RangeType_js_1.RangeType.rectangle);
|
|
64
|
-
this.size = {
|
|
65
|
-
height: height,
|
|
66
|
-
width: width,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
contains(point) {
|
|
70
|
-
const w = this.size.width, h = this.size.height, pos = this.position;
|
|
71
|
-
return point.x >= pos.x && point.x <= pos.x + w && point.y >= pos.y && point.y <= pos.y + h;
|
|
72
|
-
}
|
|
73
|
-
intersects(range) {
|
|
74
|
-
if (range instanceof Circle) {
|
|
75
|
-
return range.intersects(this);
|
|
76
|
-
}
|
|
77
|
-
if (!(range instanceof Rectangle)) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
const w = this.size.width, h = this.size.height, pos1 = this.position, pos2 = range.position, size2 = range.size, w2 = size2.width, h2 = size2.height;
|
|
81
|
-
return pos2.x < pos1.x + w && pos2.x + w2 > pos1.x && pos2.y < pos1.y + h && pos2.y + h2 > pos1.y;
|
|
82
|
-
}
|
|
83
|
-
reset(x, y, width, height) {
|
|
84
|
-
this._resetPosition(x, y);
|
|
85
|
-
this.size.width = width;
|
|
86
|
-
this.size.height = height;
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.Rectangle = Rectangle;
|
|
91
|
-
});
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Ranges.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SpatialHashGrid = void 0;
|
|
13
|
-
const Ranges_js_1 = require("./Ranges.js");
|
|
14
|
-
class SpatialHashGrid {
|
|
15
|
-
_cellSize;
|
|
16
|
-
_cells = new Map();
|
|
17
|
-
_circlePool = [];
|
|
18
|
-
_circlePoolIdx;
|
|
19
|
-
_pendingCellSize;
|
|
20
|
-
_rectanglePool = [];
|
|
21
|
-
_rectanglePoolIdx;
|
|
22
|
-
constructor(cellSize) {
|
|
23
|
-
this._cellSize = cellSize;
|
|
24
|
-
this._circlePoolIdx = 0;
|
|
25
|
-
this._rectanglePoolIdx = 0;
|
|
26
|
-
}
|
|
27
|
-
clear() {
|
|
28
|
-
this._cells.clear();
|
|
29
|
-
const pendingCellSize = this._pendingCellSize;
|
|
30
|
-
if (pendingCellSize) {
|
|
31
|
-
this._cellSize = pendingCellSize;
|
|
32
|
-
}
|
|
33
|
-
this._pendingCellSize = undefined;
|
|
34
|
-
}
|
|
35
|
-
insert(particle) {
|
|
36
|
-
const { x, y } = particle.getPosition(), key = this._cellKeyFromCoords(x, y);
|
|
37
|
-
if (!this._cells.has(key)) {
|
|
38
|
-
this._cells.set(key, []);
|
|
39
|
-
}
|
|
40
|
-
this._cells.get(key)?.push(particle);
|
|
41
|
-
}
|
|
42
|
-
query(range, check, out = []) {
|
|
43
|
-
const bounds = this._getRangeBounds(range);
|
|
44
|
-
if (!bounds) {
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
|
-
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);
|
|
48
|
-
for (let cx = minCellX; cx <= maxCellX; cx++) {
|
|
49
|
-
for (let cy = minCellY; cy <= maxCellY; cy++) {
|
|
50
|
-
const key = `${cx}_${cy}`, cellParticles = this._cells.get(key);
|
|
51
|
-
if (!cellParticles) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
for (const p of cellParticles) {
|
|
55
|
-
if (check && !check(p)) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (range.contains(p.getPosition())) {
|
|
59
|
-
out.push(p);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
queryCircle(position, radius, check, out = []) {
|
|
67
|
-
const circle = this._acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
|
|
68
|
-
this._releaseShapes();
|
|
69
|
-
return result;
|
|
70
|
-
}
|
|
71
|
-
queryRectangle(position, size, check, out = []) {
|
|
72
|
-
const rect = this._acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
|
|
73
|
-
this._releaseShapes();
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
setCellSize(cellSize) {
|
|
77
|
-
this._pendingCellSize = cellSize;
|
|
78
|
-
}
|
|
79
|
-
_acquireCircle(x, y, r) {
|
|
80
|
-
return (this._circlePool[this._circlePoolIdx++] ??= new Ranges_js_1.Circle(x, y, r)).reset(x, y, r);
|
|
81
|
-
}
|
|
82
|
-
_acquireRectangle(x, y, w, h) {
|
|
83
|
-
return (this._rectanglePool[this._rectanglePoolIdx++] ??= new Ranges_js_1.Rectangle(x, y, w, h)).reset(x, y, w, h);
|
|
84
|
-
}
|
|
85
|
-
_cellKeyFromCoords(x, y) {
|
|
86
|
-
const cellX = Math.floor(x / this._cellSize), cellY = Math.floor(y / this._cellSize);
|
|
87
|
-
return `${cellX}_${cellY}`;
|
|
88
|
-
}
|
|
89
|
-
_getRangeBounds(range) {
|
|
90
|
-
if (range instanceof Ranges_js_1.Circle) {
|
|
91
|
-
const r = range.radius, { x, y } = range.position;
|
|
92
|
-
return {
|
|
93
|
-
minX: x - r,
|
|
94
|
-
maxX: x + r,
|
|
95
|
-
minY: y - r,
|
|
96
|
-
maxY: y + r,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
if (range instanceof Ranges_js_1.Rectangle) {
|
|
100
|
-
const { x, y } = range.position, { width, height } = range.size;
|
|
101
|
-
return {
|
|
102
|
-
minX: x,
|
|
103
|
-
maxX: x + width,
|
|
104
|
-
minY: y,
|
|
105
|
-
maxY: y + height,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
_releaseShapes() {
|
|
111
|
-
this._circlePoolIdx = 0;
|
|
112
|
-
this._rectanglePoolIdx = 0;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.SpatialHashGrid = SpatialHashGrid;
|
|
116
|
-
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Constants.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Vector = exports.Vector3d = void 0;
|
|
13
|
-
const Constants_js_1 = require("./Constants.js");
|
|
14
|
-
function getZ(source) {
|
|
15
|
-
return "z" in source ? source.z : Constants_js_1.originPoint.z;
|
|
16
|
-
}
|
|
17
|
-
class Vector3d {
|
|
18
|
-
x;
|
|
19
|
-
y;
|
|
20
|
-
z;
|
|
21
|
-
constructor(x = Constants_js_1.originPoint.x, y = Constants_js_1.originPoint.y, z = Constants_js_1.originPoint.z) {
|
|
22
|
-
this.x = x;
|
|
23
|
-
this.y = y;
|
|
24
|
-
this.z = z;
|
|
25
|
-
}
|
|
26
|
-
static get origin() {
|
|
27
|
-
return Vector3d.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y, Constants_js_1.originPoint.z);
|
|
28
|
-
}
|
|
29
|
-
get angle() {
|
|
30
|
-
return Math.atan2(this.y, this.x);
|
|
31
|
-
}
|
|
32
|
-
set angle(angle) {
|
|
33
|
-
this._updateFromAngle(angle, this.length);
|
|
34
|
-
}
|
|
35
|
-
get length() {
|
|
36
|
-
return Math.sqrt(this.getLengthSq());
|
|
37
|
-
}
|
|
38
|
-
set length(length) {
|
|
39
|
-
this._updateFromAngle(this.angle, length);
|
|
40
|
-
}
|
|
41
|
-
static clone(source) {
|
|
42
|
-
return Vector3d.create(source.x, source.y, getZ(source));
|
|
43
|
-
}
|
|
44
|
-
static create(x, y, z) {
|
|
45
|
-
if (typeof x === "number") {
|
|
46
|
-
return new Vector3d(x, y ?? Constants_js_1.originPoint.y, z ?? Constants_js_1.originPoint.z);
|
|
47
|
-
}
|
|
48
|
-
return new Vector3d(x.x, x.y, getZ(x));
|
|
49
|
-
}
|
|
50
|
-
add(v) {
|
|
51
|
-
return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
|
|
52
|
-
}
|
|
53
|
-
addTo(v) {
|
|
54
|
-
this.x += v.x;
|
|
55
|
-
this.y += v.y;
|
|
56
|
-
this.z += getZ(v);
|
|
57
|
-
}
|
|
58
|
-
copy() {
|
|
59
|
-
return Vector3d.clone(this);
|
|
60
|
-
}
|
|
61
|
-
div(n) {
|
|
62
|
-
return Vector3d.create(this.x / n, this.y / n, this.z / n);
|
|
63
|
-
}
|
|
64
|
-
divTo(n) {
|
|
65
|
-
this.x /= n;
|
|
66
|
-
this.y /= n;
|
|
67
|
-
this.z /= n;
|
|
68
|
-
}
|
|
69
|
-
getLengthSq() {
|
|
70
|
-
return this.x ** Constants_js_1.squareExp + this.y ** Constants_js_1.squareExp;
|
|
71
|
-
}
|
|
72
|
-
mult(n) {
|
|
73
|
-
return Vector3d.create(this.x * n, this.y * n, this.z * n);
|
|
74
|
-
}
|
|
75
|
-
multTo(n) {
|
|
76
|
-
this.x *= n;
|
|
77
|
-
this.y *= n;
|
|
78
|
-
this.z *= n;
|
|
79
|
-
}
|
|
80
|
-
normalize() {
|
|
81
|
-
const length = this.length;
|
|
82
|
-
if (length != Constants_js_1.none) {
|
|
83
|
-
this.multTo(Constants_js_1.inverseFactorNumerator / length);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
rotate(angle) {
|
|
87
|
-
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), Constants_js_1.originPoint.z);
|
|
88
|
-
}
|
|
89
|
-
setTo(c) {
|
|
90
|
-
this.x = c.x;
|
|
91
|
-
this.y = c.y;
|
|
92
|
-
this.z = getZ(c);
|
|
93
|
-
}
|
|
94
|
-
sub(v) {
|
|
95
|
-
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
|
|
96
|
-
}
|
|
97
|
-
subFrom(v) {
|
|
98
|
-
this.x -= v.x;
|
|
99
|
-
this.y -= v.y;
|
|
100
|
-
this.z -= getZ(v);
|
|
101
|
-
}
|
|
102
|
-
_updateFromAngle(angle, length) {
|
|
103
|
-
this.x = Math.cos(angle) * length;
|
|
104
|
-
this.y = Math.sin(angle) * length;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
exports.Vector3d = Vector3d;
|
|
108
|
-
class Vector extends Vector3d {
|
|
109
|
-
constructor(x = Constants_js_1.originPoint.x, y = Constants_js_1.originPoint.y) {
|
|
110
|
-
super(x, y, Constants_js_1.originPoint.z);
|
|
111
|
-
}
|
|
112
|
-
static get origin() {
|
|
113
|
-
return Vector.create(Constants_js_1.originPoint.x, Constants_js_1.originPoint.y);
|
|
114
|
-
}
|
|
115
|
-
static clone(source) {
|
|
116
|
-
return Vector.create(source.x, source.y);
|
|
117
|
-
}
|
|
118
|
-
static create(x, y) {
|
|
119
|
-
if (typeof x === "number") {
|
|
120
|
-
return new Vector(x, y ?? Constants_js_1.originPoint.y);
|
|
121
|
-
}
|
|
122
|
-
return new Vector(x.x, x.y);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.Vector = Vector;
|
|
126
|
-
});
|