@buley/hexgrid-3d 1.0.0 → 1.1.1

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 (58) hide show
  1. package/build_log.txt +500 -0
  2. package/build_src_log.txt +8 -0
  3. package/examples/basic-usage.tsx +19 -19
  4. package/package.json +1 -1
  5. package/public/hexgrid-worker.js +2350 -1638
  6. package/site/.eslintrc.json +3 -0
  7. package/site/DEPLOYMENT.md +196 -0
  8. package/site/INDEX.md +127 -0
  9. package/site/QUICK_START.md +86 -0
  10. package/site/README.md +85 -0
  11. package/site/SITE_SUMMARY.md +180 -0
  12. package/site/next.config.js +12 -0
  13. package/site/package.json +26 -0
  14. package/site/src/app/docs/page.tsx +148 -0
  15. package/site/src/app/examples/page.tsx +133 -0
  16. package/site/src/app/globals.css +160 -0
  17. package/site/src/app/layout.tsx +29 -0
  18. package/site/src/app/page.tsx +163 -0
  19. package/site/tsconfig.json +29 -0
  20. package/site/vercel.json +6 -0
  21. package/src/Snapshot.ts +790 -585
  22. package/src/adapters/DashAdapter.ts +57 -0
  23. package/src/adapters.ts +16 -18
  24. package/src/algorithms/AdvancedStatistics.ts +58 -24
  25. package/src/algorithms/BayesianStatistics.ts +43 -12
  26. package/src/algorithms/FlowField.ts +30 -6
  27. package/src/algorithms/FlowField3D.ts +573 -0
  28. package/src/algorithms/FluidSimulation.ts +19 -3
  29. package/src/algorithms/FluidSimulation3D.ts +664 -0
  30. package/src/algorithms/GraphAlgorithms.ts +19 -12
  31. package/src/algorithms/OutlierDetection.ts +72 -38
  32. package/src/algorithms/ParticleSystem.ts +12 -2
  33. package/src/algorithms/ParticleSystem3D.ts +567 -0
  34. package/src/algorithms/index.ts +14 -8
  35. package/src/compat.ts +10 -10
  36. package/src/components/HexGrid.tsx +10 -23
  37. package/src/components/NarrationOverlay.tsx +140 -52
  38. package/src/components/index.ts +2 -1
  39. package/src/features.ts +31 -31
  40. package/src/index.ts +11 -11
  41. package/src/lib/narration.ts +17 -0
  42. package/src/lib/stats-tracker.ts +25 -0
  43. package/src/lib/theme-colors.ts +12 -0
  44. package/src/math/HexCoordinates.ts +849 -4
  45. package/src/math/Matrix4.ts +2 -12
  46. package/src/math/Vector3.ts +49 -1
  47. package/src/math/index.ts +6 -6
  48. package/src/note-adapter.ts +50 -42
  49. package/src/ontology-adapter.ts +30 -23
  50. package/src/stores/uiStore.ts +34 -34
  51. package/src/types/shared-utils.d.ts +10 -0
  52. package/src/types.ts +110 -98
  53. package/src/utils/image-utils.ts +9 -6
  54. package/src/wasm/HexGridWasmWrapper.ts +436 -388
  55. package/src/wasm/index.ts +2 -2
  56. package/src/workers/hexgrid-math.ts +40 -35
  57. package/src/workers/hexgrid-worker.worker.ts +1992 -1018
  58. package/tsconfig.json +21 -14
package/src/wasm/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WASM Module Exports
3
- *
3
+ *
4
4
  * @module wasm
5
5
  */
6
6
 
7
- export * from './HexGridWasmWrapper'
7
+ export * from './HexGridWasmWrapper';
@@ -12,23 +12,23 @@
12
12
  */
13
13
  export function getGridBounds(positions: [number, number, number][]) {
14
14
  if (!positions || positions.length === 0) {
15
- return { minX: 0, maxX: 0, minY: 0, maxY: 0, width: 0, height: 0 }
15
+ return { minX: 0, maxX: 0, minY: 0, maxY: 0, width: 0, height: 0 };
16
16
  }
17
17
 
18
18
  let minX = Infinity,
19
19
  maxX = -Infinity,
20
20
  minY = Infinity,
21
- maxY = -Infinity
21
+ maxY = -Infinity;
22
22
 
23
23
  for (const p of positions) {
24
- if (!p) continue
25
- minX = Math.min(minX, p[0])
26
- maxX = Math.max(maxX, p[0])
27
- minY = Math.min(minY, p[1])
28
- maxY = Math.max(maxY, p[1])
24
+ if (!p) continue;
25
+ minX = Math.min(minX, p[0]);
26
+ maxX = Math.max(maxX, p[0]);
27
+ minY = Math.min(minY, p[1]);
28
+ maxY = Math.max(maxY, p[1]);
29
29
  }
30
30
 
31
- return { minX, maxX, minY, maxY, width: maxX - minX, height: maxY - minY }
31
+ return { minX, maxX, minY, maxY, width: maxX - minX, height: maxY - minY };
32
32
  }
33
33
 
