@woosh/meep-engine 2.100.3 → 2.101.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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.100.3",
8
+ "version": "2.101.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,5 +1,6 @@
1
1
  /**
2
- *
2
+ * Fires a given function every frame. Typical usage is to create an instance, invoke {@link #startup} and once no longer required - invoke {@link #shutdown}
3
+ * Wraps {@link requestAnimationFrame}
3
4
  */
4
5
  export class FrameRunner {
5
6
  /**
@@ -13,22 +14,12 @@ export class FrameRunner {
13
14
  */
14
15
  action: Function;
15
16
  /**
16
- *
17
- * @type {boolean}
18
- */
19
- running: boolean;
20
- /**
21
- *
22
- * @type {number}
23
- */
24
- animationFrameId: number;
25
- /**
26
- *
17
+ * Begins animation loop. Does nothing and returns false if already running.
27
18
  * @returns {boolean}
28
19
  */
29
20
  startup(): boolean;
30
21
  /**
31
- *
22
+ * Stops animation loop. Does nothing and returns false if not currently running.
32
23
  * @returns {boolean}
33
24
  */
34
25
  shutdown(): boolean;
@@ -37,5 +28,6 @@ export class FrameRunner {
37
28
  * @returns {boolean}
38
29
  */
39
30
  isRunning(): boolean;
31
+ #private;
40
32
  }
41
33
  //# sourceMappingURL=FrameRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrameRunner.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/FrameRunner.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI;;;OAGG;IACH,8BAgBC;IAfG;;;OAGG;IACH,iBAAoB;IACpB;;;OAGG;IACH,SAFU,OAAO,CAEG;IACpB;;;OAGG;IACH,kBAFU,MAAM,CAEU;IAG9B;;;OAGG;IACH,WAFa,OAAO,CA2BnB;IAED;;;OAGG;IACH,YAFa,OAAO,CAiBnB;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;CACJ"}
1
+ {"version":3,"file":"FrameRunner.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/FrameRunner.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IAYI;;;OAGG;IACH,8BAMC;IALG;;;OAGG;IACH,iBAAoB;IAGxB;;;OAGG;IACH,WAFa,OAAO,CA2BnB;IAED;;;OAGG;IACH,YAFa,OAAO,CAiBnB;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;;CACJ"}
@@ -1,9 +1,25 @@
1
+ /**
2
+ *
3
+ * @type {number}
4
+ */
1
5
  let global_count = 0;
2
6
 
3
7
  /**
4
- *
8
+ * Fires a given function every frame. Typical usage is to create an instance, invoke {@link #startup} and once no longer required - invoke {@link #shutdown}
9
+ * Wraps {@link requestAnimationFrame}
5
10
  */
6
11
  export class FrameRunner {
12
+ /**
13
+ *
14
+ * @type {boolean}
15
+ */
16
+ #running = false;
17
+ /**
18
+ *
19
+ * @type {number}
20
+ */
21
+ #animationFrameId = -1;
22
+
7
23
  /**
8
24
  *
9
25
  * @param {function} action
@@ -14,66 +30,56 @@ export class FrameRunner {
14
30
  * @type {Function}
15
31
  */
16
32
  this.action = action;
17
- /**
18
- *
19
- * @type {boolean}
20
- */
21
- this.running = false;
22
- /**
23
- *
24
- * @type {number}
25
- */
26
- this.animationFrameId = -1;
27
33
  }
28
34
 
29
35
  /**
30
- *
36
+ * Begins animation loop. Does nothing and returns false if already running.
31
37
  * @returns {boolean}
32
38
  */
33
39
  startup() {
34
- if (this.running) {
40
+ if (this.#running) {
35
41
  return false;
36
42
  }
37
43
 
38
- console.warn(`FrameFunner.started[${global_count}]`);
44
+ // console.warn(`FrameFunner.started[${global_count}]`);
39
45
 
40
46
  global_count++;
41
47
 
42
- this.running = true;
48
+ this.#running = true;
43
49
 
44
50
  const cycle = () => {
45
- if (!this.running) {
51
+ if (!this.#running) {
46
52
  //not supposed to be running, bail
47
53
  return;
48
54
  }
49
55
 
50
56
  this.action();
51
57
 
52
- this.animationFrameId = requestAnimationFrame(cycle);
58
+ this.#animationFrameId = requestAnimationFrame(cycle);
53
59
  }
54
60
 
55
- this.animationFrameId = requestAnimationFrame(cycle);
61
+ this.#animationFrameId = requestAnimationFrame(cycle);
56
62
 
57
63
  return true;
58
64
  }
59
65
 
60
66
  /**
61
- *
67
+ * Stops animation loop. Does nothing and returns false if not currently running.
62
68
  * @returns {boolean}
63
69
  */
64
70
  shutdown() {
65
- if (!this.running) {
71
+ if (!this.#running) {
66
72
  return false;
67
73
  }
68
74
 
69
75
  global_count--;
70
76
 
71
- console.warn(`FrameFunner.stopped[${global_count}]`);
77
+ // console.warn(`FrameFunner.stopped[${global_count}]`);
72
78
 
73
- this.running = false;
74
- cancelAnimationFrame(this.animationFrameId);
79
+ this.#running = false;
80
+ cancelAnimationFrame(this.#animationFrameId);
75
81
 
76
- this.animationFrameId = -1;
82
+ this.#animationFrameId = -1;
77
83
 
78
84
  return true;
79
85
  }
@@ -83,6 +89,6 @@ export class FrameRunner {
83
89
  * @returns {boolean}
84
90
  */
85
91
  isRunning() {
86
- return this.running;
92
+ return this.#running;
87
93
  }
88
94
  }