@woosh/meep-engine 2.110.1 → 2.110.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.
@@ -97938,15 +97938,21 @@ class ImmutableObjectPool {
97938
97938
  }
97939
97939
  }
97940
97940
 
97941
+ /**
97942
+ * @template T
97943
+ */
97941
97944
  class ObjectPoolFactory {
97942
97945
  /**
97943
- * @template T
97944
97946
  * @param {function():T} creator
97945
97947
  * @param {function(T)} destroyer
97946
97948
  * @param {function(T)} resetter
97947
- * @constructor
97948
97949
  */
97949
- constructor(creator, destroyer, resetter) {
97950
+ constructor(
97951
+ creator,
97952
+ destroyer = noop,
97953
+ resetter = noop
97954
+ ) {
97955
+
97950
97956
  /**
97951
97957
  * @private
97952
97958
  * @type {function(): T}
@@ -97970,7 +97976,6 @@ class ObjectPoolFactory {
97970
97976
  this.pool = [];
97971
97977
 
97972
97978
  /**
97973
- * @private
97974
97979
  * @type {number}
97975
97980
  */
97976
97981
  this.maxSize = 256;
@@ -97988,17 +97993,20 @@ class ObjectPoolFactory {
97988
97993
  this.resetter(oldInstance);
97989
97994
 
97990
97995
  return oldInstance;
97996
+
97991
97997
  } else {
97998
+
97992
97999
  const newInstance = this.creator();
97993
98000
 
97994
98001
  return newInstance;
98002
+
97995
98003
  }
97996
98004
  }
97997
98005
 
97998
98006
  /**
97999
98007
  *
98000
98008
  * @param {T} object
98001
- * @returns {boolean}
98009
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
98002
98010
  */
98003
98011
  release(object) {
98004
98012
 
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.110.1",
8
+ "version": "2.110.2",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,12 +1,13 @@
1
- export class ObjectPoolFactory {
1
+ /**
2
+ * @template T
3
+ */
4
+ export class ObjectPoolFactory<T> {
2
5
  /**
3
- * @template T
4
6
  * @param {function():T} creator
5
7
  * @param {function(T)} destroyer
6
8
  * @param {function(T)} resetter
7
- * @constructor
8
9
  */
9
- constructor(creator: () => T, destroyer: (arg0: T) => any, resetter: (arg0: T) => any);
10
+ constructor(creator: () => T, destroyer?: (arg0: T) => any, resetter?: (arg0: T) => any);
10
11
  /**
11
12
  * @private
12
13
  * @type {function(): T}
@@ -28,10 +29,9 @@ export class ObjectPoolFactory {
28
29
  */
29
30
  private pool;
30
31
  /**
31
- * @private
32
32
  * @type {number}
33
33
  */
34
- private maxSize;
34
+ maxSize: number;
35
35
  /**
36
36
  *
37
37
  * @returns {T}
@@ -40,7 +40,7 @@ export class ObjectPoolFactory {
40
40
  /**
41
41
  *
42
42
  * @param {T} object
43
- * @returns {boolean}
43
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
44
44
  */
45
45
  release(object: T): boolean;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectPoolFactory.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/ObjectPoolFactory.js"],"names":[],"mappings":"AAIA;IACI;;;;;;OAMG;IACH,uFA4BC;IA3BG;;;OAGG;IACH,gBAAsB;IACtB;;;OAGG;IACH,kBAA0B;IAC1B;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,aAAc;IAEd;;;OAGG;IACH,gBAAkB;IAGtB;;;OAGG;IACH,YAoBC;IAED;;;;OAIG;IACH,oBAFa,OAAO,CAqBnB;CACJ"}
1
+ {"version":3,"file":"ObjectPoolFactory.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/ObjectPoolFactory.js"],"names":[],"mappings":"AAIA;;GAEG;AACH;IACI;;;;OAIG;IACH,2BAJsB,CAAC,qBACH,CAAC,4BACD,CAAC,UAqCpB;IA1BG;;;OAGG;IACH,gBAAsB;IACtB;;;OAGG;IACH,kBAA0B;IAC1B;;;OAGG;IACH,iBAAwB;IAExB;;;OAGG;IACH,aAAc;IAEd;;OAEG;IACH,SAFU,MAAM,CAEE;IAGtB;;;OAGG;IACH,UAFa,CAAC,CAwBb;IAED;;;;OAIG;IACH,gBAHW,CAAC,GACC,OAAO,CAqBnB;CACJ"}
@@ -2,15 +2,24 @@ import { assert } from "../../assert.js";
2
2
 
3
3
  import { noop } from "../../function/noop.js";
4
4
 
5
+ /**
6
+ * @template T
7
+ */
5
8
  export class ObjectPoolFactory {
6
9
  /**
7
- * @template T
8
10
  * @param {function():T} creator
9
11
  * @param {function(T)} destroyer
10
12
  * @param {function(T)} resetter
11
- * @constructor
12
13
  */
13
- constructor(creator, destroyer, resetter) {
14
+ constructor(
15
+ creator,
16
+ destroyer = noop,
17
+ resetter = noop
18
+ ) {
19
+ assert.isFunction(creator, 'creator');
20
+ assert.isFunction(destroyer, 'destroyer');
21
+ assert.isFunction(resetter, 'resetter');
22
+
14
23
  /**
15
24
  * @private
16
25
  * @type {function(): T}
@@ -34,7 +43,6 @@ export class ObjectPoolFactory {
34
43
  this.pool = [];
35
44
 
36
45
  /**
37
- * @private
38
46
  * @type {number}
39
47
  */
40
48
  this.maxSize = 256;
@@ -55,21 +63,23 @@ export class ObjectPoolFactory {
55
63
  assert.defined(oldInstance, 'oldInstance');
56
64
 
57
65
  return oldInstance;
66
+
58
67
  } else {
59
- const newInstance = this.creator();
60
68
 
69
+ const newInstance = this.creator();
61
70
 
62
71
  assert.notNull(newInstance, 'newInstance');
63
72
  assert.defined(newInstance, 'newInstance');
64
73
 
65
74
  return newInstance;
75
+
66
76
  }
67
77
  }
68
78
 
69
79
  /**
70
80
  *
71
81
  * @param {T} object
72
- * @returns {boolean}
82
+ * @returns {boolean} true if object was added back to the pool, false if pool was full and object was destroyed instead
73
83
  */
74
84
  release(object) {
75
85
  assert.notNull(object, 'object');
@@ -16,6 +16,7 @@ export class IKProblem {
16
16
  terrain: Terrain;
17
17
  }
18
18
  export namespace IKProblem {
19
- let pool: any;
19
+ let pool: ObjectPoolFactory<IKProblem>;
20
20
  }
21
+ import { ObjectPoolFactory } from "../../../core/model/object/ObjectPoolFactory.js";
21
22
  //# sourceMappingURL=IKProblem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IKProblem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/IKProblem.js"],"names":[],"mappings":"AAGA;IAEI;;;OAGG;IACH,yBAAkB;IAClB;;;OAGG;IACH,mBAAgB;IAChB;;;OAGG;IACH,iBAAe;CAElB"}
1
+ {"version":3,"file":"IKProblem.d.ts","sourceRoot":"","sources":["../../../../../src/engine/ecs/ik/IKProblem.js"],"names":[],"mappings":"AAGA;IAEI;;;OAGG;IACH,yBAAkB;IAClB;;;OAGG;IACH,mBAAgB;IAChB;;;OAGG;IACH,iBAAe;CAElB;;cAIS,kBAAkB,SAAS,CAAC;;kCAxBJ,iDAAiD"}