34
34
  /**
@@ -46,20 +46,20 @@ export function distanceBetween(
46
46
  bounds: { width: number; height: number },
47
47
  isSpherical: boolean
48
48
  ): number {
49
- let dx = b[0] - a[0]
50
- let dy = b[1] - a[1]
49
+ let dx = b[0] - a[0];
50
+ let dy = b[1] - a[1];
51
51
 
52
52
  if (isSpherical && bounds.width > 0 && bounds.height > 0) {
53
53
  // Apply toroidal wrapping: shortest distance considering wraparound
54
54
  if (Math.abs(dx) > bounds.width / 2) {
55
- dx = dx > 0 ? dx - bounds.width : dx + bounds.width
55
+ dx = dx > 0 ? dx - bounds.width : dx + bounds.width;
56
56
  }
57
57
  if (Math.abs(dy) > bounds.height / 2) {
58
- dy = dy > 0 ? dy - bounds.height : dy + bounds.height
58
+ dy = dy > 0 ? dy - bounds.height : dy + bounds.height;
59
59
  }
60
60
  }
61
61
 
62
- return Math.sqrt(dx * dx + dy * dy)
62
+ return Math.sqrt(dx * dx + dy * dy);
63
63
  }
64
64
 
65
65
  /**
@@ -82,16 +82,16 @@ export function calculateUvBoundsFromGridPosition(
82
82
  ): [number, number, number, number] {
83
83
  // Guard against invalid grid dimensions
84
84
  if (tilesX <= 0 || tilesY <= 0) {
85
- return [0, 0, 1, 1]
85
+ return [0, 0, 1, 1];
86
86
  }
87
87
 
88
- const minU = gridCol / tilesX
89
- const maxU = (gridCol + 1) / tilesX
88
+ const minU = gridCol / tilesX;
89
+ const maxU = (gridCol + 1) / tilesX;
90
90
  // V=1 is top, so row 0 maps to top (maxV=1, minV=1-1/tilesY)
91
- const minV = 1 - (gridRow + 1) / tilesY
92
- const maxV = 1 - gridRow / tilesY
91
+ const minV = 1 - (gridRow + 1) / tilesY;
92
+ const maxV = 1 - gridRow / tilesY;
93
93
 
94
- return [minU, minV, maxU, maxV]
94
+ return [minU, minV, maxU, maxV];
95
95
  }
96
96
 
97
97
  /**
@@ -110,21 +110,21 @@ export function calculateContiguity(
110
110
  hexRadius: number,
111
111
  getNeighbors: (index: number) => number[]
112
112
  ): number {
113
- if (!indices || indices.length === 0) return 0
114
- if (!positions || positions.length === 0) return 0
115
- if (hexRadius <= 0) return 0
113
+ if (!indices || indices.length === 0) return 0;
114
+ if (!positions || positions.length === 0) return 0;
115
+ if (hexRadius <= 0) return 0;
116
116
 
117
- const set = new Set(indices)
118
- let total = 0
117
+ const set = new Set(indices);
118
+ let total = 0;
119
119
 
120
120
  for (const idx of indices) {
121
- const neighbors = getNeighbors(idx)
121
+ const neighbors = getNeighbors(idx);
122
122
  for (const n of neighbors) {
123
- if (set.has(n)) total++
123
+ if (set.has(n)) total++;
124
124
  }
125
125
  }
126
126
 
127
- return total
127
+ return total;
128
128
  }
129
129
 
130
130
  /**
@@ -142,7 +142,7 @@ export function calculatePhotoContiguity(
142
142
  hexRadius: number,
143
143
  getNeighbors: (index: number) => number[]
144
144
  ): number {
145
- return calculateContiguity(indices, positions, hexRadius, getNeighbors)
145
+ return calculateContiguity(indices, positions, hexRadius, getNeighbors);
146
146
  }
147
147
 
148
148
  /**
@@ -164,14 +164,19 @@ export function calculateSwappedContiguity(
164
164
  toIndex: number,
165
165
  getNeighbors: (index: number) => number[]
166
166
  ): number {
167
- if (!indices || indices.length === 0) return 0
167
+ if (!indices || indices.length === 0) return 0;
168
168
 
169
- const tempIndices = [...indices]
170
- const fromPos = tempIndices.indexOf(fromIndex)
171
- const toPos = tempIndices.indexOf(toIndex)
169
+ const tempIndices = [...indices];
170
+ const fromPos = tempIndices.indexOf(fromIndex);
171
+ const toPos = tempIndices.indexOf(toIndex);
172
172
 
173
- if (fromPos !== -1) tempIndices[fromPos] = toIndex
174
- if (toPos !== -1) tempIndices[toPos] = fromIndex
173
+ if (fromPos !== -1) tempIndices[fromPos] = toIndex;
174
+ if (toPos !== -1) tempIndices[toPos] = fromIndex;
175
175
 
176
- return calculatePhotoContiguity(tempIndices, positions, hexRadius, getNeighbors)
176
+ return calculatePhotoContiguity(
177
+ tempIndices,
178
+ positions,
179
+ hexRadius,
180
+ getNeighbors
181
+ );
177
182
  }