@woosh/meep-engine 2.90.0 → 2.91.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.
Files changed (57) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +20 -9
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +20 -9
  5. package/package.json +1 -1
  6. package/src/core/binary/de_interleave_2_bits.spec.d.ts.map +1 -0
  7. package/src/core/binary/de_interleave_bits_by_2.d.ts.map +1 -0
  8. package/src/core/binary/reinterpret_float32_as_int32.d.ts.map +1 -0
  9. package/src/core/binary/split_by_2.d.ts.map +1 -0
  10. package/src/core/binary/split_by_3.d.ts.map +1 -0
  11. package/src/core/bvh2/binary/2/BinaryUint32BVH.d.ts.map +1 -1
  12. package/src/core/bvh2/binary/2/BinaryUint32BVH.js +3 -4
  13. package/src/core/bvh2/bvh3/BVH.js +1 -1
  14. package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
  15. package/src/core/geom/2d/aabb/AABB2.js +2 -4
  16. package/src/core/geom/2d/aabb/aabb2_array_combine.d.ts +11 -0
  17. package/src/core/geom/2d/aabb/aabb2_array_combine.d.ts.map +1 -0
  18. package/src/core/geom/2d/aabb/aabb2_array_combine.js +35 -0
  19. package/src/core/geom/2d/aabb/aabb2_array_set.d.ts +11 -0
  20. package/src/core/geom/2d/aabb/aabb2_array_set.d.ts.map +1 -0
  21. package/src/core/geom/2d/aabb/aabb2_array_set.js +21 -0
  22. package/src/core/geom/2d/aabb/aabb2_compute_area.d.ts +10 -0
  23. package/src/core/geom/2d/aabb/aabb2_compute_area.d.ts.map +1 -0
  24. package/src/core/geom/2d/aabb/aabb2_compute_area.js +14 -0
  25. package/src/core/geom/2d/bvh/BVH2D.d.ts +289 -0
  26. package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -0
  27. package/src/core/geom/2d/bvh/BVH2D.js +1143 -0
  28. package/src/core/geom/2d/bvh/BVH2D.spec.d.ts +2 -0
  29. package/src/core/geom/2d/bvh/BVH2D.spec.d.ts.map +1 -0
  30. package/src/core/geom/2d/bvh/BVH2D.spec.js +358 -0
  31. package/src/core/geom/2d/lt-grid/LooseTightGrid.js +2 -2
  32. package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
  33. package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts +79 -0
  34. package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -0
  35. package/src/core/geom/2d/r-tree/StaticR2Tree.js +384 -0
  36. package/src/core/geom/2d/r-tree/StaticR2Tree.spec.d.ts +2 -0
  37. package/src/core/geom/2d/r-tree/StaticR2Tree.spec.d.ts.map +1 -0
  38. package/src/core/geom/2d/r-tree/StaticR2Tree.spec.js +62 -0
  39. package/src/core/geom/3d/morton/mortonEncode_magicbits.js +1 -1
  40. package/src/core/geom/3d/topology/struct/binary/io/OrderedEdge.js +1 -1
  41. package/src/engine/graphics/texture/virtual/tile/compose_tile_address.js +1 -1
  42. package/src/engine/graphics/texture/virtual/tile/tile_address_to_finger_print.js +1 -1
  43. package/src/core/geom/3d/morton/de_interleave_2_bits.spec.d.ts.map +0 -1
  44. package/src/core/geom/3d/morton/de_interleave_bits_by_2.d.ts.map +0 -1
  45. package/src/core/geom/3d/morton/reinterpret_float32_as_int32.d.ts.map +0 -1
  46. package/src/core/geom/3d/morton/split_by_2.d.ts.map +0 -1
  47. package/src/core/geom/3d/morton/split_by_3.d.ts.map +0 -1
  48. /package/src/core/{geom/3d/morton → binary}/de_interleave_2_bits.spec.d.ts +0 -0
  49. /package/src/core/{geom/3d/morton → binary}/de_interleave_2_bits.spec.js +0 -0
  50. /package/src/core/{geom/3d/morton → binary}/de_interleave_bits_by_2.d.ts +0 -0
  51. /package/src/core/{geom/3d/morton → binary}/de_interleave_bits_by_2.js +0 -0
  52. /package/src/core/{geom/3d/morton → binary}/reinterpret_float32_as_int32.d.ts +0 -0
  53. /package/src/core/{geom/3d/morton → binary}/reinterpret_float32_as_int32.js +0 -0
  54. /package/src/core/{geom/3d/morton → binary}/split_by_2.d.ts +0 -0
  55. /package/src/core/{geom/3d/morton → binary}/split_by_2.js +0 -0
  56. /package/src/core/{geom/3d/morton → binary}/split_by_3.d.ts +0 -0
  57. /package/src/core/{geom/3d/morton → binary}/split_by_3.js +0 -0
