@tsparticles/updater-roll 3.0.0-alpha.1 → 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 +16 -12
- package/browser/Options/Classes/Roll.js +1 -1
- package/browser/RollUpdater.js +5 -57
- package/browser/Types.js +1 -0
- package/browser/Utils.js +54 -0
- package/browser/index.js +2 -2
- package/cjs/RollUpdater.js +6 -58
- package/cjs/Types.js +2 -0
- package/cjs/Utils.js +59 -0
- package/cjs/index.js +2 -13
- package/esm/Options/Classes/Roll.js +1 -1
- package/esm/RollUpdater.js +5 -57
- package/esm/Types.js +1 -0
- package/esm/Utils.js +54 -0
- package/esm/index.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.updater.roll.js +62 -57
- package/tsparticles.updater.roll.min.js +1 -1
- package/tsparticles.updater.roll.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/Roll.d.ts +1 -2
- package/types/Options/Classes/RollLight.d.ts +1 -1
- package/types/RollUpdater.d.ts +2 -13
- package/types/Types.d.ts +12 -0
- package/types/Utils.d.ts +4 -0
- package/types/index.d.ts +1 -1
- package/umd/RollUpdater.js +7 -59
- package/umd/Types.js +12 -0
- package/umd/Utils.js +69 -0
- package/umd/index.js +2 -2
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-
|
|
7
|
+
* v3.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,11 +91,65 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
94
|
+
loadRollUpdater: () => (/* binding */ loadRollUpdater)
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
98
|
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
100
|
+
|
|
101
|
+
function initParticle(particle) {
|
|
102
|
+
const rollOpt = particle.options.roll;
|
|
103
|
+
if (!rollOpt?.enable) {
|
|
104
|
+
particle.roll = {
|
|
105
|
+
enable: false,
|
|
106
|
+
horizontal: false,
|
|
107
|
+
vertical: false,
|
|
108
|
+
angle: 0,
|
|
109
|
+
speed: 0
|
|
110
|
+
};
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
particle.roll = {
|
|
114
|
+
enable: rollOpt.enable,
|
|
115
|
+
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
|
|
116
|
+
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
|
|
117
|
+
angle: (0,engine_root_window_.getRandom)() * Math.PI * 2,
|
|
118
|
+
speed: (0,engine_root_window_.getRangeValue)(rollOpt.speed) / 360
|
|
119
|
+
};
|
|
120
|
+
if (rollOpt.backColor) {
|
|
121
|
+
particle.backColor = (0,engine_root_window_.rangeColorToHsl)(rollOpt.backColor);
|
|
122
|
+
} else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
|
|
123
|
+
const alterType = (0,engine_root_window_.getRandom)() >= 0.5 ? "darken" : "enlighten";
|
|
124
|
+
particle.roll.alter = {
|
|
125
|
+
type: alterType,
|
|
126
|
+
value: (0,engine_root_window_.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
|
|
127
|
+
};
|
|
128
|
+
} else if (rollOpt.darken.enable) {
|
|
129
|
+
particle.roll.alter = {
|
|
130
|
+
type: "darken",
|
|
131
|
+
value: (0,engine_root_window_.getRangeValue)(rollOpt.darken.value)
|
|
132
|
+
};
|
|
133
|
+
} else if (rollOpt.enlighten.enable) {
|
|
134
|
+
particle.roll.alter = {
|
|
135
|
+
type: "enlighten",
|
|
136
|
+
value: (0,engine_root_window_.getRangeValue)(rollOpt.enlighten.value)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function updateRoll(particle, delta) {
|
|
141
|
+
const roll = particle.options.roll,
|
|
142
|
+
data = particle.roll;
|
|
143
|
+
if (!data || !roll?.enable) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const speed = data.speed * delta.factor,
|
|
147
|
+
max = 2 * Math.PI;
|
|
148
|
+
data.angle += speed;
|
|
149
|
+
if (data.angle > max) {
|
|
150
|
+
data.angle -= max;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
99
153
|
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/RollLight.js
|
|
100
154
|
|
|
101
155
|
class RollLight {
|
|
@@ -149,22 +203,9 @@ class Roll {
|
|
|
149
203
|
;// CONCATENATED MODULE: ./dist/browser/RollUpdater.js
|
|
150
204
|
|
|
151
205
|
|
|
152
|
-
function updateRoll(particle, delta) {
|
|
153
|
-
const roll = particle.options.roll;
|
|
154
|
-
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const speed = particle.roll.speed * delta.factor,
|
|
158
|
-
max = 2 * Math.PI;
|
|
159
|
-
particle.roll.angle += speed;
|
|
160
|
-
if (particle.roll.angle > max) {
|
|
161
|
-
particle.roll.angle -= max;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
206
|
class RollUpdater {
|
|
165
207
|
getTransformValues(particle) {
|
|
166
|
-
|
|
167
|
-
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll,
|
|
208
|
+
const roll = particle.roll?.enable && particle.roll,
|
|
168
209
|
rollHorizontal = roll && roll.horizontal,
|
|
169
210
|
rollVertical = roll && roll.vertical;
|
|
170
211
|
return {
|
|
@@ -173,54 +214,18 @@ class RollUpdater {
|
|
|
173
214
|
};
|
|
174
215
|
}
|
|
175
216
|
init(particle) {
|
|
176
|
-
|
|
177
|
-
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
|
|
178
|
-
particle.roll = {
|
|
179
|
-
enable: rollOpt.enable,
|
|
180
|
-
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
|
|
181
|
-
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
|
|
182
|
-
angle: (0,engine_root_window_.getRandom)() * Math.PI * 2,
|
|
183
|
-
speed: (0,engine_root_window_.getRangeValue)(rollOpt.speed) / 360
|
|
184
|
-
};
|
|
185
|
-
if (rollOpt.backColor) {
|
|
186
|
-
particle.backColor = (0,engine_root_window_.rangeColorToHsl)(rollOpt.backColor);
|
|
187
|
-
} else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
|
|
188
|
-
const alterType = (0,engine_root_window_.getRandom)() >= 0.5 ? "darken" : "enlighten";
|
|
189
|
-
particle.roll.alter = {
|
|
190
|
-
type: alterType,
|
|
191
|
-
value: (0,engine_root_window_.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value)
|
|
192
|
-
};
|
|
193
|
-
} else if (rollOpt.darken.enable) {
|
|
194
|
-
particle.roll.alter = {
|
|
195
|
-
type: "darken",
|
|
196
|
-
value: (0,engine_root_window_.getRangeValue)(rollOpt.darken.value)
|
|
197
|
-
};
|
|
198
|
-
} else if (rollOpt.enlighten.enable) {
|
|
199
|
-
particle.roll.alter = {
|
|
200
|
-
type: "enlighten",
|
|
201
|
-
value: (0,engine_root_window_.getRangeValue)(rollOpt.enlighten.value)
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
particle.roll = {
|
|
206
|
-
enable: false,
|
|
207
|
-
horizontal: false,
|
|
208
|
-
vertical: false,
|
|
209
|
-
angle: 0,
|
|
210
|
-
speed: 0
|
|
211
|
-
};
|
|
212
|
-
}
|
|
217
|
+
initParticle(particle);
|
|
213
218
|
}
|
|
214
219
|
isEnabled(particle) {
|
|
215
220
|
const roll = particle.options.roll;
|
|
216
|
-
return !particle.destroyed && !particle.spawning && !!
|
|
221
|
+
return !particle.destroyed && !particle.spawning && !!roll?.enable;
|
|
217
222
|
}
|
|
218
223
|
loadOptions(options, ...sources) {
|
|
219
224
|
if (!options.roll) {
|
|
220
225
|
options.roll = new Roll();
|
|
221
226
|
}
|
|
222
227
|
for (const source of sources) {
|
|
223
|
-
options.roll.load(source
|
|
228
|
+
options.roll.load(source?.roll);
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
update(particle, delta) {
|
|
@@ -232,8 +237,8 @@ class RollUpdater {
|
|
|
232
237
|
}
|
|
233
238
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
234
239
|
|
|
235
|
-
async function loadRollUpdater(engine) {
|
|
236
|
-
await engine.addParticleUpdater("roll", () => new RollUpdater());
|
|
240
|
+
async function loadRollUpdater(engine, refresh = true) {
|
|
241
|
+
await engine.addParticleUpdater("roll", () => new RollUpdater(), refresh);
|
|
237
242
|
}
|
|
238
243
|
})();
|
|
239
244
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.roll.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,
|
|
2
|
+
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var l="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var t in l)("object"==typeof exports?exports:e)[t]=l[t]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},l={};function t(e){var n=l[e];if(void 0!==n)return n.exports;var a=l[e]={exports:{}};return o[e](a,a.exports,t),a.exports}t.d=(e,o)=>{for(var l in o)t.o(o,l)&&!t.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:o[l]})},t.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{t.r(n),t.d(n,{loadRollUpdater:()=>r});var e=t(533);class o{constructor(){this.enable=!1,this.value=0}load(o){o&&(void 0!==o.enable&&(this.enable=o.enable),void 0!==o.value&&(this.value=(0,e.setRangeValue)(o.value)))}}class l{constructor(){this.darken=new o,this.enable=!1,this.enlighten=new o,this.mode="vertical",this.speed=25}load(o){o&&(void 0!==o.backColor&&(this.backColor=e.OptionsColor.create(this.backColor,o.backColor)),this.darken.load(o.darken),void 0!==o.enable&&(this.enable=o.enable),this.enlighten.load(o.enlighten),void 0!==o.mode&&(this.mode=o.mode),void 0!==o.speed&&(this.speed=(0,e.setRangeValue)(o.speed)))}}class a{getTransformValues(e){const o=e.roll?.enable&&e.roll,l=o&&o.horizontal,t=o&&o.vertical;return{a:l?Math.cos(o.angle):void 0,d:t?Math.sin(o.angle):void 0}}init(o){!function(o){const l=o.options.roll;if(l?.enable)if(o.roll={enable:l.enable,horizontal:"horizontal"===l.mode||"both"===l.mode,vertical:"vertical"===l.mode||"both"===l.mode,angle:(0,e.getRandom)()*Math.PI*2,speed:(0,e.getRangeValue)(l.speed)/360},l.backColor)o.backColor=(0,e.rangeColorToHsl)(l.backColor);else if(l.darken.enable&&l.enlighten.enable){const t=(0,e.getRandom)()>=.5?"darken":"enlighten";o.roll.alter={type:t,value:(0,e.getRangeValue)("darken"===t?l.darken.value:l.enlighten.value)}}else l.darken.enable?o.roll.alter={type:"darken",value:(0,e.getRangeValue)(l.darken.value)}:l.enlighten.enable&&(o.roll.alter={type:"enlighten",value:(0,e.getRangeValue)(l.enlighten.value)});else o.roll={enable:!1,horizontal:!1,vertical:!1,angle:0,speed:0}}(o)}isEnabled(e){const o=e.options.roll;return!e.destroyed&&!e.spawning&&!!o?.enable}loadOptions(e,...o){e.roll||(e.roll=new l);for(const l of o)e.roll.load(l?.roll)}update(e,o){this.isEnabled(e)&&function(e,o){const l=e.options.roll,t=e.roll;if(!t||!l?.enable)return;const n=t.speed*o.factor,a=2*Math.PI;t.angle+=n,t.angle>a&&(t.angle-=a)}(e,o)}}async function r(e,o=!0){await e.addParticleUpdater("roll",(()=>new a),o)}})(),n})()));
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Author : Matteo Bruni
|
|
3
|
-
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
-
* Demo / Generator : https://particles.js.org/
|
|
5
|
-
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
-
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0.0-alpha.1
|
|
8
|
-
*/
|
|
1
|
+
/*! tsParticles Roll Updater v3.0.0-beta.0 by Matteo Bruni */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { OptionsColor } from "@tsparticles/engine";
|
|
1
|
+
import { type IOptionLoader, OptionsColor, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
|
|
3
2
|
import type { IRoll } from "../Interfaces/IRoll";
|
|
4
3
|
import { RollLight } from "./RollLight";
|
|
5
4
|
import { RollMode } from "../../RollMode";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IRollLight } from "../Interfaces/IRollLight";
|
|
3
3
|
export declare class RollLight implements IRollLight, IOptionLoader<IRollLight> {
|
|
4
4
|
enable: boolean;
|
package/types/RollUpdater.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
import { Roll } from "./Options/Classes/Roll";
|
|
4
|
-
type RollParticle = Particle & {
|
|
5
|
-
options: RollParticlesOptions;
|
|
6
|
-
};
|
|
7
|
-
type RollParticlesOptions = ParticlesOptions & {
|
|
8
|
-
roll?: Roll;
|
|
9
|
-
};
|
|
10
|
-
type IRollParticlesOptions = IParticlesOptions & {
|
|
11
|
-
roll?: IRoll;
|
|
12
|
-
};
|
|
1
|
+
import { type IDelta, type IParticleTransformValues, type IParticleUpdater, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IRollParticlesOptions, RollParticle, RollParticlesOptions } from "./Types";
|
|
13
3
|
export declare class RollUpdater implements IParticleUpdater {
|
|
14
4
|
getTransformValues(particle: Particle): IParticleTransformValues;
|
|
15
5
|
init(particle: RollParticle): void;
|
|
@@ -17,4 +7,3 @@ export declare class RollUpdater implements IParticleUpdater {
|
|
|
17
7
|
loadOptions(options: RollParticlesOptions, ...sources: (RecursivePartial<IRollParticlesOptions> | undefined)[]): void;
|
|
18
8
|
update(particle: Particle, delta: IDelta): void;
|
|
19
9
|
}
|
|
20
|
-
export {};
|
package/types/Types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IParticlesOptions, type Particle, type ParticlesOptions } from "@tsparticles/engine";
|
|
2
|
+
import type { IRoll } from "./Options/Interfaces/IRoll";
|
|
3
|
+
import type { Roll } from "./Options/Classes/Roll";
|
|
4
|
+
export type RollParticle = Particle & {
|
|
5
|
+
options: RollParticlesOptions;
|
|
6
|
+
};
|
|
7
|
+
export type RollParticlesOptions = ParticlesOptions & {
|
|
8
|
+
roll?: Roll;
|
|
9
|
+
};
|
|
10
|
+
export type IRollParticlesOptions = IParticlesOptions & {
|
|
11
|
+
roll?: IRoll;
|
|
12
|
+
};
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
export declare function loadRollUpdater(engine: Engine): Promise<void>;
|
|
2
|
+
export declare function loadRollUpdater(engine: Engine, refresh?: boolean): Promise<void>;
|
package/umd/RollUpdater.js
CHANGED
|
@@ -4,94 +4,42 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "./Utils", "./Options/Classes/Roll"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RollUpdater = void 0;
|
|
13
|
-
const
|
|
13
|
+
const Utils_1 = require("./Utils");
|
|
14
14
|
const Roll_1 = require("./Options/Classes/Roll");
|
|
15
|
-
function updateRoll(particle, delta) {
|
|
16
|
-
const roll = particle.options.roll;
|
|
17
|
-
if (!particle.roll || !(roll === null || roll === void 0 ? void 0 : roll.enable)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const speed = particle.roll.speed * delta.factor, max = 2 * Math.PI;
|
|
21
|
-
particle.roll.angle += speed;
|
|
22
|
-
if (particle.roll.angle > max) {
|
|
23
|
-
particle.roll.angle -= max;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
15
|
class RollUpdater {
|
|
27
16
|
getTransformValues(particle) {
|
|
28
|
-
|
|
29
|
-
const roll = ((_a = particle.roll) === null || _a === void 0 ? void 0 : _a.enable) && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
|
|
17
|
+
const roll = particle.roll?.enable && particle.roll, rollHorizontal = roll && roll.horizontal, rollVertical = roll && roll.vertical;
|
|
30
18
|
return {
|
|
31
19
|
a: rollHorizontal ? Math.cos(roll.angle) : undefined,
|
|
32
20
|
d: rollVertical ? Math.sin(roll.angle) : undefined,
|
|
33
21
|
};
|
|
34
22
|
}
|
|
35
23
|
init(particle) {
|
|
36
|
-
|
|
37
|
-
if (rollOpt === null || rollOpt === void 0 ? void 0 : rollOpt.enable) {
|
|
38
|
-
particle.roll = {
|
|
39
|
-
enable: rollOpt.enable,
|
|
40
|
-
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
|
|
41
|
-
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
|
|
42
|
-
angle: (0, engine_1.getRandom)() * Math.PI * 2,
|
|
43
|
-
speed: (0, engine_1.getRangeValue)(rollOpt.speed) / 360,
|
|
44
|
-
};
|
|
45
|
-
if (rollOpt.backColor) {
|
|
46
|
-
particle.backColor = (0, engine_1.rangeColorToHsl)(rollOpt.backColor);
|
|
47
|
-
}
|
|
48
|
-
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
|
|
49
|
-
const alterType = (0, engine_1.getRandom)() >= 0.5 ? "darken" : "enlighten";
|
|
50
|
-
particle.roll.alter = {
|
|
51
|
-
type: alterType,
|
|
52
|
-
value: (0, engine_1.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
else if (rollOpt.darken.enable) {
|
|
56
|
-
particle.roll.alter = {
|
|
57
|
-
type: "darken",
|
|
58
|
-
value: (0, engine_1.getRangeValue)(rollOpt.darken.value),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
else if (rollOpt.enlighten.enable) {
|
|
62
|
-
particle.roll.alter = {
|
|
63
|
-
type: "enlighten",
|
|
64
|
-
value: (0, engine_1.getRangeValue)(rollOpt.enlighten.value),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
particle.roll = {
|
|
70
|
-
enable: false,
|
|
71
|
-
horizontal: false,
|
|
72
|
-
vertical: false,
|
|
73
|
-
angle: 0,
|
|
74
|
-
speed: 0,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
24
|
+
(0, Utils_1.initParticle)(particle);
|
|
77
25
|
}
|
|
78
26
|
isEnabled(particle) {
|
|
79
27
|
const roll = particle.options.roll;
|
|
80
|
-
return !particle.destroyed && !particle.spawning && !!
|
|
28
|
+
return !particle.destroyed && !particle.spawning && !!roll?.enable;
|
|
81
29
|
}
|
|
82
30
|
loadOptions(options, ...sources) {
|
|
83
31
|
if (!options.roll) {
|
|
84
32
|
options.roll = new Roll_1.Roll();
|
|
85
33
|
}
|
|
86
34
|
for (const source of sources) {
|
|
87
|
-
options.roll.load(source
|
|
35
|
+
options.roll.load(source?.roll);
|
|
88
36
|
}
|
|
89
37
|
}
|
|
90
38
|
update(particle, delta) {
|
|
91
39
|
if (!this.isEnabled(particle)) {
|
|
92
40
|
return;
|
|
93
41
|
}
|
|
94
|
-
updateRoll(particle, delta);
|
|
42
|
+
(0, Utils_1.updateRoll)(particle, delta);
|
|
95
43
|
}
|
|
96
44
|
}
|
|
97
45
|
exports.RollUpdater = RollUpdater;
|
package/umd/Types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
});
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.updateRoll = exports.initParticle = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
function initParticle(particle) {
|
|
15
|
+
const rollOpt = particle.options.roll;
|
|
16
|
+
if (!rollOpt?.enable) {
|
|
17
|
+
particle.roll = {
|
|
18
|
+
enable: false,
|
|
19
|
+
horizontal: false,
|
|
20
|
+
vertical: false,
|
|
21
|
+
angle: 0,
|
|
22
|
+
speed: 0,
|
|
23
|
+
};
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
particle.roll = {
|
|
27
|
+
enable: rollOpt.enable,
|
|
28
|
+
horizontal: rollOpt.mode === "horizontal" || rollOpt.mode === "both",
|
|
29
|
+
vertical: rollOpt.mode === "vertical" || rollOpt.mode === "both",
|
|
30
|
+
angle: (0, engine_1.getRandom)() * Math.PI * 2,
|
|
31
|
+
speed: (0, engine_1.getRangeValue)(rollOpt.speed) / 360,
|
|
32
|
+
};
|
|
33
|
+
if (rollOpt.backColor) {
|
|
34
|
+
particle.backColor = (0, engine_1.rangeColorToHsl)(rollOpt.backColor);
|
|
35
|
+
}
|
|
36
|
+
else if (rollOpt.darken.enable && rollOpt.enlighten.enable) {
|
|
37
|
+
const alterType = (0, engine_1.getRandom)() >= 0.5 ? "darken" : "enlighten";
|
|
38
|
+
particle.roll.alter = {
|
|
39
|
+
type: alterType,
|
|
40
|
+
value: (0, engine_1.getRangeValue)(alterType === "darken" ? rollOpt.darken.value : rollOpt.enlighten.value),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else if (rollOpt.darken.enable) {
|
|
44
|
+
particle.roll.alter = {
|
|
45
|
+
type: "darken",
|
|
46
|
+
value: (0, engine_1.getRangeValue)(rollOpt.darken.value),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else if (rollOpt.enlighten.enable) {
|
|
50
|
+
particle.roll.alter = {
|
|
51
|
+
type: "enlighten",
|
|
52
|
+
value: (0, engine_1.getRangeValue)(rollOpt.enlighten.value),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.initParticle = initParticle;
|
|
57
|
+
function updateRoll(particle, delta) {
|
|
58
|
+
const roll = particle.options.roll, data = particle.roll;
|
|
59
|
+
if (!data || !roll?.enable) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const speed = data.speed * delta.factor, max = 2 * Math.PI;
|
|
63
|
+
data.angle += speed;
|
|
64
|
+
if (data.angle > max) {
|
|
65
|
+
data.angle -= max;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.updateRoll = updateRoll;
|
|
69
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadRollUpdater = void 0;
|
|
13
13
|
const RollUpdater_1 = require("./RollUpdater");
|
|
14
|
-
async function loadRollUpdater(engine) {
|
|
15
|
-
await engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater());
|
|
14
|
+
async function loadRollUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("roll", () => new RollUpdater_1.RollUpdater(), refresh);
|
|
16
16
|
}
|
|
17
17
|
exports.loadRollUpdater = loadRollUpdater;
|
|
18
18
|
});
|