@woosh/meep-engine 2.109.24 → 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 (93) hide show
  1. package/build/meep.cjs +248 -117
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +248 -117
  4. package/package.json +1 -1
  5. package/src/core/collection/heap/{FastBinaryHeap.d.ts → BinaryHeap.d.ts} +16 -9
  6. package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -0
  7. package/src/core/collection/heap/{FastBinaryHeap.js → BinaryHeap.js} +31 -21
  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} +1 -1
  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/collection/table/RowFirstTable.d.ts +10 -7
  14. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  15. package/src/core/collection/table/RowFirstTable.js +23 -6
  16. package/src/core/geom/3d/normal/octahedron/encode_unit_to_octahedron.js +2 -2
  17. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts +1 -0
  18. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.d.ts.map +1 -1
  19. package/src/core/geom/3d/topology/simplify/simplifyTopoMesh.js +5 -5
  20. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
  21. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +14 -8
  22. package/src/core/geom/packing/max-rect/MaxRectanglesPacker.js +1 -1
  23. package/src/core/graph/Edge.d.ts +1 -0
  24. package/src/core/graph/Edge.d.ts.map +1 -1
  25. package/src/core/graph/Edge.js +5 -0
  26. package/src/core/graph/graph_compute_distance_matrix.js +2 -2
  27. package/src/core/graph/metis/cluster_mesh_metis.d.ts +9 -0
  28. package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -0
  29. package/src/core/graph/metis/cluster_mesh_metis.js +31 -0
  30. package/src/core/graph/metis/mesh_to_metis_graph.d.ts +10 -0
  31. package/src/core/graph/metis/mesh_to_metis_graph.d.ts.map +1 -0
  32. package/src/core/graph/metis/mesh_to_metis_graph.js +64 -0
  33. package/src/core/graph/metis/metis_cluster_bs.d.ts +12 -0
  34. package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -0
  35. package/src/core/graph/{cluster_mesh_metis.js → metis/metis_cluster_bs.js} +12 -98
  36. package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
  37. package/src/core/graph/mn_graph_coarsen.js +7 -3
  38. package/src/core/graph/mn_graph_coarsen.spec.js +2 -0
  39. package/src/engine/animation/async/TimeSeries.d.ts.map +1 -1
  40. package/src/engine/animation/async/TimeSeries.js +6 -2
  41. package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts +9 -0
  42. package/src/engine/animation/async/table_find_min_index_in_ordered_column.d.ts.map +1 -0
  43. package/src/engine/animation/async/{findSampleIndex.js → table_find_min_index_in_ordered_column.js} +5 -4
  44. package/src/engine/asset/AssetManager.js +2 -2
  45. package/src/engine/graphics/sh3/gi/material/common.glsl +46 -55
  46. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.d.ts.map +1 -1
  47. package/src/engine/graphics/sh3/gi/material/makeOctahedralDepthAtlas.js +5 -3
  48. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +1 -1
  49. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +1 -1
  50. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  51. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +3 -2
  52. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.d.ts.map +1 -1
  53. package/src/engine/graphics/sh3/lpv/depth/octahedral/bake_octahedral_depth_map.js +19 -7
  54. package/src/engine/graphics/sh3/lpv/depth/octahedral/v2/visualise.frag.glsl +17 -15
  55. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -1
  56. package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +6 -2
  57. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.js +2 -2
  58. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  59. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +10 -0
  60. package/src/engine/graphics/sh3/prototypeSH3Probe.js +3 -3
  61. package/src/engine/input/devices/InputDeviceSwitch.d.ts.map +1 -1
  62. package/src/engine/input/devices/InputDeviceSwitch.js +18 -0
  63. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  64. package/src/engine/input/devices/KeyboardDevice.js +4 -41
  65. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts +11 -0
  66. package/src/engine/input/devices/LocationalInteractionMetadata.d.ts.map +1 -0
  67. package/src/engine/input/devices/LocationalInteractionMetadata.js +18 -0
  68. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  69. package/src/engine/input/devices/PointerDevice.js +90 -37
  70. package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts +7 -0
  71. package/src/engine/input/devices/events/eventToSourceIdentifier.d.ts.map +1 -0
  72. package/src/engine/input/devices/events/eventToSourceIdentifier.js +36 -0
  73. package/src/engine/input/devices/isHTMLElementFocusable.d.ts +6 -0
  74. package/src/engine/input/devices/isHTMLElementFocusable.d.ts.map +1 -0
  75. package/src/engine/input/devices/isHTMLElementFocusable.js +34 -0
  76. package/src/engine/network/PriorityFetch.d.ts.map +1 -1
  77. package/src/engine/network/PriorityFetch.js +2 -2
  78. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
  79. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
  80. package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +4 -4
  81. package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts.map +1 -1
  82. package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +2 -2
  83. package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
  84. package/src/core/collection/heap/FastBinaryHeap.d.ts.map +0 -1
  85. package/src/core/collection/heap/FastBinaryHeap.spec.d.ts +0 -2
  86. package/src/core/collection/heap/FastBinaryHeap.spec.d.ts.map +0 -1
  87. package/src/core/collection/heap/Uin32Heap.spec.d.ts +0 -2
  88. package/src/core/collection/heap/Uin32Heap.spec.d.ts.map +0 -1
  89. package/src/core/graph/cluster_mesh_metis.d.ts +0 -28
  90. package/src/core/graph/cluster_mesh_metis.d.ts.map +0 -1
  91. package/src/engine/animation/async/findSampleIndex.d.ts +0 -9
  92. package/src/engine/animation/async/findSampleIndex.d.ts.map +0 -1
  93. /package/src/core/collection/heap/{Uin32Heap.spec.js → Uint32Heap.spec.js} +0 -0