@@ -52052,7 +52052,7 @@ const COLUMN_USER_DATA = COLUMN_CHILD_2;
52052
52052
  *
52053
52053
  * @type {number}
52054
52054
  */
52055
- const NULL_NODE = 4294967295;
52055
+ const NULL_NODE = UINT32_MAX;
52056
52056
 
52057
52057
  /**
52058
52058
  * @readonly
@@ -55534,7 +55534,7 @@ class BinaryUint32BVH {
55534
55534
 
55535
55535
  // build bottom-most level, just above the leaves
55536
55536
  for (i = 0; i < level_node_count; i++) {
55537
- const leaf_index_0 = i * 2;
55537
+ const leaf_index_0 = i << 1;
55538
55538
  const leaf_index_1 = leaf_index_0 + 1;
55539
55539
 
55540
55540
  const leaf_offset_0 = leaf_node_block_address + leaf_index_0 * BVH_LEAF_NODE_SIZE;
@@ -55562,18 +55562,17 @@ class BinaryUint32BVH {
55562
55562
 
55563
55563
  //build intermediate nodes
55564
55564
  for (; level >= 0; level--) {
55565
- level_node_count = Math.pow(2, level);
55565
+ level_node_count = 1 << level;
55566
55566
  parentIndex = (level_node_count - 1);
55567
55567
 
55568
55568
  for (i = 0; i < level_node_count; i++) {
55569
55569
 
55570
55570
  const childIndex0 = (parentIndex << 1) + 1;
55571
- const childIndex1 = childIndex0 + 1;
55572
55571
 
55573
55572
  const address_parent = parentIndex * BVH_BINARY_NODE_SIZE;
55574
55573
 
55575
55574
  const address_child_0 = childIndex0 * BVH_BINARY_NODE_SIZE;
55576
- const address_child_1 = childIndex1 * BVH_BINARY_NODE_SIZE;
55575
+ const address_child_1 = address_child_0 + BVH_BINARY_NODE_SIZE;
55577
55576
 
55578
55577
  aabb3_array_combine(
55579
55578
  float32, address_parent,
@@ -79317,6 +79316,21 @@ function line_segment_compute_line_segment_intersection_2d(
79317
79316
  return collision;
79318
79317
  }
79319
79318
 
79319
+ /**
79320
+ *
79321
+ * @param {number} x0
79322
+ * @param {number} y0
79323
+ * @param {number} x1
79324
+ * @param {number} y1
79325
+ * @return {number}
79326
+ */
79327
+ function aabb2_compute_area(x0, y0, x1, y1) {
79328
+ const dx = x1 - x0;
79329
+ const dy = y1 - y0;
79330
+
79331
+ return dx * dy;
79332
+ }
79333
+
79320
79334
  /**
79321
79335
  *
79322
79336
  * @param {number} ax0
@@ -79655,10 +79669,7 @@ class AABB2 {
79655
79669
  const x1 = this.x1;
79656
79670
  const y1 = this.y1;
79657
79671
 
79658
- const dx = x1 - x0;
79659
- const dy = y1 - y0;
79660
-
79661
- return dx * dy;
79672
+ return aabb2_compute_area(x0, y0, x1, y1);
79662
79673
  }
79663
79674
 
79664
79675
  /**
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.90.0",
8
+ "version": "2.91.0",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de_interleave_2_bits.spec.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/de_interleave_2_bits.spec.js"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de_interleave_bits_by_2.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/de_interleave_bits_by_2.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACJ,MAAM,CAWlB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reinterpret_float32_as_int32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/reinterpret_float32_as_int32.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,oDAHW,MAAM,GACJ,MAAM,CAKlB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split_by_2.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/split_by_2.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAHW,MAAM,GACJ,MAAM,CAUlB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split_by_3.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/split_by_3.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAHW,MAAM,GACJ,MAAM,CASlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAchB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAuEC;CACJ"}
1
+ {"version":3,"file":"BinaryUint32BVH.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/binary/2/BinaryUint32BVH.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH,gCAFU,MAAM,CAEmB;AAEnC;;;;GAIG;AACH,mCAFU,MAAM,CAEsB;AACtC;;;GAGG;AACH,iCAFU,MAAM,CAEoB;AAiDpC;IACI;;;;OAIG;IACH,sBAAc;IAEd;;;;OAIG;IACH,gCAAe;IAEf;;;;OAIG;IACH,+BAAc;IAEd;;;;OAIG;IACH,4BAAwB;IAExB;;;;OAIG;IACH,0BAAsB;IA0CtB;;;OAGG;IACH,2BAOC;IAED,wBAEC;IAnDD;;;OAGG;IACH,oBAFa,MAAM,CAIlB;IAED,2BAEC;IAED,gCAEC;IAED,8BAEC;IAED;;;OAGG;IACH,uBAFa,MAAM,CAIlB;IAED,4BAEC;IAED,0BAEC;IAmBD;;;;OAIG;IACH,2BAHW,MAAM,GACJ,MAAM,CAalB;IAED,6BASC;IAED;;;OAGG;IACH,oBAFW,MAAM,QAchB;IAED;;;;;;;;;;OAUG;IACH,mBATW,MAAM,WACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,oBAJW,MAAM,eACN,MAAM,EAAE,GAAC,YAAY,sBACrB,MAAM,QAIhB;IAED;;;;OAIG;IACH,4BAHW,MAAM,GACJ,MAAM,CAQlB;IAED,qCAoBC;IAED;;;;;;;OAOG;IACH,yCAYC;IAED;;;;;;OAMG;IACH,kDAuBC;IAED,wBAUC;IAGD;;;OAGG;IACH,oBAFW,MAAM,EAAE,QAkElB;IAED;;;;;OAKG;IACH,sBAUC;IAED;;OAEG;IACH,cAsEC;CACJ"}
@@ -476,7 +476,7 @@ export class BinaryUint32BVH {
476
476
 
477
477
  // build bottom-most level, just above the leaves
478
478
  for (i = 0; i < level_node_count; i++) {
479
- const leaf_index_0 = i * 2;
479
+ const leaf_index_0 = i << 1;
480
480
  const leaf_index_1 = leaf_index_0 + 1;
481
481
 
482
482
  const leaf_offset_0 = leaf_node_block_address + leaf_index_0 * BVH_LEAF_NODE_SIZE;
@@ -504,18 +504,17 @@ export class BinaryUint32BVH {
504
504
 
505
505
  //build intermediate nodes
506
506
  for (; level >= 0; level--) {
507
- level_node_count = Math.pow(2, level);
507
+ level_node_count = 1 << level;
508
508
  parentIndex = (level_node_count - 1);
509
509
 
510
510
  for (i = 0; i < level_node_count; i++) {
511
511
 
512
512
  const childIndex0 = (parentIndex << 1) + 1;
513
- const childIndex1 = childIndex0 + 1;
514
513
 
515
514
  const address_parent = parentIndex * BVH_BINARY_NODE_SIZE;
516
515
 
517
516
  const address_child_0 = childIndex0 * BVH_BINARY_NODE_SIZE;
518
- const address_child_1 = childIndex1 * BVH_BINARY_NODE_SIZE;
517
+ const address_child_1 = address_child_0 + BVH_BINARY_NODE_SIZE;
519
518
 
520
519
  aabb3_array_combine(
521
520
  float32, address_parent,
@@ -23,7 +23,7 @@ const COLUMN_USER_DATA = COLUMN_CHILD_2;
23
23
  *
24
24
  * @type {number}
25
25
  */
