@tsparticles/updater-tilt 3.0.0-alpha.1 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/browser/Options/Classes/Tilt.js +1 -1
- package/browser/TiltUpdater.js +9 -39
- package/browser/Types.js +1 -0
- package/browser/Utils.js +27 -0
- package/browser/index.js +3 -3
- package/browser/package.json +1 -0
- package/cjs/Options/Classes/Tilt.js +2 -2
- package/cjs/TiltUpdater.js +10 -40
- package/cjs/Types.js +2 -0
- package/cjs/Utils.js +31 -0
- package/cjs/index.js +3 -14
- package/cjs/package.json +1 -0
- package/esm/Options/Classes/Tilt.js +1 -1
- package/esm/TiltUpdater.js +9 -39
- package/esm/Types.js +1 -0
- package/esm/Utils.js +27 -0
- package/esm/index.js +3 -3
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.updater.tilt.js +17 -19
- package/tsparticles.updater.tilt.min.js +1 -1
- package/tsparticles.updater.tilt.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/Tilt.d.ts +5 -6
- package/types/Options/Classes/TiltAnimation.d.ts +2 -2
- package/types/Options/Interfaces/ITilt.d.ts +2 -2
- package/types/TiltUpdater.d.ts +2 -18
- package/types/Types.d.ts +17 -0
- package/types/Utils.d.ts +3 -0
- package/types/index.d.ts +1 -1
- package/umd/Options/Classes/Tilt.js +3 -3
- package/umd/TiltUpdater.js +11 -41
- package/umd/Types.js +12 -0
- package/umd/Utils.js +41 -0
- package/umd/index.js +4 -4
|
@@ -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.1
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
91
91
|
|
|
92
92
|
// EXPORTS
|
|
93
93
|
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
|
|
94
|
+
loadTiltUpdater: () => (/* binding */ loadTiltUpdater)
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
@@ -148,19 +148,16 @@ class Tilt extends engine_root_window_.ValueWithRandom {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
;// CONCATENATED MODULE: ./dist/browser/
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
154
152
|
function updateTilt(particle, delta) {
|
|
155
|
-
var _a, _b;
|
|
156
153
|
if (!particle.tilt || !particle.options.tilt) {
|
|
157
154
|
return;
|
|
158
155
|
}
|
|
159
156
|
const tilt = particle.options.tilt,
|
|
160
157
|
tiltAnimation = tilt.animation,
|
|
161
|
-
speed = (
|
|
158
|
+
speed = (particle.tilt.velocity ?? 0) * delta.factor,
|
|
162
159
|
max = 2 * Math.PI,
|
|
163
|
-
decay =
|
|
160
|
+
decay = particle.tilt.decay ?? 1;
|
|
164
161
|
if (!tiltAnimation.enable) {
|
|
165
162
|
return;
|
|
166
163
|
}
|
|
@@ -183,20 +180,22 @@ function updateTilt(particle, delta) {
|
|
|
183
180
|
particle.tilt.velocity *= decay;
|
|
184
181
|
}
|
|
185
182
|
}
|
|
183
|
+
;// CONCATENATED MODULE: ./dist/browser/TiltUpdater.js
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
186
187
|
class TiltUpdater {
|
|
187
188
|
constructor(container) {
|
|
188
189
|
this.container = container;
|
|
189
190
|
}
|
|
190
191
|
getTransformValues(particle) {
|
|
191
|
-
|
|
192
|
-
const tilt = ((_a = particle.tilt) === null || _a === void 0 ? void 0 : _a.enable) && particle.tilt;
|
|
192
|
+
const tilt = particle.tilt?.enable && particle.tilt;
|
|
193
193
|
return {
|
|
194
194
|
b: tilt ? Math.cos(tilt.value) * tilt.cosDirection : undefined,
|
|
195
195
|
c: tilt ? Math.sin(tilt.value) * tilt.sinDirection : undefined
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
init(particle) {
|
|
199
|
-
var _a;
|
|
200
199
|
const tiltOptions = particle.options.tilt;
|
|
201
200
|
if (!tiltOptions) {
|
|
202
201
|
return;
|
|
@@ -221,8 +220,8 @@ class TiltUpdater {
|
|
|
221
220
|
particle.tilt.status = "increasing";
|
|
222
221
|
break;
|
|
223
222
|
}
|
|
224
|
-
const tiltAnimation =
|
|
225
|
-
if (tiltAnimation
|
|
223
|
+
const tiltAnimation = particle.options.tilt?.animation;
|
|
224
|
+
if (tiltAnimation?.enable) {
|
|
226
225
|
particle.tilt.decay = 1 - (0,engine_root_window_.getRangeValue)(tiltAnimation.decay);
|
|
227
226
|
particle.tilt.velocity = (0,engine_root_window_.getRangeValue)(tiltAnimation.speed) / 360 * this.container.retina.reduceFactor;
|
|
228
227
|
if (!tiltAnimation.sync) {
|
|
@@ -231,16 +230,15 @@ class TiltUpdater {
|
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
232
|
isEnabled(particle) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return !particle.destroyed && !particle.spawning && !!(tiltAnimation === null || tiltAnimation === void 0 ? void 0 : tiltAnimation.enable);
|
|
233
|
+
const tiltAnimation = particle.options.tilt?.animation;
|
|
234
|
+
return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;
|
|
237
235
|
}
|
|
238
236
|
loadOptions(options, ...sources) {
|
|
239
237
|
if (!options.tilt) {
|
|
240
238
|
options.tilt = new Tilt();
|
|
241
239
|
}
|
|
242
240
|
for (const source of sources) {
|
|
243
|
-
options.tilt.load(source
|
|
241
|
+
options.tilt.load(source?.tilt);
|
|
244
242
|
}
|
|
245
243
|
}
|
|
246
244
|
update(particle, delta) {
|
|
@@ -252,8 +250,8 @@ class TiltUpdater {
|
|
|
252
250
|
}
|
|
253
251
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
254
252
|
|
|
255
|
-
async function loadTiltUpdater(engine) {
|
|
256
|
-
await engine.addParticleUpdater("tilt", container => new TiltUpdater(container));
|
|
253
|
+
async function loadTiltUpdater(engine, refresh = true) {
|
|
254
|
+
await engine.addParticleUpdater("tilt", container => new TiltUpdater(container), refresh);
|
|
257
255
|
}
|
|
258
256
|
})();
|
|
259
257
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.tilt.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in i)("object"==typeof exports?exports:t)[o]=i[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function o(t){var n=i[t];if(void 0!==n)return n.exports;var a=i[t]={exports:{}};return e[t](a,a.exports,o),a.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadTiltUpdater:()=>
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var o in i)("object"==typeof exports?exports:t)[o]=i[o]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function o(t){var n=i[t];if(void 0!==n)return n.exports;var a=i[t]={exports:{}};return e[t](a,a.exports,o),a.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadTiltUpdater:()=>s});var t=o(533);class e{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(e){e&&(void 0!==e.enable&&(this.enable=e.enable),void 0!==e.speed&&(this.speed=(0,t.setRangeValue)(e.speed)),void 0!==e.decay&&(this.decay=(0,t.setRangeValue)(e.decay)),void 0!==e.sync&&(this.sync=e.sync))}}class i extends t.ValueWithRandom{constructor(){super(),this.animation=new e,this.direction="clockwise",this.enable=!1,this.value=0}load(t){super.load(t),t&&(this.animation.load(t.animation),void 0!==t.direction&&(this.direction=t.direction),void 0!==t.enable&&(this.enable=t.enable))}}class a{constructor(t){this.container=t}getTransformValues(t){const e=t.tilt?.enable&&t.tilt;return{b:e?Math.cos(e.value)*e.cosDirection:void 0,c:e?Math.sin(e.value)*e.sinDirection:void 0}}init(e){const i=e.options.tilt;if(!i)return;e.tilt={enable:i.enable,value:(0,t.getRangeValue)(i.value)*Math.PI/180,sinDirection:(0,t.getRandom)()>=.5?1:-1,cosDirection:(0,t.getRandom)()>=.5?1:-1};let o=i.direction;if("random"===o){o=Math.floor(2*(0,t.getRandom)())>0?"counter-clockwise":"clockwise"}switch(o){case"counter-clockwise":case"counterClockwise":e.tilt.status="decreasing";break;case"clockwise":e.tilt.status="increasing"}const n=e.options.tilt?.animation;n?.enable&&(e.tilt.decay=1-(0,t.getRangeValue)(n.decay),e.tilt.velocity=(0,t.getRangeValue)(n.speed)/360*this.container.retina.reduceFactor,n.sync||(e.tilt.velocity*=(0,t.getRandom)()))}isEnabled(t){const e=t.options.tilt?.animation;return!t.destroyed&&!t.spawning&&!!e?.enable}loadOptions(t,...e){t.tilt||(t.tilt=new i);for(const i of e)t.tilt.load(i?.tilt)}update(t,e){this.isEnabled(t)&&function(t,e){if(!t.tilt||!t.options.tilt)return;const i=t.options.tilt.animation,o=(t.tilt.velocity??0)*e.factor,n=2*Math.PI,a=t.tilt.decay??1;i.enable&&("increasing"===t.tilt.status?(t.tilt.value+=o,t.tilt.value>n&&(t.tilt.value-=n)):(t.tilt.value-=o,t.tilt.value<0&&(t.tilt.value+=n)),t.tilt.velocity&&1!==a&&(t.tilt.velocity*=a))}(t,e)}}async function s(t,e=!0){await t.addParticleUpdater("tilt",(t=>new a(t)),e)}})(),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 Tilt Updater v3.0.0-beta.1 by Matteo Bruni */
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ITilt } from "../Interfaces/ITilt";
|
|
3
|
-
import { TiltAnimation } from "./TiltAnimation";
|
|
4
|
-
import { TiltDirection } from "../../TiltDirection";
|
|
5
|
-
import type { TiltDirectionAlt } from "../../TiltDirection";
|
|
6
|
-
import { ValueWithRandom } from "@tsparticles/engine";
|
|
1
|
+
import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
|
|
2
|
+
import type { ITilt } from "../Interfaces/ITilt.js";
|
|
3
|
+
import { TiltAnimation } from "./TiltAnimation.js";
|
|
4
|
+
import { TiltDirection } from "../../TiltDirection.js";
|
|
5
|
+
import type { TiltDirectionAlt } from "../../TiltDirection.js";
|
|
7
6
|
export declare class Tilt extends ValueWithRandom implements ITilt, IOptionLoader<ITilt> {
|
|
8
7
|
animation: TiltAnimation;
|
|
9
8
|
direction: TiltDirection | keyof typeof TiltDirection | TiltDirectionAlt;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { ITiltAnimation } from "../Interfaces/ITiltAnimation";
|
|
1
|
+
import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITiltAnimation } from "../Interfaces/ITiltAnimation.js";
|
|
3
3
|
export declare class TiltAnimation implements ITiltAnimation, IOptionLoader<ITiltAnimation> {
|
|
4
4
|
decay: RangeValue;
|
|
5
5
|
enable: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TiltDirection, TiltDirectionAlt } from "../../TiltDirection";
|
|
2
|
-
import type { ITiltAnimation } from "./ITiltAnimation";
|
|
1
|
+
import type { TiltDirection, TiltDirectionAlt } from "../../TiltDirection.js";
|
|
2
|
+
import type { ITiltAnimation } from "./ITiltAnimation.js";
|
|
3
3
|
import type { IValueWithRandom } from "@tsparticles/engine";
|
|
4
4
|
export interface ITilt extends IValueWithRandom {
|
|
5
5
|
animation: ITiltAnimation;
|
package/types/TiltUpdater.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
import { Tilt } from "./Options/Classes/Tilt";
|
|
4
|
-
export interface IParticleTiltValueAnimation extends IParticleValueAnimation<number> {
|
|
5
|
-
cosDirection: number;
|
|
6
|
-
sinDirection: number;
|
|
7
|
-
}
|
|
8
|
-
type TiltParticle = Particle & {
|
|
9
|
-
options: TiltParticlesOptions;
|
|
10
|
-
tilt?: IParticleTiltValueAnimation;
|
|
11
|
-
};
|
|
12
|
-
type ITiltParticlesOptions = IParticlesOptions & {
|
|
13
|
-
tilt?: ITilt;
|
|
14
|
-
};
|
|
15
|
-
type TiltParticlesOptions = ParticlesOptions & {
|
|
16
|
-
tilt?: Tilt;
|
|
17
|
-
};
|
|
1
|
+
import { type Container, type IDelta, type IParticleTransformValues, type IParticleUpdater, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { ITiltParticlesOptions, TiltParticle, TiltParticlesOptions } from "./Types.js";
|
|
18
3
|
export declare class TiltUpdater implements IParticleUpdater {
|
|
19
4
|
private readonly container;
|
|
20
5
|
constructor(container: Container);
|
|
@@ -24,4 +9,3 @@ export declare class TiltUpdater implements IParticleUpdater {
|
|
|
24
9
|
loadOptions(options: TiltParticlesOptions, ...sources: (RecursivePartial<ITiltParticlesOptions> | undefined)[]): void;
|
|
25
10
|
update(particle: Particle, delta: IDelta): void;
|
|
26
11
|
}
|
|
27
|
-
export {};
|
package/types/Types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IParticleValueAnimation, IParticlesOptions, Particle, ParticlesOptions } from "@tsparticles/engine";
|
|
2
|
+
import type { ITilt } from "./Options/Interfaces/ITilt.js";
|
|
3
|
+
import type { Tilt } from "./Options/Classes/Tilt.js";
|
|
4
|
+
export interface IParticleTiltValueAnimation extends IParticleValueAnimation<number> {
|
|
5
|
+
cosDirection: number;
|
|
6
|
+
sinDirection: number;
|
|
7
|
+
}
|
|
8
|
+
export type TiltParticle = Particle & {
|
|
9
|
+
options: TiltParticlesOptions;
|
|
10
|
+
tilt?: IParticleTiltValueAnimation;
|
|
11
|
+
};
|
|
12
|
+
export type ITiltParticlesOptions = IParticlesOptions & {
|
|
13
|
+
tilt?: ITilt;
|
|
14
|
+
};
|
|
15
|
+
export type TiltParticlesOptions = ParticlesOptions & {
|
|
16
|
+
tilt?: Tilt;
|
|
17
|
+
};
|
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 loadTiltUpdater(engine: Engine): Promise<void>;
|
|
2
|
+
export declare function loadTiltUpdater(engine: Engine, refresh?: boolean): Promise<void>;
|
|
@@ -4,18 +4,18 @@
|
|
|
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", "@tsparticles/engine", "./TiltAnimation.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Tilt = void 0;
|
|
13
|
-
const TiltAnimation_1 = require("./TiltAnimation");
|
|
14
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const TiltAnimation_js_1 = require("./TiltAnimation.js");
|
|
15
15
|
class Tilt extends engine_1.ValueWithRandom {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
|
-
this.animation = new
|
|
18
|
+
this.animation = new TiltAnimation_js_1.TiltAnimation();
|
|
19
19
|
this.direction = "clockwise";
|
|
20
20
|
this.enable = false;
|
|
21
21
|
this.value = 0;
|
package/umd/TiltUpdater.js
CHANGED
|
@@ -4,56 +4,27 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Tilt"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Tilt.js", "./Utils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TiltUpdater = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = ((_a = particle.tilt.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor, max = 2 * Math.PI, decay = (_b = particle.tilt.decay) !== null && _b !== void 0 ? _b : 1;
|
|
21
|
-
if (!tiltAnimation.enable) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
switch (particle.tilt.status) {
|
|
25
|
-
case "increasing":
|
|
26
|
-
particle.tilt.value += speed;
|
|
27
|
-
if (particle.tilt.value > max) {
|
|
28
|
-
particle.tilt.value -= max;
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
case "decreasing":
|
|
32
|
-
default:
|
|
33
|
-
particle.tilt.value -= speed;
|
|
34
|
-
if (particle.tilt.value < 0) {
|
|
35
|
-
particle.tilt.value += max;
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
40
|
-
particle.tilt.velocity *= decay;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
14
|
+
const Tilt_js_1 = require("./Options/Classes/Tilt.js");
|
|
15
|
+
const Utils_js_1 = require("./Utils.js");
|
|
43
16
|
class TiltUpdater {
|
|
44
17
|
constructor(container) {
|
|
45
18
|
this.container = container;
|
|
46
19
|
}
|
|
47
20
|
getTransformValues(particle) {
|
|
48
|
-
|
|
49
|
-
const tilt = ((_a = particle.tilt) === null || _a === void 0 ? void 0 : _a.enable) && particle.tilt;
|
|
21
|
+
const tilt = particle.tilt?.enable && particle.tilt;
|
|
50
22
|
return {
|
|
51
23
|
b: tilt ? Math.cos(tilt.value) * tilt.cosDirection : undefined,
|
|
52
24
|
c: tilt ? Math.sin(tilt.value) * tilt.sinDirection : undefined,
|
|
53
25
|
};
|
|
54
26
|
}
|
|
55
27
|
init(particle) {
|
|
56
|
-
var _a;
|
|
57
28
|
const tiltOptions = particle.options.tilt;
|
|
58
29
|
if (!tiltOptions) {
|
|
59
30
|
return;
|
|
@@ -78,8 +49,8 @@
|
|
|
78
49
|
particle.tilt.status = "increasing";
|
|
79
50
|
break;
|
|
80
51
|
}
|
|
81
|
-
const tiltAnimation =
|
|
82
|
-
if (tiltAnimation
|
|
52
|
+
const tiltAnimation = particle.options.tilt?.animation;
|
|
53
|
+
if (tiltAnimation?.enable) {
|
|
83
54
|
particle.tilt.decay = 1 - (0, engine_1.getRangeValue)(tiltAnimation.decay);
|
|
84
55
|
particle.tilt.velocity = ((0, engine_1.getRangeValue)(tiltAnimation.speed) / 360) * this.container.retina.reduceFactor;
|
|
85
56
|
if (!tiltAnimation.sync) {
|
|
@@ -88,23 +59,22 @@
|
|
|
88
59
|
}
|
|
89
60
|
}
|
|
90
61
|
isEnabled(particle) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return !particle.destroyed && !particle.spawning && !!(tiltAnimation === null || tiltAnimation === void 0 ? void 0 : tiltAnimation.enable);
|
|
62
|
+
const tiltAnimation = particle.options.tilt?.animation;
|
|
63
|
+
return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;
|
|
94
64
|
}
|
|
95
65
|
loadOptions(options, ...sources) {
|
|
96
66
|
if (!options.tilt) {
|
|
97
|
-
options.tilt = new
|
|
67
|
+
options.tilt = new Tilt_js_1.Tilt();
|
|
98
68
|
}
|
|
99
69
|
for (const source of sources) {
|
|
100
|
-
options.tilt.load(source
|
|
70
|
+
options.tilt.load(source?.tilt);
|
|
101
71
|
}
|
|
102
72
|
}
|
|
103
73
|
update(particle, delta) {
|
|
104
74
|
if (!this.isEnabled(particle)) {
|
|
105
75
|
return;
|
|
106
76
|
}
|
|
107
|
-
updateTilt(particle, delta);
|
|
77
|
+
(0, Utils_js_1.updateTilt)(particle, delta);
|
|
108
78
|
}
|
|
109
79
|
}
|
|
110
80
|
exports.TiltUpdater = TiltUpdater;
|
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,41 @@
|
|
|
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.updateTilt = void 0;
|
|
13
|
+
function updateTilt(particle, delta) {
|
|
14
|
+
if (!particle.tilt || !particle.options.tilt) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = (particle.tilt.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = particle.tilt.decay ?? 1;
|
|
18
|
+
if (!tiltAnimation.enable) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
switch (particle.tilt.status) {
|
|
22
|
+
case "increasing":
|
|
23
|
+
particle.tilt.value += speed;
|
|
24
|
+
if (particle.tilt.value > max) {
|
|
25
|
+
particle.tilt.value -= max;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case "decreasing":
|
|
29
|
+
default:
|
|
30
|
+
particle.tilt.value -= speed;
|
|
31
|
+
if (particle.tilt.value < 0) {
|
|
32
|
+
particle.tilt.value += max;
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (particle.tilt.velocity && decay !== 1) {
|
|
37
|
+
particle.tilt.velocity *= decay;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.updateTilt = updateTilt;
|
|
41
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./TiltUpdater"], factory);
|
|
7
|
+
define(["require", "exports", "./TiltUpdater.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadTiltUpdater = void 0;
|
|
13
|
-
const
|
|
14
|
-
async function loadTiltUpdater(engine) {
|
|
15
|
-
await engine.addParticleUpdater("tilt", (container) => new
|
|
13
|
+
const TiltUpdater_js_1 = require("./TiltUpdater.js");
|
|
14
|
+
async function loadTiltUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("tilt", (container) => new TiltUpdater_js_1.TiltUpdater(container), refresh);
|
|
16
16
|
}
|
|
17
17
|
exports.loadTiltUpdater = loadTiltUpdater;
|
|
18
18
|
});
|