@@ -1,10 +1,23 @@
1
1
  import { assert } from "../../assert.js";
2
2
 
3
3
  /**
4
- * Min-Heap implementation with a score function. The data structure is a binary heap where elements are removed in order defined by scoring function
4
+ * Min-Heap implementation with a score function.
5
+ * The data structure is a binary heap where elements are removed in order defined by scoring function
5
6
  * @template T
6
7
  */
7
8
  class BinaryHeap {
9
+ /**
10
+ * @private
11
+ * @type {T[]}
12
+ */
13
+ data = [];
14
+
15
+ /**
16
+ * @private
17
+ * @type {number}
18
+ */
19
+ length = 0;
20
+
8
21
  /**
9
22
  * @template T
10
23
  * @param {function(el:T):number} scoreFunction
@@ -18,17 +31,6 @@ class BinaryHeap {
18
31
  */
19
32
  this.scoreFunction = scoreFunction;
20
33
 
21
- /**
22
- *
23
- * @type {T[]}
24
- */
25
- this.data = [];
26
-
27
- /**
28
- * @private
29
- * @type {number}
30
- */
31
- this.length = 0;
32
34
  }
33
35
 
34
36
  /**
@@ -100,19 +102,19 @@ class BinaryHeap {
100
102
  if (right >= length) {
101
103
  //right node doesn't exist
102
104
 
103
-
104
105
  if (scoreLeft >= scoreMin) {
105
106
  break;
106
107
  } else {
107
108
  minIndex = left;
108
109
  dataMin = dataLeft;
109
110
  }
111
+
110
112
  } else {
113
+
111
114
  //both left and right nodes exist
112
115
  const dataRight = data[right];
113
116
  const scoreRight = this.scoreFunction(dataRight);
114
117
 
115
- //
116
118
  if (scoreLeft <= scoreRight) {
117
119
  if (scoreLeft >= scoreMin) {
118
120
  break;
@@ -128,6 +130,7 @@ class BinaryHeap {
128
130
  dataMin = dataRight;
129
131
  }
130
132
  }
133
+
131
134
  }
132
135
 
133
136
  //swap positions
@@ -145,7 +148,6 @@ class BinaryHeap {
145
148
  */
