@woosh/meep-engine 2.92.14 → 2.92.15

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.92.14",
8
+ "version": "2.92.15",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -8,12 +8,6 @@ export class BinaryElementPool {
8
8
  * @param {number} initial_capacity how many items to reverse in the newly created pool
9
9
  */
10
10
  constructor(item_size: number, initial_capacity?: number);
11
- /**
12
- * Size of a single pool item in bytes
13
- * @type {number}
14
- * @private
15
- */
16
- private __item_size;
17
11
  /**
18
12
  * Unused slots
19
13
  * @type {number[]}
@@ -27,18 +21,60 @@ export class BinaryElementPool {
27
21
  * @private
28
22
  */
29
23
  private __free_pointer;
30
- __data_buffer: ArrayBuffer;
31
- __data_uint8: Uint8Array;
32
- __data_uint32: Uint32Array;
33
- __data_float32: Float32Array;
34
- data_view: DataView;
35
- __capacity: number;
36
24
  /**
37
25
  *
38
26
  * @type {number}
39
27
  * @private
40
28
  */
41
29
  private __size;
30
+ /**
31
+ * Size of a single pool item in bytes
32
+ * @type {number}
33
+ * @private
34
+ */
35
+ private __item_size;
36
+ /**
37
+ *
38
+ * @type {ArrayBuffer}
39
+ * @private
40
+ */
41
+ private __data_buffer;
42
+ /**
43
+ *
44
+ * @type {Uint8Array}
45
+ * @private
46
+ */
47
+ private __data_uint8;
48
+ /**
49
+ *
50
+ * @type {Uint32Array}
51
+ * @private
52
+ */
53
+ private __data_uint32;
54
+ /**
55
+ *
56
+ * @type {Float32Array}
57
+ * @private
58
+ */
59
+ private __data_float32;
60
+ data_view: DataView;
61
+ /**
62
+ *
63
+ * @type {number}
64
+ * @private
65
+ */
66
+ private __capacity;
67
+ /**
68
+ *
69
+ * @param {ArrayBuffer} buffer
70
+ * @param {number} allocated_record_count
71
+ */
72
+ fromArrayBuffer(buffer: ArrayBuffer, allocated_record_count?: number): void;
73
+ /**
74
+ * Size of a single record in bytes
75
+ * @return {number}
76
+ */
77
+ get item_size(): number;
42
78
  /**
43
79
  * Returns size of used region, this includes both elements that are allocated and those that aren't
44
80
  * Please note that this value does not represent number of currently active elements, if you need that - you'll need to use something else
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryElementPool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/struct/binary/BinaryElementPool.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IAEI;;;;OAIG;IACH,uBAHW,MAAM,qBACN,MAAM,EA0ChB;IApCG;;;;OAIG;IACH,oBAA4B;IAE5B;;;;OAIG;IACH,eAAgB;IAEhB;;;;;OAKG;IACH,uBAAuB;IAEvB,2BAA2E;IAC3E,yBAAsD;IACtD,2BAAwD;IACxD,6BAA0D;IAC1D,oBAAiD;IAEjD,mBAAkC;IAElC;;;;OAIG;IACH,eAAe;IAGnB;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,iCAEC;IAED;;OAEG;IACH,aAEC;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,MAAM,CAMjB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACL,OAAO,CAsBlB;IAED;;;;OAIG;IACH,uBAsBC;IAED;;;;OAIG;IACH,wBAQC;IAED;;;OAGG;IACH,0BAFW,MAAM,QAMhB;IAGD;;;OAGG;IACH,YAFY,MAAM,CAqBjB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,MAAM,CAcjB;IAED;;;;OAIG;IACH,YAFW,MAAM,QAYhB;IAED;;OAEG;IACH,cAGC;CACJ"}
1
+ {"version":3,"file":"BinaryElementPool.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/geom/3d/topology/struct/binary/BinaryElementPool.js"],"names":[],"mappings":"AAwBA;;GAEG;AACH;IAwBI;;;;OAIG;IACH,uBAHW,MAAM,qBACN,MAAM,EAiDhB;IA1ED;;;;OAIG;IACH,eAAY;IAEZ;;;;;OAKG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAW;IAaP;;;;OAIG;IACH,oBAA4B;IAG5B;;;;OAIG;IACH,sBAA2E;IAC3E;;;;OAIG;IACH,qBAAsD;IACtD;;;;OAIG;IACH,sBAAwD;IACxD;;;;OAIG;IACH,uBAA0D;IAC1D,oBAAiD;IAEjD;;;;OAIG;IACH,mBAAkC;IAItC;;;;OAIG;IACH,wBAHW,WAAW,2BACX,MAAM,QAsBhB;IAED;;;OAGG;IACH,wBAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,iCAEC;IAED;;OAEG;IACH,aAEC;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,MAAM,CAMjB;IAED;;;;;OAKG;IACH,iBAHW,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACL,OAAO,CAsBlB;IAED;;;;OAIG;IACH,uBAsBC;IAED;;;;OAIG;IACH,wBAQC;IAED;;;OAGG;IACH,0BAFW,MAAM,QAMhB;IAGD;;;OAGG;IACH,YAFY,MAAM,CAqBjB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,MAAM,CAcjB;IAED;;;;OAIG;IACH,YAFW,MAAM,QAYhB;IAED;;OAEG;IACH,cAGC;CACJ"}
@@ -27,6 +27,28 @@ const CAPACITY_GROW_MIN_STEP = 32;
27
27
  */
28
28
  export class BinaryElementPool {
29
29
 
30
+ /**
31
+ * Unused slots
32
+ * @type {number[]}
33
+ * @private
34
+ */
35
+ __free = [];
36
+
37
+ /**
38
+ * Tracks last unallocated item in the list,
39
+ * this separate cursor is necessary to prevent re-allocation of the 'free' array
40
+ * @type {number}
41
+ * @private
42
+ */
43
+ __free_pointer = 0;
44
+
45
+ /**
46
+ *
47
+ * @type {number}
48
+ * @private
49
+ */
50
+ __size = 0;
51
+
30
52
  /**
31
53
  *
32
54
  * @param {number} item_size in bytes
@@ -36,6 +58,8 @@ export class BinaryElementPool {
36
58
  assert.isNonNegativeInteger(item_size, 'item_size');
37
59
  assert.greaterThan(item_size, 0, 'item_size must be greater than 0');
38
60
 
61
+ assert.isNonNegativeInteger(initial_capacity, 'initial_capacity');
62
+
39
63
  /**
40
64
  * Size of a single pool item in bytes
41
65
  * @type {number}
@@ -43,35 +67,75 @@ export class BinaryElementPool {
43
67
  */
44
68
  this.__item_size = item_size;
45
69
 
70
+
46
71
  /**
47
- * Unused slots
48
- * @type {number[]}
72
+ *
73
+ * @type {ArrayBuffer}
49
74
  * @private
50
75
  */
51
- this.__free = [];
52
-
76
+ this.__data_buffer = new ArrayBuffer(align_4(initial_capacity * item_size));
53
77
  /**
54
- * Tracks last unallocated item in the list,
55
- * this separate cursor is necessary to prevent re-allocation of the 'free' array
56
- * @type {number}
78
+ *
79
+ * @type {Uint8Array}
57
80
  * @private
58
81
  */
59
- this.__free_pointer = 0;
60
-
61
- this.__data_buffer = new ArrayBuffer(align_4(initial_capacity * item_size));
62
82
  this.__data_uint8 = new Uint8Array(this.__data_buffer);
83
+ /**
84
+ *
85
+ * @type {Uint32Array}
86
+ * @private
87
+ */
63
88
  this.__data_uint32 = new Uint32Array(this.__data_buffer);
89
+ /**
90
+ *
91
+ * @type {Float32Array}
92
+ * @private
93
+ */
64
94
  this.__data_float32 = new Float32Array(this.__data_buffer);
65
95
  this.data_view = new DataView(this.__data_buffer);
66
96
 
67
- this.__capacity = initial_capacity;
68
-
69
97
  /**
70
98
  *
71
99
  * @type {number}
72
100
  * @private
73
101
  */
74
- this.__size = 0;
102
+ this.__capacity = initial_capacity;
103
+
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param {ArrayBuffer} buffer
109
+ * @param {number} allocated_record_count
110
+ */
111
+ fromArrayBuffer(buffer, allocated_record_count = 0) {
112
+ assert.defined(buffer, 'buffer');
113
+ assert.notNull(buffer, 'buffer');
114
+
115
+ const capacity = Math.floor(buffer.byteLength / this.__item_size);
116
+
117
+ assert.isNonNegativeInteger(allocated_record_count, 'allocated_record_count');
118
+ assert.lessThanOrEqual(allocated_record_count, capacity, 'allocated_record_count is higher than capacity');
119
+
120
+ this.__data_buffer = buffer;
121
+ this.__data_uint8 = new Uint8Array(buffer);
122
+ this.__data_uint32 = new Uint32Array(buffer);
123
+ this.__data_float32 = new Float32Array(buffer);
124
+ this.data_view = new DataView(buffer);
125
+
126
+ this.__capacity = capacity;
127
+
128
+ // drop free slots
129
+ this.__free_pointer = 0;
130
+ this.__size = allocated_record_count;
131
+ }
132
+
133
+ /**
134
+ * Size of a single record in bytes
135
+ * @return {number}
136
+ */
137
+ get item_size() {
138
+ return this.__item_size;
75
139
  }
76
140
 
77
141
  /**