@woosh/meep-engine 2.109.25 → 2.109.26

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 (70) hide show
  1. package/build/meep.cjs +58 -54
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +58 -54
  4. package/package.json +1 -1
  5. package/src/core/collection/heap/{FastBinaryHeap.d.ts → BinaryHeap.d.ts} +4 -4
  6. package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -0
  7. package/src/core/collection/heap/{FastBinaryHeap.js → BinaryHeap.js} +3 -3
  8. package/src/core/collection/heap/BinaryHeap.spec.d.ts +2 -0
  9. package/src/core/collection/heap/BinaryHeap.spec.d.ts.map +1 -0
  10. package/src/core/collection/heap/{FastBinaryHeap.spec.js → BinaryHeap.spec.js} +10 -10
  11. package/src/core/collection/heap/Uint32Heap.spec.d.ts +2 -0
  12. package/src/core/collection/heap/Uint32Heap.spec.d.ts.map +1 -0
  13. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +1 -0
  14. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
  15. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +5 -5
  16. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
  17. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +14 -8
  18. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +2 -2
  19. package/src/core/graph/Edge.d.ts +1 -0
  20. package/src/core/graph/Edge.d.ts.map +1 -1
  21. package/src/core/graph/Edge.js +5 -0
  22. package/src/core/graph/graph_compute_distance_matrix.js +2 -2
  23. package/src/core/graph/metis/cluster_mesh_metis.d.ts +9 -0
  24. package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -0
  25. package/src/core/graph/metis/cluster_mesh_metis.js +31 -0
  26. package/src/core/graph/metis/mesh_to_metis_graph.d.ts +10 -0
  27. package/src/core/graph/metis/mesh_to_metis_graph.d.ts.map +1 -0
  28. package/src/core/graph/metis/mesh_to_metis_graph.js +64 -0
  29. package/src/core/graph/metis/metis_cluster_bs.d.ts +12 -0
  30. package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -0
  31. package/src/core/graph/{cluster_mesh_metis.js → metis/metis_cluster_bs.js} +12 -98
  32. package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
  33. package/src/core/graph/mn_graph_coarsen.js +7 -3
  34. package/src/core/graph/mn_graph_coarsen.spec.js +2 -0
  35. package/src/engine/asset/AssetManager.js +3 -3
  36. package/src/engine/graphics/sh3/gi/material/common.glsl +45 -54
  37. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
  38. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +5 -3
  39. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +2 -2
  40. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +1 -1
  41. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  42. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +3 -2
  43. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
  44. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +14 -7
  45. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +17 -15
  46. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  47. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +6 -2
  48. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +2 -2
  49. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  50. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +10 -0
  51. package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
  52. package/src/engine/input/devices/PointerDevice.js +1 -1
  53. package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts.map +1 -0
  54. package/src/engine/network/PriorityFetch.d.ts.map +1 -1
  55. package/src/engine/network/PriorityFetch.js +2 -2
  56. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +3 -3
  57. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +2 -2
  58. package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +2 -2
  59. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
  60. package/src/core/collection/heap/FastBinaryHeap.d.ts.map +0 -1
  61. package/src/core/collection/heap/FastBinaryHeap.spec.d.ts +0 -2
  62. package/src/core/collection/heap/FastBinaryHeap.spec.d.ts.map +0 -1
  63. package/src/core/collection/heap/Uin32Heap.spec.d.ts +0 -2
  64. package/src/core/collection/heap/Uin32Heap.spec.d.ts.map +0 -1
  65. package/src/core/graph/cluster_mesh_metis.d.ts +0 -28
  66. package/src/core/graph/cluster_mesh_metis.d.ts.map +0 -1
  67. package/src/engine/input/devices/eventToSourceIdentifier.d.ts.map +0 -1
  68. /package/src/core/collection/heap/{Uin32Heap.spec.js → Uint32Heap.spec.js} +0 -0
  69. /package/src/engine/input/devices/{eventToSourceIdentifier.d.ts → events/eventToSourceIdentifier.d.ts} +0 -0
  70. /package/src/engine/input/devices/{eventToSourceIdentifier.js → events/eventToSourceIdentifier.js} +0 -0
@@ -71547,6 +71547,23 @@ class EntityObserver {
71547
71547
  }