146
149
  pop() {
147
150
 
148
-
149
151
  this.length--;
150
152
 
151
153
  const new_length = this.length;
@@ -154,19 +156,20 @@ class BinaryHeap {
154
156
 
155
157
  if (new_length === 0) {
156
158
 
159
+ // this was the last element in the heap
160
+
157
161
  return last;
158
162
 
159
- } else {
163
+ }
160
164
 
161
- const ret = this.data[0];
165
+ const ret = this.data[0];
162
166
 
163
- this.data[0] = last;
167
+ this.data[0] = last;
164
168
 
165
- this.bubbleDown(0);
169
+ this.bubbleDown(0);
166
170
 
167
- return ret;
171
+ return ret;
168
172
 
169
- }
170
173
  }
171
174
 
172
175
  /**
@@ -270,4 +273,11 @@ class BinaryHeap {
270
273
  }
271
274
  }
272
275
 
276
+ /**
277
+ * Useful for type checks
278
+ * @readonly
279
+ * @type {boolean}
280
+ */
281
+ BinaryHeap.prototype.isBinaryHeap = true;
282
+
273
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,7 +2,7 @@ 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 BinaryHeap from "./FastBinaryHeap.js";
5
+ import BinaryHeap from "./BinaryHeap.js";
6
6
 