26
- export const NULL_NODE = 4294967295;
26
+ export const NULL_NODE = UINT32_MAX;
27
27
 
28
28
  /**
29
29
  * @readonly
@@ -1 +1 @@
1
- {"version":3,"file":"AABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/AABB2.js"],"names":[],"mappings":";AAiBA;;;GAGG;AACH;IACI;;;;;;OAMG;IACH,gEA+BC;IApBG;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IAGhB;;;OAG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B;IAED;;;;;;OAMG;IACH,UALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAQhB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;IAED;;OAEG;IACH,oCAEC;IAED,mBAEC;IAED;;;;;MAOC;IAED,0BAEC;CACJ;;;qBAqCS,KAAK;qBAML,KAAK;;oBAljBK,kBAAkB;AA0gBtC;;;;;;;GAOG;AACH,gDANW,KAAK,MACL,KAAK,MACL,OAAO,MACP,OAAO,GACL,OAAO,CAsBnB"}
1
+ {"version":3,"file":"AABB2.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/AABB2.js"],"names":[],"mappings":";AAkBA;;;GAGG;AACH;IACI;;;;;;OAMG;IACH,gEA+BC;IApBG;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IACZ;;;OAGG;IACH,WAAY;IAGhB;;;OAGG;IACH,WAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,aAFW,MAAM,QAIhB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QA8BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QAShB;IAED;;;;;OAKG;IACH,sBAJW,KAAK,UACL,KAAK,GACH,OAAO,CAcnB;IAED;;;;OAIG;IACH,qBAHW,KAAK,GACH,OAAO,CAcnB;IAED;;;;;;;OAOG;IACH,0EAMC;IAED;;;;OAIG;IACH,qBAHW,MAAM,KACN,MAAM,QAKhB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,0BALW,OAAO,MACP,OAAO,UACP,OAAO,GACL,OAAO,CA0BnB;IAED;;;;OAIG;IACH,kCAHW,OAAO,UACP,OAAO,QAmBjB;IAED;;;;OAIG;IACH,wBAHW,KAAK,GACH,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,sBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CA4BlB;IAED;;;OAGG;IACH,eAFa,MAAM,CASlB;IAED;;;OAGG;IACH,sBAFY,MAAM,CAYjB;IAED;;;;;OAKG;IACH,iBAJW,MAAM,KACN,MAAM,GACJ,OAAO,CAInB;IAED;;;OAGG;IACH,mBAFW,KAAK,QAIf;IAED;;;OAGG;IACH,kBAFW,OAAO,QAOjB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,aAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,0DAiBC;IAED;;;;OAIG;IACH,eAHW,MAAM,KACN,MAAM,QAOhB;IAED;;;;OAIG;IACH,aAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;OAGG;IACH,SAFa,KAAK,CAIjB;IAED;;;;OAIG;IACH,YAHW,KAAK,GACH,KAAK,CAIjB;IAED;;;;OAIG;IACH,cAHW,KAAK,GACH,OAAO,CAOnB;IAED;;;;;;OAMG;IACH,UALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAQhB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAsBhB;IAED;;OAEG;IACH,oCAEC;IAED,mBAEC;IAED;;;;;MAOC;IAED,0BAEC;CACJ;;;qBAqCS,KAAK;qBAML,KAAK;;oBAhjBK,kBAAkB;AAwgBtC;;;;;;;GAOG;AACH,gDANW,KAAK,MACL,KAAK,MACL,OAAO,MACP,OAAO,GACL,OAAO,CAsBnB"}
@@ -12,6 +12,7 @@ import Vector2 from "../../Vector2.js";
12
12
  import {
13
13
  line_segment_compute_line_segment_intersection_2d
14
14
  } from "../line/line_segment_compute_line_segment_intersection_2d.js";
15
+ import { aabb2_compute_area } from "./aabb2_compute_area.js";
15
16
  import { aabb2_compute_overlap } from "./aabb2_compute_overlap.js";
16
17
  import { aabb2_overlap_exists } from "./aabb2_overlap_exists.js";
17
18
 
@@ -316,10 +317,7 @@ class AABB2 {
316
317
  const x1 = this.x1;
317
318
  const y1 = this.y1;
318
319
 
319
- const dx = x1 - x0;
320
- const dy = y1 - y0;
321
-
322
- return dx * dy;
320
+ return aabb2_compute_area(x0, y0, x1, y1);
323
321
  }
324
322
 
325
323
  /**
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
3
+ * @param {ArrayLike<number>|number[]|Float32Array} result where resulting value is written to
4
+ * @param {number} result_offset
5
+ * @param {ArrayLike<number>|number[]|Float32Array} a
6
+ * @param {number} a_offset
7
+ * @param {ArrayLike<number>|number[]|Float32Array} b
8
+ * @param {number} b_offset
9
+ */
10
+ export function aabb2_array_combine(result: ArrayLike<number> | number[] | Float32Array, result_offset: number, a: ArrayLike<number> | number[] | Float32Array, a_offset: number, b: ArrayLike<number> | number[] | Float32Array, b_offset: number): void;
11
+ //# sourceMappingURL=aabb2_array_combine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb2_array_combine.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_array_combine.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,4CAPW,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,iBACvC,MAAM,KACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,YACvC,MAAM,KACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,YACvC,MAAM,QAwBhB"}
@@ -0,0 +1,35 @@
1
+ import { max2 } from "../../../math/max2.js";
2
+ import { min2 } from "../../../math/min2.js";
3
+
4
+ /**
5
+ * Merge bounds of two axis-aligned bounding boxes, the result is a box that tightly bounds inputs
6
+ * @param {ArrayLike<number>|number[]|Float32Array} result where resulting value is written to
7
+ * @param {number} result_offset
8
+ * @param {ArrayLike<number>|number[]|Float32Array} a
9
+ * @param {number} a_offset
10
+ * @param {ArrayLike<number>|number[]|Float32Array} b
11
+ * @param {number} b_offset
12
+ */
13
+ export function aabb2_array_combine(
14
+ result, result_offset,
15
+ a, a_offset,
16
+ b, b_offset
17
+ ) {
18
+
19
+ const a_x0 = a[a_offset];
20
+ const a_y0 = a[a_offset + 1];
21
+ const a_x1 = a[a_offset + 2];
22
+ const a_y1 = a[a_offset + 3];
23
+
24
+ const b_x0 = b[b_offset];
25
+ const b_y0 = b[b_offset + 1];
26
+ const b_x1 = b[b_offset + 2];
27
+ const b_y1 = b[b_offset + 3];
28
+
29
+ result[result_offset] = min2(a_x0, b_x0);
30
+ result[result_offset + 1] = min2(a_y0, b_y0);
31
+
32
+ result[result_offset + 2] = max2(a_x1, b_x1);
33
+ result[result_offset + 3] = max2(a_y1, b_y1);
34
+
35
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @param {ArrayLike<number>|Float32Array|number[]} result
4
+ * @param {number} result_offset
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} x1
8
+ * @param {number} y1
9
+ */
10
+ export function aabb2_array_set(result: ArrayLike<number> | Float32Array | number[], result_offset: number, x0: number, y0: number, x1: number, y1: number): void;
11
+ //# sourceMappingURL=aabb2_array_set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb2_array_set.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_array_set.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wCAPW,UAAU,MAAM,CAAC,GAAC,YAAY,GAAC,MAAM,EAAE,iBACvC,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAahB"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ *
3
+ * @param {ArrayLike<number>|Float32Array|number[]} result
4
+ * @param {number} result_offset
5
+ * @param {number} x0
6
+ * @param {number} y0
7
+ * @param {number} x1
8
+ * @param {number} y1
9
+ */
10
+ export function aabb2_array_set(
11
+ result, result_offset,
12
+ x0, y0,
13
+ x1, y1,
14
+ ) {
15
+
16
+ result[result_offset + 0] = x0;
17
+ result[result_offset + 1] = y0;
18
+
19
+ result[result_offset + 2] = x1;
20
+ result[result_offset + 3] = y1;
21
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {number} x0
4
+ * @param {number} y0
5
+ * @param {number} x1
6
+ * @param {number} y1
7
+ * @return {number}
8
+ */
9
+ export function aabb2_compute_area(x0: number, y0: number, x1: number, y1: number): number;
10
+ //# sourceMappingURL=aabb2_compute_area.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb2_compute_area.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_compute_area.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,uCANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACL,MAAM,CAOjB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ *
3
+ * @param {number} x0
4
+ * @param {number} y0
5
+ * @param {number} x1
6
+ * @param {number} y1
7
+ * @return {number}
8
+ */
9
+ export function aabb2_compute_area(x0, y0, x1, y1) {
10
+ const dx = x1 - x0;
11
+ const dy = y1 - y0;
12
+
13
+ return dx * dy;
14
+ }
@@ -0,0 +1,289 @@
1
+ export const COLUMN_PARENT: 4;
2
+ export const COLUMN_CHILD_1: 5;
3
+ export const COLUMN_CHILD_2: 6;
4
+ export const COLUMN_HEIGHT: 7;
5
+ /**
6
+ *
7
+ * @type {number}
8
+ */
9
+ export const NULL_NODE: number;
10
+ /**
11
+ * How many words are used for a single NODE in the tree
12
+ * One "word" is 4 bytes for the sake of alignment
13
+ * @readonly
14
+ * @type {number}
15
+ */
16
+ export const ELEMENT_WORD_COUNT: number;
17
+ /**
18
+ * 2D Bounding Volume Hierarchy implementation.
19
+ * Based on BVH (3D) implementation
20
+ * @class
21
+ */
22
+ export class BVH2D {
23
+ /**
24
+ *
25
+ * @type {ArrayBuffer}
26
+ * @private
27
+ */
28
+ private __data_buffer;
29
+ /**
30
+ *
31
+ * @type {Float32Array}
32
+ * @private
33
+ */
34
+ private __data_float32;
35
+ /**
36
+ *
37
+ * @type {Uint32Array}
38
+ * @private
39
+ */
40
+ private __data_uint32;
41
+ /**
42
+ * How many nodes are currently reserved, this will grow automatically through {@link #allocate_node} method usage
43
+ * @type {number}
44
+ * @private
45
+ */
46
+ private __capacity;
47
+ /**
48
+ * Number of used nodes. These are either live nodes, or node sitting in the {@link #__free} pool
49
+ * @type {number}
50
+ * @private
51
+ */
52
+ private __size;
53
+ /**
54
+ * Indices of released nodes. Nodes are pulled from here first if available, before the whole tree gets resized
55
+ * @type {number[]}
56
+ * @private
57
+ */
58
+ private __free;
59
+ /**
60
+ * Pointer into __free array that's used as a stack, so this pointer represents top of the stack
61
+ * @type {number}
62
+ * @private
63
+ */
64
+ private __free_pointer;
65
+ /**
66
+ * Root node of the hierarchy
67
+ * @type {number}
68
+ * @private
69
+ */
70
+ private __root;
71
+ /**
72
+ *
73
+ * @returns {number}
74
+ */
75
+ get root(): number;
76
+ /**
77
+ *
78
+ * @param {number} v
79
+ */
80
+ set node_capacity(arg: number);
81
+ /**
82
+ *
83
+ * @returns {number}
84
+ */
85
+ get node_capacity(): number;
86
+ __grow_capacity(): void;
87
+ /**
88
+ *
89
+ * @param {number} new_capacity in number of nodes
90
+ * @private
91
+ */
92
+ private __set_capacity;
93
+ /**
94
+ * Trim allocated memory region to only contain allocated nodes
95
+ */
96
+ trim(): void;
97
+ /**
98
+ *
99
+ * @returns {number}
100
+ */
101
+ allocate_node(): number;
102
+ /**
103
+ * Release memory used by the node back into the pool
104
+ * NOTE: Make sure that the node is not "live" (not attached to the hierarchy), otherwise this operation may corrupt the tree
105
+ * @param {number} id
106
+ */
107
+ release_node(id: number): void;
108
+ /**
109
+ *
110
+ * @param {number} id
111
+ * @returns {boolean}
112
+ */
113
+ node_is_leaf(id: number): boolean;
114
+ /**
115
+ *
116
+ * @param {number} id
117
+ * @returns {number}
118
+ */
119
+ node_get_user_data(id: number): number;
120
+ /**
121
+ *
122
+ * @param {number} id
123
+ * @param {number} value
124
+ */
125
+ node_set_user_data(id: number, value: number): void;
126
+ /**
127
+ *
128
+ * @param {number} id
129
+ * @returns {number}
130
+ */
131
+ node_get_child1(id: number): number;
132
+ /**
133
+ *
134
+ * @param {number} node
135
+ * @param {number} child1
136
+ */
137
+ node_set_child1(node: number, child1: number): void;
138
+ /**
139
+ *
140
+ * @param {number} id
141
+ * @returns {number}
142
+ */
143
+ node_get_child2(id: number): number;
144
+ /**
145
+ *
146
+ * @param {number} node
147
+ * @param {number} child2
148
+ */
149
+ node_set_child2(node: number, child2: number): void;
150
+ /**
151
+ *
152
+ * @param {number} id
153
+ * @returns {number}
154
+ */
155
+ node_get_parent(id: number): number;
156
+ /**
157
+ *
158
+ * @param {number} node
159
+ * @param {number} parent
160
+ */
161
+ node_set_parent(node: number, parent: number): void;
162
+ /**
163
+ *
164
+ * @param {number} id
165
+ * @returns {number}
166
+ */
167
+ node_get_height(id: number): number;
168
+ /**
169
+ *
170
+ * @param {number} id
171
+ * @param {number} height
172
+ */
173
+ node_set_height(id: number, height: number): void;
174
+ /**
175
+ *
176
+ * @param {number} id
177
+ * @param {number[]|Float32Array} result
178
+ */
179
+ node_get_aabb(id: number, result: number[] | Float32Array): void;
180
+ /**
181
+ *
182
+ * @param {number} id
183
+ * @param {number[]|ArrayLike<number>} aabb
184
+ */
185
+ node_set_aabb(id: number, aabb: number[] | ArrayLike<number>): void;
186
+ /**
187
+ *
188
+ * @param {number} id
189
+ * @param {number[]} aabb
190
+ */
191
+ node_move_aabb(id: number, aabb: number[]): void;
192
+ /**
193
+ *
194
+ * @param {number} id
195
+ * @param {number} x0
196
+ * @param {number} y0
197
+ * @param {number} z0
198
+ * @param {number} x1
199
+ * @param {number} y1
200
+ * @param {number} z1
201
+ */
202
+ node_set_aabb_primitive(id: number, x0: number, y0: number, x1: number, y1: number): void;
203
+ /**
204
+ *
205
+ * @param {number} id
206
+ * @returns {number}
207
+ */
208
+ node_get_surface_area(id: number): number;
209
+ /**
210
+ *
211
+ * @param {number} index_a
212
+ * @param {number} index_b
213
+ * @returns {number}
214
+ */
215
+ node_get_combined_surface_area(index_a: number, index_b: number): number;
216
+ /**
217
+ *
218
+ * @param {number} destination
219
+ * @param {number} index_a
220
+ * @param {number} index_b
221
+ */
222
+ node_set_combined_aabb(destination: number, index_a: number, index_b: number): void;
223
+ /**
224
+ *
225
+ * @param {number} leaf
226
+ * @returns {void}
227
+ */
228
+ insert_leaf(leaf: number): void;
229
+ /**
230
+ * refit and update nodes up the tree. Only updates bounds
231
+ * NOTE: Does not update "height"
232
+ * @param {number} parent
233
+ * @private
234
+ */
235
+ private bubble_up_refit;
236
+ /**
237
+ * refit and update nodes up the tree
238
+ * @param {number} parent
239
+ * @private
240
+ */
241
+ private bubble_up_update;
242
+ /**
243
+ * NOTE: Leaf node is not released, make sure to call {@link #release_node} separately when you no longer need the leaf node
244
+ * @param {number} leaf
245
+ * @returns {void}
246
+ */
247
+ remove_leaf(leaf: number): void;
248
+ /**
249
+ * Perform a left or right rotation if node A is imbalanced.
250
+ * Returns the new root index.
251
+ * @param {number} iA
252
+ * @returns {number}
253
+ * @private
254
+ */
255
+ private balance;
256
+ /**
257
+ * Release all nodes, this essentially resets the tree to empty state
258
+ * NOTE: For performance reasons, released memory is not reset, this means that attempting to access cleared nodes' memory will yield garbage data
259
+ */
260
+ release_all(): void;
261
+ /**
262
+ *
263
+ * @param {function(node:number, tree:BVH):void} callback
264
+ * @param {*} [ctx]
265
+ */
266
+ traverse(callback: any, ctx?: any): void;
267
+ /**
268
+ *
269
+ * @param {number[]} destination
270
+ * @param {number} destination_offset
271
+ * @returns {number}
272
+ */
273
+ collect_nodes_all(destination: number[], destination_offset: number): number;
274
+ /**
275
+ * Update parent and child links of a given node to point to a new location, useful for re-locating nodes
276
+ * @param {number} node node to update
277
+ * @param {number} destination Where updated links should point to
278
+ * @private
279
+ */
280
+ private __move_node_links;
281
+ /**
282
+ * Swap two nodes in memory
283
+ * @param {number} a
284
+ * @param {number} b
285
+ * @returns {boolean}
286
+ */
287
+ swap_nodes(a: number, b: number): boolean;
288
+ }
289
+ //# sourceMappingURL=BVH2D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BVH2D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/bvh/BVH2D.js"],"names":[],"mappings":"AASA,8BAA+B;AAC/B,+BAAgC;AAChC,+BAAgC;AAChC,8BAA+B;AAU/B;;;GAGG;AACH,wBAFU,MAAM,CAEoB;AAcpC;;;;;GAKG;AACH,iCAFU,MAAM,CAEoB;AAgBpC;;;;GAIG;AACH;IAEI;;;;OAIG;IACH,sBAA2E;IAE3E;;;;OAIG;IACH,uBAAsD;IAEtD;;;;OAIG;IACH,sBAAoD;IAEpD;;;;OAIG;IACH,mBAA8B;IAE9B;;;;OAIG;IACH,eAAW;IAEX;;;;OAIG;IACH,eAAY;IAEZ;;;;OAIG;IACH,uBAAmB;IAEnB;;;;OAIG;IACH,eAAmB;IAEnB;;;OAGG;IACH,mBAEC;IAUD;;;OAGG;IACH,+BAMC;IAlBD;;;OAGG;IACH,4BAEC;IAcD,wBAgBC;IAED;;;;OAIG;IACH,uBAqBC;IAED;;OAEG;IACH,aAIC;IAED;;;OAGG;IACH,iBAFa,MAAM,CAmDlB;IAED;;;;OAIG;IACH,iBAFW,MAAM,QAMhB;IAED;;;;OAIG;IACH,iBAHW,MAAM,GACJ,OAAO,CAOnB;IAED;;;;OAIG;IACH,uBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,uBAHW,MAAM,SACN,MAAM,QAOhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,MAAM,CAKlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,UACN,M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