71548
71548
  }
71549
71549
 
71550
+ /**
71551
+ * Given an object and a value, find the first property with matching value and returns name of that property
71552
+ * Useful for working with ENUM-like objects
71553
+ * @param {Object<T>} object
71554
+ * @param {T} value
71555
+ * @returns {string|undefined} name of the property, or undefined if property not found
71556
+ */
71557
+ function objectKeyByValue(object, value) {
71558
+ for (let i in object) {
71559
+ if (object[i] === value) {
71560
+ return i;
71561
+ }
71562
+ }
71563
+
71564
+ return undefined;
71565
+ }
71566
+
71550
71567
  /**
71551
71568
  *
71552
71569
  * @enum {number}
@@ -71663,6 +71680,10 @@ class Edge {
71663
71680
  return [this.first, this.second];
71664
71681
  }
71665
71682
 
71683
+ toString() {
71684
+ return `Edge:{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
71685
+ }
71686
+
71666
71687
  }
71667
71688
 
71668
71689
  /**
@@ -78580,23 +78601,6 @@ class ShadedGeometrySystem extends System {
78580
78601
  }
78581
78602
  }
78582
78603
 
78583
- /**
78584
- * Given an object and a value, find the first property with matching value and returns name of that property
78585
- * Useful for working with ENUM-like objects
78586
- * @param {Object<T>} object
78587
- * @param {T} value
78588
- * @returns {string|undefined} name of the property, or undefined if property not found
78589
- */
78590
- function objectKeyByValue(object, value) {
78591
- for (let i in object) {
78592
- if (object[i] === value) {
78593
- return i;
78594
- }
78595
- }
78596
-
78597
- return undefined;
78598
- }
78599
-
78600
78604
  /**
78601
78605
  *
78602
78606
  * @enum {string}
@@ -84592,7 +84596,7 @@ class ViewStack extends View {
84592
84596
  * The data structure is a binary heap where elements are removed in order defined by scoring function
84593
84597
  * @template T
84594
84598
  */