7
7
  test("constructor doesn't throw", () => {
8
8
  new BinaryHeap(returnZero);
@@ -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":""}
@@ -1,7 +1,10 @@
1
+ /**
2
+ * Compact binary table storage
3
+ */
1
4
  export class RowFirstTable {
2
5
  /**
3
6
  *
4
- * @param {RowFirstTableSpec} spec
7
+ * @param {RowFirstTableSpec} spec what does the schema look like? How many columns do we have and what are their types?
5
8
  * @param {boolean} [shared_array] should we use SharedArrayBuffer instead of ArrayBuffer?
6
9
  * @constructor
7
10
  */
@@ -71,9 +74,9 @@ export class RowFirstTable {
71
74
  hash(): number;
72
75
  /**
73
76
  *
74
- * @param {int} rowCount
77
+ * @param {number} rowCount
75
78
  */
76
- setCapacity(rowCount: int): void;
79
+ setCapacity(rowCount: number): void;
77
80
  /**
78
81
  * Drop excess capacity, setting capacity exactly to the current length
79
82
  */
@@ -112,15 +115,15 @@ export class RowFirstTable {
112
115
  insertRows(index: number, rowCount: number): void;
113
116
  /**
114
117
  *
115
- * @param {Array.<Number>} values
118
+ * @param {Array.<number>} values
116
119
  */
117
120
  addRow(values: Array<number>): void;
118
121
  /**
119
122
  *
120
- * @param {int} count number of rows to be added
121
- * @param {function} valueSupplier supplier of row values, called with row index and an empty row to be filled
123
+ * @param {number} count number of rows to be added
124
+ * @param {function(row_index:number, row:Array.<number>):*} valueSupplier supplier of row values, called with row index and an empty row to be filled
122
125
  */
123
- addRows(count: int, valueSupplier: Function): void;
126
+ addRows(count: number, valueSupplier: any): void;
124
127
  /**
125
128
  * Copy data from another table. Specs must match.
126
129
  * NOTE: does not send onAdded signal
@@ -1 +1 @@
1
- {"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AAMA;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EAuDjB;IA/CG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,gBAFU,qBAAsB,CAET;IAEvB;;;OAGG;IACH,MAFU,WAAW,CAEuB;IAE5C;;;OAGG;IACH,gBAFU,MAAM,CAEyB;IAEzC;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,UAFU,QAAQ,CAEE;IAEpB;;MAEC;IAKL;;OAEG;IACH,mBAiBC;IAXG;;;OAGG;IACH,sBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEb;IAEvC;;;OAGG;IACH,uBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEX;IAG7C;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA4BlB;IAED;;;OAGG;IACH,iCAoCC;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,iBAFW,MAAM,QAYhB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,eACN,MAAM,SACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAclB;IAED;;;;OAIG;IACH,kBAHW,MAAM,YACN,MAAM,QAyBhB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,YACN,MAAM,QAqBhB;IAED;;;OAGG;IACH,eAFW,aAAc,QAgBxB;IAED;;;;OAIG;IACH,mDAiCC;IAED;;;;OAIG;IACH,YAFW,aAAa,QAsBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAyBnB;IAED;;;;OAIG;IACH,wCAEC;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,EAAE,QAIlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,wBAEC;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAgBtB;IAED;;OAEG;IACH,uBAIC;CACJ;mBA1fkB,+BAA+B"}
1
+ {"version":3,"file":"RowFirstTable.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/table/RowFirstTable.js"],"names":[],"mappings":"AAMA;;GAEG;AACH;IACI;;;;;OAKG;IACH,oDAHW,OAAO,EAuDjB;IA/CG;;;OAGG;IACH,wBAAgB;IAEhB;;;OAGG;IACH,gBAFU,qBAAsB,CAET;IAEvB;;;OAGG;IACH,MAFU,WAAW,CAEuB;IAE5C;;;OAGG;IACH,gBAFU,MAAM,CAEyB;IAEzC;;;OAGG;IACH,QAFU,MAAM,CAED;IAEf;;;OAGG;IACH,UAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,UAFU,QAAQ,CAEE;IAEpB;;MAEC;IAKL;;OAEG;IACH,mBAiBC;IAXG;;;OAGG;IACH,sBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEb;IAEvC;;;OAGG;IACH,uBAFmB,QAAQ,QAAE,MAAM,QAAE,MAAM,EAAE,KAAG,IAAI,CAEX;IAG7C;;;;OAIG;IACH,uDAMC;IAED;;;OAGG;IACH,QAFa,MAAM,CA4BlB;IAED;;;OAGG;IACH,sBAFW,MAAM,QA+ChB;IAED;;OAEG;IACH,aAEC;IAED;;;OAGG;IACH,iBAFW,MAAM,QAchB;IAED;;;;;OAKG;IACH,yBAJW,MAAM,eACN,MAAM,SACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,eACN,MAAM,GACJ,MAAM,CAclB;IAED;;;;OAIG;IACH,kBAHW,MAAM,YACN,MAAM,QAyBhB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,YACN,MAAM,QAqBhB;IAED;;;OAGG;IACH,eAFW,MAAO,MAAM,CAAC,QAexB;IAED;;;;OAIG;IACH,eAHW,MAAM,4BAoChB;IAED;;;;OAIG;IACH,YAFW,aAAa,QAsBvB;IAED;;;OAGG;IACH,cAHW,aAAa,GACX,OAAO,CAyBnB;IAED;;;;OAIG;IACH,wCAIC;IAED;;;;OAIG;IACH,cAHW,MAAM,UACN,MAAM,EAAE,QAMlB;IAED;;OAEG;IACH,qBA4BC;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,wBAEC;IAED;;;OAGG;IACH,cAFa,MAAM,EAAE,EAAE,CAgBtB;IAED;;OAEG;IACH,uBAIC;CACJ;mBA3gBkB,+BAA+B"}
@@ -4,10 +4,13 @@ import Signal from "../../events/signal/Signal.js";
4
4
  import { max2 } from "../../math/max2.js";
5
5
  import { array_copy } from "../array/array_copy.js";
6
6
 
7
+ /**
8
+ * Compact binary table storage
9
+ */
7
10
  export class RowFirstTable {
8
11
  /**
9
12
  *
10
- * @param {RowFirstTableSpec} spec
13
+ * @param {RowFirstTableSpec} spec what does the schema look like? How many columns do we have and what are their types?
11
14
  * @param {boolean} [shared_array] should we use SharedArrayBuffer instead of ArrayBuffer?
12
15
  * @constructor
13
16
  */
@@ -134,13 +137,22 @@ export class RowFirstTable {
134
137
 
135
138
  /**
136
139
  *
137
- * @param {int} rowCount
140
+ * @param {number} rowCount
138
141
  */
139
142
  setCapacity(rowCount) {
143
+ assert.isNonNegativeInteger(rowCount, 'rowCount');
144
+
145
+ if(this.capacity === rowCount){
146
+ // already right size
147
+ return;
148
+ }
149
+
150
+
140
151
  const oldData = this.data;
141
152
 
142
153
  const bytesPerRecord = this.bytesPerRecord;
143
154
  const byteSize = rowCount * bytesPerRecord;
155
+
144
156
  try {
145
157
  // can be either ArrayBuffer or SharedArrayBuffer
146
158
  const BufferConstructor = this.data.constructor;
@@ -186,6 +198,8 @@ export class RowFirstTable {
186
198
  * @param {number} rowCount
187
199
  */
188
200
  resize(rowCount) {
201
+ assert.isNonNegativeInteger(rowCount, 'rowCount');
202
+
189
203
  if (this.capacity < rowCount) {
190
204
  //grow
191
205
  const growFactor = 1.5;
@@ -296,7 +310,7 @@ export class RowFirstTable {
296
310
 
297
311
  /**
298
312
  *
299
- * @param {Array.<Number>} values
313
+ * @param {Array.<number>} values
300
314
  */
301
315
  addRow(values) {
302
316
 
@@ -308,7 +322,6 @@ export class RowFirstTable {
308
322
 
309
323
  this.length = newRowCount;
310
324
 
311
-
312
325
  this.writeRowMethod(this.dataView, this.bytesPerRecord * rowIndex, values);
313
326
 
314
327
  this.on.added.send2(rowIndex, values);
@@ -316,8 +329,8 @@ export class RowFirstTable {
316
329
 
317
330
  /**
318
331
  *
319
- * @param {int} count number of rows to be added
320
- * @param {function} valueSupplier supplier of row values, called with row index and an empty row to be filled
332
+ * @param {number} count number of rows to be added
333
+ * @param {function(row_index:number, row:Array.<number>):*} valueSupplier supplier of row values, called with row index and an empty row to be filled
321
334
  */
322
335
  addRows(count, valueSupplier) {
323
336
  const newRowCount = this.length + count;
@@ -416,6 +429,8 @@ export class RowFirstTable {
416
429
  * @param {Array} result where row values are to be stored
417
430
  */
418
431
  getRow(index, result) {
432
+ assert.isNonNegativeInteger(index,'index');
433
+
419
434
  this.readRowMethod(this.dataView, this.bytesPerRecord * index, result);
420
435
  }
421
436
 
@@ -425,6 +440,8 @@ export class RowFirstTable {
425
440
  * @param {number[]} record
426
441
  */
427
442
  setRow(index, record) {
443
+ assert.isNonNegativeInteger(index,'index');
444
+
428
445
  this.writeRowMethod(this.dataView, this.bytesPerRecord * index, record);
429
446
  }
430
447
 
@@ -23,10 +23,10 @@ export function encode_unit_to_octahedron(
23
23
  const inverse_sum = 1 / abs_sum;
24
24
 
25
25
  let p_x = x * inverse_sum;
26
- let p_y = y * inverse_sum;
26
+ let p_y = z * inverse_sum;
27
27
 
28
28
  // Reflect the folds of the lower hemisphere over the diagonals
29
- if (z < 0) {
29
+ if (y < 0) {
30
30
  const abs_x = Math.abs(p_x);
31
31
  const abs_y = Math.abs(p_y);
32
32
 
@@ -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 BinaryHeap 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";
@@ -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"}