@woosh/meep-engine 2.113.2 → 2.113.3

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.
@@ -48983,6 +48983,14 @@ function is_typed_array_equals(a, b) {
48983
48983
  return false;
48984
48984
  }
48985
48985
 
48986
+ const a_constructor = a.constructor;
48987
+ const b_constructor = b.constructor;
48988
+
48989
+ if (a_constructor !== b_constructor) {
48990
+ // incompatible constructors
48991
+ return false;
48992
+ }
48993
+
48986
48994
  if (a_length === 0) {
48987
48995
  // both arrays are empty
48988
48996
  return true;
@@ -48999,20 +49007,15 @@ function is_typed_array_equals(a, b) {
48999
49007
  return false;
49000
49008
  }
49001
49009
 
49002
- const a_constructor = a.constructor;
49003
- const b_constructor = b.constructor;
49004
-
49005
- if (a_constructor !== b_constructor) {
49006
- // incompatible constructors
49007
- return false;
49008
- }
49009
-
49010
49010
 
49011
49011
  const a_buffer = a.buffer;
49012
49012
  const b_buffer = b.buffer;
49013
49013
 
49014
49014
  // check if buffers are the same
49015
- if (a_buffer === b_buffer && a.byteOffset === b.byteOffset) {
49015
+ const a_offset = a.byteOffset;
49016
+ const b_offset = b.byteOffset;
49017
+
49018
+ if (a_buffer === b_buffer && a_offset === b_offset) {
49016
49019
  // using the same buffer and pointing to the same range within it
49017
49020
  return true;
49018
49021
  }
@@ -49022,14 +49025,28 @@ function is_typed_array_equals(a, b) {
49022
49025
 
49023
49026
  const bytes_per_element = a_constructor.BYTES_PER_ELEMENT;
49024
49027
 
49025
- if (bytes_per_element < 4 && byte_length % 4 === 0) {
49028
+ if (
49029
+ bytes_per_element < 4
49030
+ && byte_length % 4 === 0
49031
+ && a_offset % 4 === 0
49032
+ && b_offset % 4 === 0
49033
+ ) {
49034
+
49026
49035
  // 4 byte alignment, can use uint32
49027
- a_proxy = new Uint32Array(a_buffer, a.byteOffset, byte_length / 4);
49028
- b_proxy = new Uint32Array(b_buffer, b.byteOffset, byte_length / 4);
49029
- } else if (bytes_per_element < 2 && byte_length % 2 === 0) {
49036
+ a_proxy = new Uint32Array(a_buffer, a_offset, byte_length >>> 2);
49037
+ b_proxy = new Uint32Array(b_buffer, b_offset, byte_length >>> 2);
49038
+
49039
+ } else if (
49040
+ bytes_per_element < 2
49041
+ && byte_length % 2 === 0
49042
+ && a_offset % 2 === 0
49043
+ && b_offset % 2 === 0
49044
+ ) {
49045
+
49030
49046
  // 2 byte alignment, can use uint16
49031
- a_proxy = new Uint16Array(a_buffer, a.byteOffset, byte_length / 2);
49032
- b_proxy = new Uint16Array(b_buffer, b.byteOffset, byte_length / 2);
49047
+ a_proxy = new Uint16Array(a_buffer, a_offset, byte_length >>> 1);
49048
+ b_proxy = new Uint16Array(b_buffer, b_offset, byte_length >>> 1);
49049
+
49033
49050
  }
49034
49051
 
49035
49052
  return isArrayEqualStrict(a_proxy, b_proxy);
@@ -86081,6 +86098,8 @@ function get_pending_asset_priority_score(pending_asset) {
86081
86098
  }
86082
86099
 
86083
86100
 
86101
+ // TODO handle 429 HTTP error gracefully
86102
+
86084
86103
  /**
86085
86104
  * Handles loading/generating assets
86086
86105
  * @template CTX
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.113.2",
8
+ "version": "2.113.3",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"is_typed_array_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/is_typed_array_equals.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,UAAU,GAAC,WAAW,KACtB,UAAU,GAAC,WAAW,GACpB,OAAO,CAkEnB"}
1
+ {"version":3,"file":"is_typed_array_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/is_typed_array_equals.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,yCAJW,UAAU,GAAC,WAAW,KACtB,UAAU,GAAC,WAAW,GACpB,OAAO,CAmFnB"}
@@ -21,6 +21,14 @@ export function is_typed_array_equals(a, b) {
21
21
  return false;
22
22
  }
23
23
 
24
+ const a_constructor = a.constructor;
25
+ const b_constructor = b.constructor;
26
+
27
+ if (a_constructor !== b_constructor) {
28
+ // incompatible constructors
29
+ return false;
30
+ }
31
+
24
32
  if (a_length === 0) {
25
33
  // both arrays are empty
26
34
  return true;
@@ -37,20 +45,15 @@ export function is_typed_array_equals(a, b) {
37
45
  return false;
38
46
  }
39
47
 
40
- const a_constructor = a.constructor;
41
- const b_constructor = b.constructor;
42
-
43
- if (a_constructor !== b_constructor) {
44
- // incompatible constructors
45
- return false;
46
- }
47
-
48
48
 
49
49
  const a_buffer = a.buffer;
50
50
  const b_buffer = b.buffer;
51
51
 
52
52
  // check if buffers are the same
53
- if (a_buffer === b_buffer && a.byteOffset === b.byteOffset) {
53
+ const a_offset = a.byteOffset;
54
+ const b_offset = b.byteOffset;
55
+
56
+ if (a_buffer === b_buffer && a_offset === b_offset) {
54
57
  // using the same buffer and pointing to the same range within it
55
58
  return true;
56
59
  }
@@ -60,14 +63,28 @@ export function is_typed_array_equals(a, b) {
60
63
 
61
64
  const bytes_per_element = a_constructor.BYTES_PER_ELEMENT;
62
65
 
63
- if (bytes_per_element < 4 && byte_length % 4 === 0) {
66
+ if (
67
+ bytes_per_element < 4
68
+ && byte_length % 4 === 0
69
+ && a_offset % 4 === 0
70
+ && b_offset % 4 === 0
71
+ ) {
72
+
64
73
  // 4 byte alignment, can use uint32
65
- a_proxy = new Uint32Array(a_buffer, a.byteOffset, byte_length / 4);
66
- b_proxy = new Uint32Array(b_buffer, b.byteOffset, byte_length / 4);
67
- } else if (bytes_per_element < 2 && byte_length % 2 === 0) {
74
+ a_proxy = new Uint32Array(a_buffer, a_offset, byte_length >>> 2);
75
+ b_proxy = new Uint32Array(b_buffer, b_offset, byte_length >>> 2);
76
+
77
+ } else if (
78
+ bytes_per_element < 2
79
+ && byte_length % 2 === 0
80
+ && a_offset % 2 === 0
81
+ && b_offset % 2 === 0
82
+ ) {
83
+
68
84
  // 2 byte alignment, can use uint16
69
- a_proxy = new Uint16Array(a_buffer, a.byteOffset, byte_length / 2);
70
- b_proxy = new Uint16Array(b_buffer, b.byteOffset, byte_length / 2);
85
+ a_proxy = new Uint16Array(a_buffer, a_offset, byte_length >>> 1);
86
+ b_proxy = new Uint16Array(b_buffer, b_offset, byte_length >>> 1);
87
+
71
88
  }
72
89
 
73
90
  return isArrayEqualStrict(a_proxy, b_proxy);
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {Uint32Array} array
4
+ * @param {number} offset
5
+ * @param {number} length
6
+ * @param {number} [sample_limit]
7
+ * @returns {number}
8
+ */
9
+ export function sparse_typed_array_hash(array: Uint32Array, offset: number, length: number, sample_limit?: number): number;
10
+ //# sourceMappingURL=sparse_typed_array_hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparse_typed_array_hash.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/sparse_typed_array_hash.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,+CANW,WAAW,UACX,MAAM,UACN,MAAM,iBACN,MAAM,GACJ,MAAM,CAelB"}
@@ -0,0 +1,26 @@
1
+ import { min2 } from "../../../math/min2.js";
2
+ import { computeStridedArrayHash } from "../../../primitives/array/computeStridedArrayHash.js";
3
+ import { computeHashFloat } from "../../../primitives/numbers/computeHashFloat.js";
4
+
5
+ /**
6
+ *
7
+ * @param {Uint32Array} array
8
+ * @param {number} offset
9
+ * @param {number} length
10
+ * @param {number} [sample_limit]
11
+ * @returns {number}
12
+ */
13
+ export function sparse_typed_array_hash(array, offset, length, sample_limit = 31) {
14
+ // limit hash evaluation to first 1k of the data to random memory access and keep CPU cache usage more coherent
15
+ const hash_evaluation_length = min2(length, 1024);
16
+
17
+ // compute stride so that we don't have to iterate over the entire buffer, instead picking at most X(509) values to consider
18
+ const stride = Math.max(1, Math.ceil(hash_evaluation_length / sample_limit));
19
+
20
+ // TODO implement fast dedicated float and int paths
21
+
22
+ return computeStridedArrayHash(
23
+ array, 0, hash_evaluation_length, stride,
24
+ computeHashFloat
25
+ );
26
+ }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  *
3
- * @param {number[]|vec3} result
4
- * @param {number[]} vA
5
- * @param {number[]} vB
6
- * @param {number[]} vC
3
+ * @param {number[]|vec3|Float32Array|Float64Array} result
4
+ * @param {number[]|vec3|Float32Array|Float64Array} vA
5
+ * @param {number[]|vec3|Float32Array|Float64Array} vB
6
+ * @param {number[]|vec3|Float32Array|Float64Array} vC
7
7
  */
8
- export function compute_triangle_normal(result: number[] | vec3, vA: number[], vB: number[], vC: number[]): void;
8
+ export function compute_triangle_normal(result: number[] | vec3 | Float32Array | Float64Array, vA: number[] | vec3 | Float32Array | Float64Array, vB: number[] | vec3 | Float32Array | Float64Array, vC: number[] | vec3 | Float32Array | Float64Array): void;
9
9
  //# sourceMappingURL=compute_triangle_normal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute_triangle_normal.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/compute_triangle_normal.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,gDALW,MAAM,EAAE,OAAK,MACb,MAAM,EAAE,MACR,MAAM,EAAE,MACR,MAAM,EAAE,QAiBlB"}
1
+ {"version":3,"file":"compute_triangle_normal.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/compute_triangle_normal.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,gDALW,MAAM,EAAE,UAAM,YAAY,GAAC,YAAY,MACvC,MAAM,EAAE,UAAM,YAAY,GAAC,YAAY,MACvC,MAAM,EAAE,UAAM,YAAY,GAAC,YAAY,MACvC,MAAM,EAAE,UAAM,YAAY,GAAC,YAAY,QAiBjD"}
@@ -2,10 +2,10 @@ import { v3_compute_triangle_normal } from "./v3_compute_triangle_normal.js";
2
2
 
3
3
  /**
4
4
  *
5
- * @param {number[]|vec3} result
6
- * @param {number[]} vA
7
- * @param {number[]} vB
8
- * @param {number[]} vC
5
+ * @param {number[]|vec3|Float32Array|Float64Array} result
6
+ * @param {number[]|vec3|Float32Array|Float64Array} vA
7
+ * @param {number[]|vec3|Float32Array|Float64Array} vB
8
+ * @param {number[]|vec3|Float32Array|Float64Array} vC
9
9
  */
10
10
  export function compute_triangle_normal(result, vA, vB, vC) {
11
11
 
@@ -9,7 +9,7 @@ export function roundFair(number, random) {
9
9
  const mantissa = number % 1;
10
10
  const roll = random();
11
11
 
12
- if (roll < mantissa) {
12
+ if (roll > mantissa) {
13
13
  return Math.floor(number);
14
14
  } else {
15
15
  return Math.ceil(number);
@@ -1 +1 @@
1
- {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AA4CA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IA2QD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,kCAEJ,QAAQ,OAAO,CAAC,CAU5B;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BA72B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
1
+ {"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../../../src/engine/asset/AssetManager.js"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH;IAgII;;;;;OAKG;IACH,oCAJW,GAAG,EAYb;IA7ID;;;;OAIG;IACH,eAEG;IAEH;;;OAGG;IACH,aAFU,YAAY,gBAAgB,EAAE,YAAY,CAAC,CAER;IAe7C;;;;;;OAMG;IACH,kBAFU,MAAM,CAEY;IAyB5B;;;;OAIG;IACH,iBAAc;IAEd;;;OAGG;IACH,mBAFU,iBAAiB,CAEiB;IAwE5C,gBAQC;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACL,QAAQ,IAAI,CAAC,CAexB;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAOnB;IAED;;OAEG;IACH,cAEC;IAED,8BAEC;IAED;;;;;;OAMG;IACH,4DAJW,iBAAiB,GAEf,cAAc,CAY1B;IAED;;;;;;;;;OASG;IACH,qFAsCC;IAED;;;;;OAKG;IACH,aAJW,MAAM,QACN,MAAM,sBAehB;IA2QD;;;;;OAKG;IACH,sBA2BC;IAGD;;;;OAIG;IACH,uBAHW,MAAM,GACL,OAAO,CAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,GACJ,wBAAY,SAAS,CAMjC;IAaD;;;;OAIG;IACH,+BAHW,MAAM,4CAqBhB;IAED;;;;OAIG;IACH,iCAHW,MAAM,+CAyBhB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,kCAEJ,QAAQ,OAAO,CAAC,CAU5B;IAED;;;;;OAKG;IACH,0BAJW,MAAM,iEAwChB;IAED;;;OAGG;IACH,uBAFW,MAAM,iBAkBhB;IAED;;;;;;OAMG;IACH,yCAFa,aAAS,IAAI,CAYzB;IAED;;;;;OAKG;IACH,eAJW,MAAM,QACN,MAAM,GACJ,OAAO,CAMnB;IAED;;;;OAIG;IACH,2BAHW,MAAM,GACL,mBAAiB,CAa5B;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACL,gBAAgB,GAAC,SAAS,CAQrC;IAED;;;;;OAKG;IACH,mBAJW,MAAM,QACN,MAAM,QACN,MAAM,QAUhB;IAGL;;;OAGG;IACH,yBAFU,OAAO,CAEoB;;CANpC;4BA/2B2B,0CAA0C;iCAOrC,uBAAuB;6BAM3B,mBAAmB;kCAFd,6BAA6B;kCAD7B,wBAAwB;4BAE9B,0BAA0B"}
@@ -42,6 +42,8 @@ function get_pending_asset_priority_score(pending_asset) {
42
42
  }
43
43
 
44
44
 
45
+ // TODO handle 429 HTTP error gracefully
46
+
45
47
  /**
46
48
  * Handles loading/generating assets
47
49
  * @template CTX
@@ -1 +1 @@
1
- {"version":3,"file":"computeBufferAttributeHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,sDAHW,MAAM,eAAe,GACnB,MAAM,CAyBlB"}
1
+ {"version":3,"file":"computeBufferAttributeHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,sDAHW,MAAM,eAAe,GACnB,MAAM,CAgBlB"}
@@ -1,6 +1,4 @@
1
- import { min2 } from "../../../../core/math/min2.js";
2
- import { computeStridedArrayHash } from "../../../../core/primitives/array/computeStridedArrayHash.js";
3
- import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
1
+ import { sparse_typed_array_hash } from "../../../../core/collection/array/typed/sparse_typed_array_hash.js";
4
2
 
5
3
  /**
6
4
  *
@@ -16,16 +14,7 @@ export function computeBufferAttributeHash(attribute) {
16
14
 
17
15
  result += data_size;
18
16
 
19
- // limit hash evaluation to first 1k of the data to random memory access and keep CPU cache usage more coherent
20
- const hash_evaluation_length = min2(data_size, 1024);
21
-
22
- // compute stride so that we don't have to iterate over the entire buffer, instead picking at most X(509) values to consider
23
- const stride = Math.max(1, Math.ceil(hash_evaluation_length / 31));
24
-
25
- result ^= computeStridedArrayHash(
26
- data, 0, hash_evaluation_length, stride,
27
- computeHashFloat
28
- );
17
+ result ^= sparse_typed_array_hash(data, 0, data_size);
29
18
 
30
19
  }
31
20