84595
- class FastBinaryHeap {
84599
+ class BinaryHeap {
84596
84600
  /**
84597
84601
  * @private
84598
84602
  * @type {T[]}
@@ -84863,7 +84867,7 @@ class FastBinaryHeap {
84863
84867
  * @readonly
84864
84868
  * @type {boolean}
84865
84869
  */
84866
- FastBinaryHeap.prototype.isFastBinaryHeap = true;
84870
+ BinaryHeap.prototype.isBinaryHeap = true;
84867
84871
 
84868
84872
  /**
84869
84873
  * Decorator that wraps another map and lets you observe mutations
@@ -86053,7 +86057,7 @@ let Response$1 = class Response {
86053
86057
  };
86054
86058
 
86055
86059
  /**
86056
- * Used by the priority queue, so the priority is inverted as the FastBinaryHeap returns elements in ascending score order (from lowest)
86060
+ * Used by the priority queue, so the priority is inverted as the BinaryHeap returns elements in ascending score order (from lowest)
86057
86061
  * @param {PendingAsset} pending_asset
86058
86062
  * @returns {number}
86059
86063
  */
@@ -86088,7 +86092,7 @@ class AssetManager {
86088
86092
  * @type {BinaryHeap<PendingAsset>}
86089
86093
  * @private
86090
86094
  */
86091
- #pending_asset_wait_queue = new FastBinaryHeap(get_pending_asset_priority_score);
86095
+ #pending_asset_wait_queue = new BinaryHeap(get_pending_asset_priority_score);
86092
86096
  /**
86093
86097
  * Assets currently being processed by #loaders
86094
86098
  * @type {Set<PendingAsset>}
@@ -91420,38 +91424,6 @@ class KeyboardDevice {
91420
91424
  }
91421
91425
  }
91422
91426
 
91423
- /**
91424
- * Event names for DOM {@link EventTarget} related to mouse.
91425
- * useful for .addEventListener and .removeEventListener
91426
- * @readonly
91427
- * @enum {string}
91428
- */
91429
- const MouseEvents = {
91430
- Down: "mousedown",
91431
- Up: "mouseup",
91432
- Move: "mousemove",
91433
- Enter: "mouseenter",
91434
- Leave: "mouseleave",
91435
- Out: "mouseout",
91436
- Over: "mouseover",
91437
- Wheel: "wheel",
91438
- Click: "click",
91439
- DoubleClick: "dblclick"
91440
- };
91441
-
91442
- /**
91443
- * Event names for DOM {@link EventTarget} related to touch.
91444
- * useful for .addEventListener and .removeEventListener
91445
- * @readonly
91446
- * @enum {string}
91447
- */
91448
- const TouchEvents = {
91449
- Start: "touchstart",
91450
- End: "touchend",
91451
- Move: "touchmove",
91452
- Cancel: "touchcancel",
91453
- };
91454
-
91455
91427
  /**
91456
91428
  *
91457
91429
  * @param {TouchEvent|MouseEvent} event
@@ -91489,6 +91461,38 @@ function eventToSourceIdentifier(event) {
91489
91461
  ;
91490
91462
  }
91491
91463
 
91464
+ /**
91465
+ * Event names for DOM {@link EventTarget} related to mouse.
91466
+ * useful for .addEventListener and .removeEventListener
91467
+ * @readonly
91468
+ * @enum {string}
91469
+ */
91470
+ const MouseEvents = {
91471
+ Down: "mousedown",
91472
+ Up: "mouseup",
91473
+ Move: "mousemove",
91474
+ Enter: "mouseenter",
91475
+ Leave: "mouseleave",
91476
+ Out: "mouseout",
91477
+ Over: "mouseover",
91478
+ Wheel: "wheel",
91479
+ Click: "click",
91480
+ DoubleClick: "dblclick"
91481
+ };
91482
+
91483
+ /**
91484
+ * Event names for DOM {@link EventTarget} related to touch.
91485
+ * useful for .addEventListener and .removeEventListener
91486
+ * @readonly
91487
+ * @enum {string}
91488
+ */
91489
+ const TouchEvents = {
91490
+ Start: "touchstart",
91491
+ End: "touchend",
91492
+ Move: "touchmove",
91493
+ Cancel: "touchcancel",
91494
+ };
91495
+
91492
91496
  class LocationalInteractionMetadata {
91493
91497
  timestamp = performance.now()
91494
91498
  position = new Vector2()
@@ -108162,7 +108166,7 @@ class MaxRectanglesPacker {
108162
108166
  return -Math.min(box.getWidth(), box.getHeight());
108163
108167
  }
108164
108168
 
108165
- const heap = new FastBinaryHeap(scoreBoxByMinSide);
108169
+ const heap = new BinaryHeap(scoreBoxByMinSide);
108166
108170
 
108167
108171
  for (let i = 0; i < numBoxes; i++) {
108168
108172
  heap.push(i);
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.109.25",
8
+ "version": "2.109.26",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1,10 +1,10 @@
1
- export default FastBinaryHeap;
1
+ export default BinaryHeap;
2
2
  /**
3
3
  * Min-Heap implementation with a score function.
4
4
  * The data structure is a binary heap where elements are removed in order defined by scoring function
5
5
  * @template T
6
6
  */
7
- declare class FastBinaryHeap<T> {
7
+ declare class BinaryHeap<T> {
8
8
  /**
9
9
  * @template T
10
10
  * @param {function(el:T):number} scoreFunction
@@ -93,6 +93,6 @@ declare class FastBinaryHeap<T> {
93
93
  * @readonly
94
94
  * @type {boolean}
95
95
  */
96
- readonly isFastBinaryHeap: boolean;
96
+ readonly isBinaryHeap: boolean;
97
97
  }
98
- //# sourceMappingURL=FastBinaryHeap.d.ts.map
98
+ //# sourceMappingURL=BinaryHeap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BinaryHeap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.js"],"names":[],"mappings":";AAEA;;;;GAIG;AACH;IAaI;;;;OAIG;IACH,gCAQC;IAzBD;;;OAGG;IACH,aAAU;IAEV;;;OAGG;IACH,eAAW;IASP;;;OAGG;IACH,8BAFuB,MAAM,CAEK;IAItC;;;OAGG;IACH,iBA8BC;IAED;;;OAGG;IACH,mBAmEC;IAED;;;OAGG;IACH,OAFY,CAAC,CA0BZ;IAED;;;OAGG;IACH,QAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;;OAIG;IACH,aAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;OAGG;IACH,iBAFW,MAAM,QAOhB;IAED;;OAEG;IACH,cAGC;IAED;;;;OAIG;IACH,eAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,QAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAWnB;IAED;;;OAGG;IACH,SAFW,CAAC,QAUX;IAGL;;;;OAIG;IACH,uBAFU,OAAO,CAEgB;CAPhC"}
@@ -5,7 +5,7 @@ import { assert } from "../../assert.js";
5
5
  * The data structure is a binary heap where elements are removed in order defined by scoring function
6
6
  * @template T
7
7
  */
8
- class FastBinaryHeap {
8
+ class BinaryHeap {
9
9
  /**
10
10
  * @private
11
11
  * @type {T[]}
@@ -278,6 +278,6 @@ class FastBinaryHeap {
278
278
  * @readonly
279
279
  * @type {boolean}
280
280
  */
281
- FastBinaryHeap.prototype.isFastBinaryHeap = true;
281
+ BinaryHeap.prototype.isBinaryHeap = true;
282
282
 
283
- export default FastBinaryHeap;
283
+ export default BinaryHeap;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BinaryHeap.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BinaryHeap.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/BinaryHeap.spec.js"],"names":[],"mappings":""}
@@ -2,20 +2,20 @@ import { passThrough } from "../../function/passThrough.js";
2
2
  import { returnZero } from "../../function/returnZero.js";
3
3
  import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
4
4
  import { seededRandom } from "../../math/random/seededRandom.js";
5
- import FastBinaryHeap from "./FastBinaryHeap.js";
5
+ import BinaryHeap from "./BinaryHeap.js";
6
6
 
7
7
  test("constructor doesn't throw", () => {
8
- new FastBinaryHeap(returnZero);
8
+ new BinaryHeap(returnZero);
9
9
  });
10
10
 
11
11
  test("empty heap has size 0", () => {
12
- const h = new FastBinaryHeap(returnZero);
12
+ const h = new BinaryHeap(returnZero);
13
13
 
14
14
  expect(h.size()).toBe(0);
15
15
  });
16
16
 
17
17
  test('clear empty', () => {
18
- const h = new FastBinaryHeap(returnZero);
18
+ const h = new BinaryHeap(returnZero);
19
19
 
20
20
  h.clear();
21
21
 
@@ -24,7 +24,7 @@ test('clear empty', () => {
24
24
  });
25
25
 
26
26
  test('clear heap with 1 element', () => {
27
- const h = new FastBinaryHeap(returnZero);
27
+ const h = new BinaryHeap(returnZero);
28
28
 
29
29
  h.push(1);
30
30
 
@@ -35,7 +35,7 @@ test('clear heap with 1 element', () => {
35
35
  });
36
36
 
37
37
  test("isEmpty", () => {
38
- const h = new FastBinaryHeap(returnZero);
38
+ const h = new BinaryHeap(returnZero);
39
39
 
40
40
  expect(h.isEmpty()).toBe(true);
41
41
 
@@ -49,7 +49,7 @@ test("isEmpty", () => {
49
49
  });
50
50
 
51
51
  test("push followed by a pop", () => {
52
- const h = new FastBinaryHeap(returnZero);
52
+ const h = new BinaryHeap(returnZero);
53
53
 
54
54
  h.push(7);
55
55
 
@@ -63,7 +63,7 @@ test("push followed by a pop", () => {
63
63
  });
64
64
 
65
65
  test("contains method", () => {
66
- const h = new FastBinaryHeap(returnZero);
66
+ const h = new BinaryHeap(returnZero);
67
67
 
68
68
  expect(h.contains(7)).toBe(false);
69
69
 
@@ -82,7 +82,7 @@ test("contains method", () => {
82
82
  });
83
83
 
84
84
  test("correct sorting of 4 numbers", () => {
85
- const h = new FastBinaryHeap(passThrough);
85
+ const h = new BinaryHeap(passThrough);
86
86
 
87
87
  const input = [2, 7, 1, 5];
88
88
 
@@ -100,7 +100,7 @@ test("correct sorting of 4 numbers", () => {
100
100
  });
101
101
 
102
102
  test.skip("performance 100k random fill -> drain", () => {
103
- const h = new FastBinaryHeap(passThrough);
103
+ const h = new BinaryHeap(passThrough);
104
104
 
105
105
  const random = seededRandom(42);
106
106
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Uint32Heap.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Uint32Heap.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/heap/Uint32Heap.spec.js"],"names":[],"mappings":""}
@@ -22,4 +22,5 @@ export function collapse_edges(number_faces_to_remove: number, heap: BinaryHeap<
22
22
  */
23
23
  export function simplifyTopoMesh(mesh: TopoMesh, num_faces_to_remove: number, restricted_vertices?: Set<number>): void;
24
24
  import { EdgeCollapseCandidate } from "./EdgeCollapseCandidate.js";
25
+ import BinaryHeap from "../../../../collection/heap/BinaryHeap.js";
25
26
  //# sourceMappingURL=simplifyTopoMesh.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"simplifyTopoMesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/simplifyTopoMesh.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFW,qBAAqB,UAI/B;AAGD;;;;;;;GAOG;AACH,uDAPW,MAAM,iFAGN,cAAc,qBAAqB,CAAC,qBACpC,IAAI,MAAM,aAAa,uBACvB,IAAI,MAAM,CAAC,QAyKrB;AAED;;;;;;;GAOG;AACH,sEAHW,MAAM,wBACN,IAAI,MAAM,CAAC,QAwDrB;sCAnQqC,4BAA4B"}
1
+ {"version":3,"file":"simplifyTopoMesh.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/topology/simplify/simplifyTopoMesh.js"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wCAFW,qBAAqB,UAI/B;AAGD;;;;;;;GAOG;AACH,uDAPW,MAAM,QACN,WAAW,qBAAqB,CAAC,wCAEjC,cAAc,qBAAqB,CAAC,qBACpC,IAAI,MAAM,aAAa,uBACvB,IAAI,MAAM,CAAC,QAyKrB;AAED;;;;;;;GAOG;AACH,sEAHW,MAAM,wBACN,IAAI,MAAM,CAAC,QAwDrB;sCAhQqC,4BAA4B;uBAJ3C,2CAA2C"}
@@ -1,10 +1,10 @@
1
- import FastBinaryHeap from "../../../../collection/heap/FastBinaryHeap.js";
2
1
  import { array_copy_unique } from "../../../../collection/array/array_copy_unique.js";
2
+ import BinaryHeap from "../../../../collection/heap/BinaryHeap.js";
3
+ import { build_edge_collapse_candidates } from "./build_edge_collapse_candidates.js";
4
+ import { collapse_all_degenerate_edges } from "./collapse_all_degenerate_edges.js";
5
+ import { collapse_degenerate_edge } from "./collapse_degenerate_edge.js";
3
6
  import { EdgeCollapseCandidate } from "./EdgeCollapseCandidate.js";
4
7
  import { build_vertex_quadratics } from "./quadratic/build_vertex_quadratics.js";
5
- import { collapse_degenerate_edge } from "./collapse_degenerate_edge.js";
6
- import { collapse_all_degenerate_edges } from "./collapse_all_degenerate_edges.js";
7
- import { build_edge_collapse_candidates } from "./build_edge_collapse_candidates.js";
8
8
 
9
9
 
10
10
  const scratch_array_1 = [];
@@ -220,7 +220,7 @@ export function simplifyTopoMesh(mesh, num_faces_to_remove, restricted_vertices
220
220
  *
221
221
  * @type {BinaryHeap<EdgeCollapseCandidate>}
222
222
  */
223
- const open_set = new FastBinaryHeap(extract_edge_cost);
223
+ const open_set = new BinaryHeap(extract_edge_cost);
224
224
 
225
225
  /**
226
226
  *
@@ -1 +1 @@
1
- {"version":3,"file":"computeTriangleRayIntersectionBarycentricEdge.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,sEAlBW,MAAM,EAAE,YACR,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,GACL,OAAO,CAgElB"}
1
+ {"version":3,"file":"computeTriangleRayIntersectionBarycentricEdge.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,sEAlBW,MAAM,EAAE,YACR,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,GACL,OAAO,CAsElB"}
@@ -43,20 +43,27 @@ export function computeTriangleRayIntersectionBarycentricEdge(
43
43
  //if determinant is near zero, ray lies in plane of triangle
44
44
  const det = v3_dot(edge1_x, edge1_y, edge1_z, pvec_x, pvec_y, pvec_z);
45
45
 
46
+ if(det === 0){
47
+ // ray is parallel to the plane of the triange, no intersection possible
48
+ return false;
49
+ }
50
+
46
51
  if (det <= 0) {
47
52
  // back-face culling
48
- return false;
53
+ // return false;
49
54
  }
50
55
 
56
+ const inv_det = 1 / det;
57
+
51
58
  // calculate distance from vert0 to ray origin (not really, but okay)
52
59
  const tvec_x = origin_x - ax;
53
60
  const tvec_y = origin_y - ay;
54
61
  const tvec_z = origin_z - az;
55
62
 
56
63
  // calculate u
57
- const u = v3_dot(tvec_x, tvec_y, tvec_z, pvec_x, pvec_y, pvec_z);
64
+ const u = v3_dot(tvec_x, tvec_y, tvec_z, pvec_x, pvec_y, pvec_z)*inv_det;
58
65
 
59
- if (u < 0 || u > det) {
66
+ if (u < 0 || u > 1) {
60
67
  // outside of bounds of the triangle
61
68
  return false;
62
69
  }
@@ -68,22 +75,21 @@ export function computeTriangleRayIntersectionBarycentricEdge(
68
75
  const qvec_z = tvec_x * edge1_y - tvec_y * edge1_x;
69
76
 
70
77
  // calculate V parameter
71
- const v = v3_dot(direction_x, direction_y, direction_z, qvec_x, qvec_y, qvec_z);
78
+ const v = v3_dot(direction_x, direction_y, direction_z, qvec_x, qvec_y, qvec_z)*inv_det;
72
79
 
73
- if (v < 0 || u + v > det) {
80
+ if (v < 0 || u + v > 1) {
74
81
  // out of bounds
75
82
  return false;
76
83
  }
77
84
 
78
85
 
79
- const inv_det = 1 / det;
80
86
 
81
87
  // calculate t, scale parameter, ray intersects triangle
82
88
  const t = v3_dot(edge2_x, edge2_y, edge2_z, qvec_x, qvec_y, qvec_z) * inv_det;
83
89
 
84
90
  result[0] = t;
85
- result[1] = u * inv_det;
86
- result[2] = v * inv_det;
91
+ result[1] = u ;
92
+ result[2] = v ;
87
93
 
88
94
  return true;
89
95
  }
@@ -1,5 +1,5 @@
1
1
  import { assert } from "../../../assert.js";
2
- import FastBinaryHeap from "../../../collection/heap/FastBinaryHeap.js";
2
+ import BinaryHeap from "../../../collection/heap/BinaryHeap.js";
3
3
  import AABB2 from "../../2d/aabb/AABB2.js";
4
4
  import { QuadTreeDatum } from "../../2d/quad-tree/QuadTreeDatum.js";
5
5
  import { QuadTreeNode } from "../../2d/quad-tree/QuadTreeNode.js";
@@ -136,7 +136,7 @@ export class MaxRectanglesPacker {
136
136
  return -Math.min(box.getWidth(), box.getHeight());
137
137
  }
138
138
 
139
- const heap = new FastBinaryHeap(scoreBoxByMinSide);
139
+ const heap = new BinaryHeap(scoreBoxByMinSide);
140
140
 
141
141
  for (let i = 0; i < numBoxes; i++) {
142
142
  heap.push(i);
@@ -75,6 +75,7 @@ export class Edge<N> {
75
75
  * @returns {N[]}
76
76
  */
77
77
  get nodes(): N[];
78
+ toString(): string;
78
79
  /**
79
80
  *
80
81
  * @type {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"gCAIU,MAAM;;;;;;AAQhB;;GAEG;AACH;IACI;;;;;OAKG;IACH,4BAmBC;IAfG;;;OAGG;IACH,WAAc;IACd;;;OAGG;IACH,YAAe;IAEf;;OAEG;IACH,WAFU,iBAAiB,CAEkB;IAGjD;;;;OAIG;IACH,eAHW,CAAC,GACA,OAAO,CAIlB;IAED;;;;;OAKG;IACH,2BAJW,CAAC,UACD,CAAC,GACC,OAAO,CASnB;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,CAAC,CAIb;IAED;;;OAGG;IACH,sBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,uBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,wBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,iBAEC;IAIL;;;OAGG;IACH,QAFU,OAAO,CAEI;CANpB"}
1
+ {"version":3,"file":"Edge.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/Edge.js"],"names":[],"mappings":"gCAKU,MAAM;;;;;;AAQhB;;GAEG;AACH;IACI;;;;;OAKG;IACH,4BAmBC;IAfG;;;OAGG;IACH,WAAc;IACd;;;OAGG;IACH,YAAe;IAEf;;OAEG;IACH,WAFU,iBAAiB,CAEkB;IAGjD;;;;OAIG;IACH,eAHW,CAAC,GACA,OAAO,CAIlB;IAED;;;;;OAKG;IACH,2BAJW,CAAC,UACD,CAAC,GACC,OAAO,CASnB;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,CAAC,CAIb;IAED;;;OAGG;IACH,sBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,uBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,wBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;;OAIG;IACH,yBAHW,CAAC,GACC,OAAO,CAKnB;IAED;;;OAGG;IACH,iBAEC;IAED,mBAEC;IAIL;;;OAGG;IACH,QAFU,OAAO,CAEI;CANpB"}
@@ -1,4 +1,5 @@
1
1
  import { assert } from "../assert.js";
2
+ import { objectKeyByValue } from "../model/object/objectKeyByValue.js";
2
3
 
3
4
  /**
4
5
  *
@@ -118,6 +119,10 @@ export class Edge {
118
119
  return [this.first, this.second];
119
120
  }
120
121
 
122
+ toString() {
123
+ return `Edge:{ first=${this.first}, second=${this.second}, direction=${objectKeyByValue(EdgeDirectionType, this.direction)} }`
124
+ }
125
+
121
126
  }
122
127
 
123
128
  /**
@@ -1,6 +1,6 @@
1
1
  import { BitSet } from "../binary/BitSet.js";
2
2
  import { BinaryDataType } from "../binary/type/BinaryDataType.js";
3
- import FastBinaryHeap from "../collection/heap/FastBinaryHeap.js";
3
+ import BinaryHeap from "../collection/heap/BinaryHeap.js";
4
4
  import { SquareMatrix } from "./SquareMatrix.js";
5
5
 
6
6
  /**
@@ -40,7 +40,7 @@ export function graph_compute_distance_matrix(graph, node_array, targets, node_i
40
40
  // distance to self is always 0
41
41
  m_distances.setCellValue(source_node, source_node, 0);
42
42
 
43
- const heap = new FastBinaryHeap(score);
43
+ const heap = new BinaryHeap(score);
44
44
  heap.push(source_node);
45
45
 
46
46
  while (!heap.isEmpty()) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {Uint32Array} result
4
+ * @param {TopoMesh} mesh
5
+ * @param {number} patch_size
6
+ * @returns {number}
7
+ */
8
+ export function cluster_mesh_metis(result: Uint32Array, mesh: TopoMesh, patch_size: number): number;
9
+ //# sourceMappingURL=cluster_mesh_metis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster_mesh_metis.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/cluster_mesh_metis.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,2CALW,WAAW,8BAEX,MAAM,GACJ,MAAM,CAqBlB"}
@@ -0,0 +1,31 @@
1
+ import { mesh_to_metis_graph } from "./mesh_to_metis_graph.js";
2
+ import { metis_cluster_bs } from "./metis_cluster_bs.js";
3
+
4
+ /**
5
+ *
6
+ * @param {Uint32Array} result
7
+ * @param {TopoMesh} mesh
8
+ * @param {number} patch_size
9
+ * @returns {number}
10
+ */
11
+ export async function cluster_mesh_metis(result, mesh, patch_size) {
12
+
13
+ const face_set = mesh.getFaces();
14
+ const input_face_count = face_set.size;
15
+
16
+ const face_array = Array.from(face_set);
17
+
18
+ const metis_graph = mesh_to_metis_graph(face_array);
19
+
20
+ const partition_count = await metis_cluster_bs(
21
+ result,
22
+ input_face_count,
23
+ metis_graph.edge_addresses,
24
+ metis_graph.adjacency,
25
+ metis_graph.edge_weights,
26
+ patch_size
27
+ );
28
+
29
+ return partition_count;
30
+ }
31
+
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @param {TopoTriangle[]} face_array
3
+ * @returns {{edge_addresses:Uint32Array, adjacency:Uint32Array, edge_weights:Uint32Array}}
4
+ */
5
+ export function mesh_to_metis_graph(face_array: TopoTriangle[]): {
6
+ edge_addresses: Uint32Array;
7
+ adjacency: Uint32Array;
8
+ edge_weights: Uint32Array;
9
+ };
10
+ //# sourceMappingURL=mesh_to_metis_graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh_to_metis_graph.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/mesh_to_metis_graph.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,gDAHW,cAAc;oBACI,WAAW;eAAY,WAAW;kBAAe,WAAW;EA2DxF"}
@@ -0,0 +1,64 @@
1
+ import { assert } from "../../assert.js";
2
+
3
+ /**
4
+ * @param {TopoTriangle[]} face_array
5
+ * @returns {{edge_addresses:Uint32Array, adjacency:Uint32Array, edge_weights:Uint32Array}}
6
+ */
7
+ export function mesh_to_metis_graph(face_array) {
8
+ assert.isArray(face_array, 'face_array');
9
+
10
+ const input_face_count = face_array.length;
11
+
12
+ const edge_addresses = new Uint32Array(input_face_count + 1);
13
+ const adjacency = [];
14
+ const edge_weights = [];
15
+
16
+ const face_index_map = new Map();
17
+
18
+ for (let i = 0; i < input_face_count; i++) {
19
+ const face = face_array[i];
20
+ face_index_map.set(face, i);
21
+ }
22
+
23
+ let offset = 0;
24
+ edge_addresses[0] = 0;
25
+ for (let i = 0; i < input_face_count; i++) {
26
+ const face = face_array[i];
27
+
28
+ const edges = face.edges;
29
+
30
+ const edge_count = edges.length;
31
+ for (let j = 0; j < edge_count; j++) {
32
+ const topoEdge = edges[j];
33
+
34
+ const edge_faces = topoEdge.faces;
35
+
36
+ const edge_face_count = edge_faces.length;
37
+ for (let k = 0; k < edge_face_count; k++) {
38
+ const neighbour = edge_faces[k];
39
+
40
+ if (neighbour === face) {
41
+ //skip self
42
+ continue;
43
+ }
44
+
45
+ adjacency[offset] = face_index_map.get(neighbour);
46
+ edge_weights[offset] = 1;
47
+
48
+ offset++;
49
+ }
50
+ }
51
+
52
+ edge_addresses[i + 1] = offset;
53
+ }
54
+
55
+ const adjecency_uint32 = new Uint32Array(adjacency);
56
+ const edge_weights_uint32 = new Uint32Array(edge_weights);
57
+
58
+
59
+ return {
60
+ edge_addresses: edge_addresses,
61
+ adjacency: adjecency_uint32,
62
+ edge_weights: edge_weights_uint32
63
+ };
64
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * @param {Uint32Array} result
4
+ * @param {number} node_count
5
+ * @param {Uint32Array} edge_addresses
6
+ * @param {Uint32Array} adjacency_uint32
7
+ * @param {Uint32Array} edge_weights_uint32
8
+ * @param {number} patch_size
9
+ * @returns {Promise<number>}
10
+ */
11
+ export function metis_cluster_bs(result: Uint32Array, node_count: number, edge_addresses: Uint32Array, adjacency_uint32: Uint32Array, edge_weights_uint32: Uint32Array, patch_size: number): Promise<number>;
12
+ //# sourceMappingURL=metis_cluster_bs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metis_cluster_bs.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/metis/metis_cluster_bs.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,yCARW,WAAW,cACX,MAAM,kBACN,WAAW,oBACX,WAAW,uBACX,WAAW,cACX,MAAM,GACJ,QAAQ,MAAM,CAAC,CA6G3B"}