@woosh/meep-engine 2.92.18 → 2.92.20

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.18",
8
+ "version": "2.92.20",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"DataViewStructAccessor.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataViewStructAccessor.js"],"names":[],"mappings":"AAOA;IAiBI;;;;OAIG;IACH,yCAFW,OAAO,EAiCjB;IApDD;;OAEG;IACH,OAFU,QAAQ,CAEZ;IAEN;;OAEG;IACH,SAFU,MAAM,CAEJ;IAEZ;;;OAGG;IACH,4BAFU,MAAM,CAEM;IAwCtB;;;OAGG;IACH,qCAEC;IAED;;;;OAIG;IACH,gBAHW,QAAQ,eACR,MAAM,QAKhB;IAED;;;;OAIG;IACH,yBAHW,QAAQ,SACR,MAAM,QAKhB;CACJ"}
1
+ {"version":3,"file":"DataViewStructAccessor.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/DataViewStructAccessor.js"],"names":[],"mappings":"AAGA;IAiBI;;;;OAIG;IACH,yCAFW,OAAO,EAYjB;IA/BD;;OAEG;IACH,OAFU,QAAQ,CAEZ;IAEN;;OAEG;IACH,SAFU,MAAM,CAEJ;IAEZ;;;OAGG;IACH,4BAFU,MAAM,CAEM;IAmBtB;;;OAGG;IACH,qCAEC;IAED;;;;OAIG;IACH,gBAHW,QAAQ,eACR,MAAM,QAKhB;IAED;;;;OAIG;IACH,yBAHW,QAAQ,SACR,MAAM,QAKhB;CACJ"}
@@ -1,9 +1,5 @@
1
- import { assert } from "../../assert.js";
2
- import { FunctionCompiler } from "../../function/FunctionCompiler.js";
3
1
  import { BinaryDataType } from "../type/BinaryDataType.js";
4
- import { DataTypeByteSizes } from "../type/DataTypeByteSizes.js";
5
- import { DataType2DataViewReaders } from "./DataType2DataViewReaders.js";
6
- import { DataType2DataViewWriters } from "./DataType2DataViewWriters.js";
2
+ import { buildAccessor } from "./buildAccessor.js";
7
3
 
