1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.FrameManager = void 0;
|
4 | class FrameManager {
|
5 | constructor(container) {
|
6 | this.container = container;
|
7 | }
|
8 | nextFrame(timestamp) {
|
9 | var _a;
|
10 | try {
|
11 | const container = this.container;
|
12 | if (container.lastFrameTime !== undefined &&
|
13 | timestamp < container.lastFrameTime + 1000 / container.fpsLimit) {
|
14 | container.draw(false);
|
15 | return;
|
16 | }
|
17 | (_a = container.lastFrameTime) !== null && _a !== void 0 ? _a : (container.lastFrameTime = timestamp);
|
18 | const deltaValue = timestamp - container.lastFrameTime;
|
19 | const delta = {
|
20 | value: deltaValue,
|
21 | factor: (60 * deltaValue) / 1000,
|
22 | };
|
23 | container.lifeTime += delta.value;
|
24 | container.lastFrameTime = timestamp;
|
25 | if (deltaValue > 1000) {
|
26 | container.draw(false);
|
27 | return;
|
28 | }
|
29 | container.particles.draw(delta);
|
30 | if (container.duration > 0 && container.lifeTime > container.duration) {
|
31 | container.destroy();
|
32 | return;
|
33 | }
|
34 | if (container.getAnimationStatus()) {
|
35 | container.draw(false);
|
36 | }
|
37 | }
|
38 | catch (e) {
|
39 | console.error("tsParticles error in animation loop", e);
|
40 | }
|
41 | }
|
42 | }
|
43 | exports.FrameManager = FrameManager;
|