@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.
- package/build_log.txt +500 -0
- package/build_src_log.txt +8 -0
- package/examples/basic-usage.tsx +19 -19
- package/package.json +1 -1
- package/public/hexgrid-worker.js +2350 -1638
- package/site/.eslintrc.json +3 -0
- package/site/DEPLOYMENT.md +196 -0
- package/site/INDEX.md +127 -0
- package/site/QUICK_START.md +86 -0
- package/site/README.md +85 -0
- package/site/SITE_SUMMARY.md +180 -0
- package/site/next.config.js +12 -0
- package/site/package.json +26 -0
- package/site/src/app/docs/page.tsx +148 -0
- package/site/src/app/examples/page.tsx +133 -0
- package/site/src/app/globals.css +160 -0
- package/site/src/app/layout.tsx +29 -0
- package/site/src/app/page.tsx +163 -0
- package/site/tsconfig.json +29 -0
- package/site/vercel.json +6 -0
- package/src/Snapshot.ts +790 -585
- package/src/adapters/DashAdapter.ts +57 -0
- package/src/adapters.ts +16 -18
- package/src/algorithms/AdvancedStatistics.ts +58 -24
- package/src/algorithms/BayesianStatistics.ts +43 -12
- package/src/algorithms/FlowField.ts +30 -6
- package/src/algorithms/FlowField3D.ts +573 -0
- package/src/algorithms/FluidSimulation.ts +19 -3
- package/src/algorithms/FluidSimulation3D.ts +664 -0
- package/src/algorithms/GraphAlgorithms.ts +19 -12
- package/src/algorithms/OutlierDetection.ts +72 -38
- package/src/algorithms/ParticleSystem.ts +12 -2
- package/src/algorithms/ParticleSystem3D.ts +567 -0
- package/src/algorithms/index.ts +14 -8
- package/src/compat.ts +10 -10
- package/src/components/HexGrid.tsx +10 -23
- package/src/components/NarrationOverlay.tsx +140 -52
- package/src/components/index.ts +2 -1
- package/src/features.ts +31 -31
- package/src/index.ts +11 -11
- package/src/lib/narration.ts +17 -0
- package/src/lib/stats-tracker.ts +25 -0
- package/src/lib/theme-colors.ts +12 -0
- package/src/math/HexCoordinates.ts +849 -4
- package/src/math/Matrix4.ts +2 -12
- package/src/math/Vector3.ts +49 -1
- package/src/math/index.ts +6 -6
- package/src/note-adapter.ts +50 -42
- package/src/ontology-adapter.ts +30 -23
- package/src/stores/uiStore.ts +34 -34
- package/src/types/shared-utils.d.ts +10 -0
- package/src/types.ts +110 -98
- package/src/utils/image-utils.ts +9 -6
- package/src/wasm/HexGridWasmWrapper.ts +436 -388
- package/src/wasm/index.ts +2 -2
- package/src/workers/hexgrid-math.ts +40 -35
- package/src/workers/hexgrid-worker.worker.ts +1992 -1018
- package/tsconfig.json +21 -14
package/src/wasm/index.ts
CHANGED
|
@@ -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(
|
|
176
|
+
return calculatePhotoContiguity(
|
|
177
|
+
tempIndices,
|
|
178
|
+
positions,
|
|
179
|
+
hexRadius,
|
|
180
|
+
getNeighbors
|
|
181
|
+
);
|
|
177
182
|
}
|