8
4
  export class DataViewStructAccessor {
9
5
  /**
@@ -28,36 +24,15 @@ export class DataViewStructAccessor {
28
24
  * @param {boolean} [little_endian]
29
25
  */
30
26
  constructor(schema, little_endian = false) {
31
- assert.defined(schema, 'schema');
32
- assert.isBoolean(little_endian, 'little_endian');
33
27
 
34
- const props = Object.keys(schema);
35
- const property_count = props.length;
28
+ this.$record_byte_size = buildAccessor({
29
+ schema,
30
+ target: this,
31
+ data_variable_name: "this.$data",
32
+ offset_variable_name: "this.$offset",
33
+ little_endian
34
+ });
36
35
 
37
- let offset = 0;
38
- for (let i = 0; i < property_count; i++) {
39
- const property = props[i];
40
- const type = schema[property];
41
-
42
- assert.enum(type, BinaryDataType, "type");
43
-
44
- assert.arrayHasNo(["bind", "$data", "$offset", "this", "constructor", "get", "set"], property, `Illegal property name ${property}`);
45
-
46
- //
47
- Object.defineProperty(this, property, {
48
- get: FunctionCompiler.INSTANCE.compile({
49
- code: `return this.$data.${DataType2DataViewReaders[type]}(this.$offset + ${offset}, ${little_endian})`
50
- }),
51
- set: FunctionCompiler.INSTANCE.compile({
52
- args: ["value"],
53
- code: `this.$data.${DataType2DataViewWriters[type]}(this.$offset + ${offset}, value, ${little_endian})`
54
- })
55
- })
56
-
57
- offset += DataTypeByteSizes[type];
58
- }
59
-
60
- this.$record_byte_size = offset;
61
36
  }
62
37
 
63
38
  /**
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {Object<BinaryDataType>} schema
4
+ * @param {Object} target
5
+ * @param {string} [data_variable_name]
6
+ * @param {string} [offset_variable_name]
7
+ * @param {boolean} [little_endian]
8
+ * @return {number}
9
+ */
10
+ export function buildAccessor({ schema, target, data_variable_name, offset_variable_name, little_endian }: any): number;
11
+ //# sourceMappingURL=buildAccessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAccessor.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/data_view/buildAccessor.js"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,iHAFY,MAAM,CA8CjB"}
@@ -0,0 +1,61 @@
1
+ import { assert } from "../../assert.js";
2
+ import { FunctionCompiler } from "../../function/FunctionCompiler.js";
3
+ import { BinaryDataType } from "../type/BinaryDataType.js";
4
+ import { DataTypeByteSizes } from "../type/DataTypeByteSizes.js";
5
+ import { DataType2DataViewReaders } from "./DataType2DataViewReaders.js";
6
+ import { DataType2DataViewWriters } from "./DataType2DataViewWriters.js";
7
+
8
+ /**
9
+ *
10
+ * @param {Object<BinaryDataType>} schema
11
+ * @param {Object} target
12
+ * @param {string} [data_variable_name]
13
+ * @param {string} [offset_variable_name]
14
+ * @param {boolean} [little_endian]
15
+ * @return {number}
16
+ */
17
+ export function buildAccessor({
18
+ schema,
19
+ target,
20
+ data_variable_name = "this.$data",
21
+ offset_variable_name = "this.$offset",
22
+ little_endian = false
23
+ }) {
24
+
25
+ assert.defined(schema, 'schema');
26
+ assert.isBoolean(little_endian, 'little_endian');
27
+
28
+ assert.isString(data_variable_name, 'data_variable_name')
29
+ assert.isString(offset_variable_name, 'offset_variable_name')
30
+
31
+ assert.defined(target, 'target');
32
+ assert.notNull(target, 'target');
33
+
34
+ const props = Object.keys(schema);
35
+ const property_count = props.length;
36
+
37
+ let offset = 0;
38
+ for (let i = 0; i < property_count; i++) {
39
+ const property = props[i];
40
+ const type = schema[property];
41
+
42
+ assert.enum(type, BinaryDataType, "type");
43
+
44
+ assert.arrayHasNo(["bind", "$data", "$offset", "this", "constructor", "get", "set"], property, `Illegal property name ${property}`);
45
+
46
+ //
47
+ Object.defineProperty(target, property, {
48
+ get: FunctionCompiler.INSTANCE.compile({
49
+ code: `return ${data_variable_name}.${DataType2DataViewReaders[type]}(${offset_variable_name} + ${offset}, ${little_endian})`
50
+ }),
51
+ set: FunctionCompiler.INSTANCE.compile({
52
+ args: ["value"],
53
+ code: `${data_variable_name}.${DataType2DataViewWriters[type]}(${offset_variable_name} + ${offset}, value, ${little_endian})`
54
+ })
55
+ })
56
+
57
+ offset += DataTypeByteSizes[type];
58
+ }
59
+
60
+ return offset;
61
+ }
@@ -5,9 +5,10 @@ export class BinaryElementPool {
5
5
  /**
6
6
  *
7
7
  * @param {number} item_size in bytes
8
- * @param {number} initial_capacity how many items to reverse in the newly created pool
8
+ * @param {number} [initial_capacity] how many items to reverse in the newly created pool
9
+ * @param {boolean} [use_shared_buffer]
9
10
  */
10
- constructor(item_size: number, initial_capacity?: number);
11
+ constructor(item_size: number, initial_capacity?: number, use_shared_buffer?: boolean);
11
12
  /**
12
13
  * Unused slots
13
14
  * @type {number[]}
@@ -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;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,+BAEC;IAED;;;OAGG;IACH,wBAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,uBAEC;IAGD;;;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":"AAyBA;;GAEG;AACH;IAwBI;;;;;OAKG;IACH,uBAJW,MAAM,qBACN,MAAM,sBACN,OAAO,EAkDjB;IA5ED;;;;OAIG;IACH,eAAY;IAEZ;;;;;OAKG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAW;IAeP;;;;OAIG;IACH,oBAA4B;IAG5B;;;;OAIG;IACH,sBAA8F;IAC9F;;;;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,+BAEC;IAED;;;OAGG;IACH,wBAEC;IAED;;;;OAIG;IACH,mBAEC;IAED;;;OAGG;IACH,uBAEC;IAED;;;OAGG;IACH,uBAEC;IAGD;;;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,uBAwBC;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,5 +1,6 @@
1
1
  import { assert } from "../../../../../assert.js";
2
2
  import { align_4 } from "../../../../../binary/align_4.js";
3
+ import { makeArrayBuffer } from "../../../../../binary/makeArrayBuffer.js";
3
4
  import { typed_array_copy } from "../../../../../collection/array/typed/typed_array_copy.js";
4
5
  import { max3 } from "../../../../../math/max3.js";
5
6
 
@@ -52,13 +53,15 @@ export class BinaryElementPool {
52
53
  /**
53
54
  *
54
55
  * @param {number} item_size in bytes
55
- * @param {number} initial_capacity how many items to reverse in the newly created pool
56
+ * @param {number} [initial_capacity] how many items to reverse in the newly created pool
57
+ * @param {boolean} [use_shared_buffer]
56
58
  */
57
- constructor(item_size, initial_capacity = INITIAL_CAPACITY) {
59
+ constructor(item_size, initial_capacity = INITIAL_CAPACITY, use_shared_buffer = false) {
58
60
  assert.isNonNegativeInteger(item_size, 'item_size');
59
61
  assert.greaterThan(item_size, 0, 'item_size must be greater than 0');
60
62
 
61
63
  assert.isNonNegativeInteger(initial_capacity, 'initial_capacity');
64
+ assert.isBoolean(use_shared_buffer, 'use_shared_buffer');
62
65
 
63
66
  /**
64
67
  * Size of a single pool item in bytes
@@ -73,7 +76,7 @@ export class BinaryElementPool {
73
76
  * @type {ArrayBuffer}
74
77
  * @private
75
78
  */
76
- this.__data_buffer = new ArrayBuffer(align_4(initial_capacity * item_size));
79
+ this.__data_buffer = makeArrayBuffer(align_4(initial_capacity * item_size), use_shared_buffer);
77
80
  /**
78
81
  *
79
82
  * @type {Uint8Array}
@@ -254,7 +257,9 @@ export class BinaryElementPool {
254
257
 
255
258
  const aligned_byte_size = align_4(new_capacity * this.__item_size);
256
259
 
257
- const new_data_buffer = new ArrayBuffer(aligned_byte_size);
260
+ const ArrayBufferType = this.__data_buffer.constructor;
261
+
262
+ const new_data_buffer = new ArrayBufferType(aligned_byte_size);
258
263
 
259
264
  this.__data_buffer = new_data_buffer;
260
265
  this.__data_uint8 = new Uint8Array(new_data_buffer);